/**
 * ============================================================================
 * TECNOFIX SOLUTIONS — Layout CSS
 * ============================================================================
 * 
 * Define la estructura del layout principal: header, sidebar y área de
 * contenido. Incluye el sistema de grids para tarjetas del dashboard.
 * ============================================================================
 */

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN PAGE — Centrado con fondo neumórfico
   ═══════════════════════════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-md);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: var(--space-2xl);
  border-radius: var(--radius-xl);
  box-shadow: var(--neu-shadow-raised);
  background: var(--bg-card);
  animation: fadeInUp var(--transition-slow) ease;
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.login-logo h1 {
  font-size: var(--text-3xl);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-top: var(--space-xs);
}

/* ── Demo credentials panel ────────────────────────────────────────── */
.demo-credentials {
  margin-top: var(--space-lg);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  box-shadow: var(--neu-shadow-inset-sm);
  background: var(--bg-input);
}

.demo-credentials h4 {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.demo-user-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: var(--neu-shadow-raised-sm);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.demo-user-btn:hover {
  box-shadow: var(--neu-shadow-hover);
  transform: translateY(-1px);
}

.demo-user-btn:active {
  box-shadow: var(--neu-shadow-inset-sm);
  transform: translateY(0);
}

.demo-user-btn:last-child {
  margin-bottom: 0;
}

.demo-user-btn .role-badge {
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.demo-user-btn .role-badge.admin { background: rgba(108, 92, 231, 0.15); color: var(--primary); }
.demo-user-btn .role-badge.supervisor { background: rgba(9, 132, 227, 0.15); color: var(--info); }
.demo-user-btn .role-badge.tecnico { background: rgba(0, 184, 148, 0.15); color: var(--success); }

/* ═══════════════════════════════════════════════════════════════════════════
   APP LAYOUT — Header + Sidebar + Content
   ═══════════════════════════════════════════════════════════════════════════ */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar content";
  min-height: 100vh;
  transition: grid-template-columns var(--transition-base);
}

/* ── Header ────────────────────────────────────────────────────────── */
.app-header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-lg);
  background: var(--bg-header);
  box-shadow: var(--neu-shadow-raised-sm);
  z-index: var(--z-header);
  gap: var(--space-md);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.menu-toggle {
  display: flex;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: var(--text-xl);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  box-shadow: var(--neu-shadow-raised-sm);
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.app-sidebar {
  grid-area: sidebar;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  box-shadow: var(--neu-shadow-raised-sm);
  z-index: var(--z-sidebar);
  overflow-y: auto;
  transition: transform var(--transition-base);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  height: var(--header-height);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-brand h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-size: var(--text-lg);
  font-weight: 700;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.sidebar-section-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: var(--space-md) var(--space-sm) var(--space-xs);
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.nav-item:hover {
  color: var(--primary);
  box-shadow: var(--neu-shadow-raised-sm);
  background: var(--bg-card);
}

.nav-item.active {
  color: var(--primary);
  box-shadow: var(--neu-shadow-inset-sm);
  background: var(--bg-input);
  font-weight: 600;
}

.nav-item .nav-icon {
  font-size: var(--text-lg);
  width: 24px;
  text-align: center;
}

/* ── Sidebar Collapsed State (Desktop) ─────────────────────────────── */
@media (min-width: 1025px) {
  .app-layout.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) 1fr;
  }
  
  .app-layout.sidebar-collapsed .app-sidebar {
    overflow: visible;
  }
  
  .app-layout.sidebar-collapsed .sidebar-brand h2 {
    display: none;
  }
  
  .app-layout.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding: var(--space-md) 0;
  }
  
  .app-layout.sidebar-collapsed .sidebar-section-title {
    display: none;
  }
  
  .app-layout.sidebar-collapsed .nav-item span:not(.nav-icon) {
    display: none;
  }
  
  .app-layout.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: var(--space-md) 0;
    position: relative;
    overflow: visible;
  }
  
  /* Custom Tooltip on hover */
  .app-layout.sidebar-collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + var(--space-sm));
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: var(--neu-shadow-raised);
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    z-index: 1000;
    font-size: var(--text-sm);
    font-weight: 500;
  }
  
  .app-layout.sidebar-collapsed .nav-item:hover::after {
    opacity: 1;
    visibility: visible;
  }
}

/* ── Content Area ──────────────────────────────────────────────────── */
.app-content {
  grid-area: content;
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height));
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.page-header h1 {
  font-size: var(--text-2xl);
}

.page-header-actions {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   GRID SYSTEM — Para tarjetas del dashboard
   ═══════════════════════════════════════════════════════════════════════════ */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

/* ── User menu dropdown ────────────────────────────────────────────── */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  box-shadow: var(--neu-shadow-raised-sm);
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.user-menu-trigger:hover {
  box-shadow: var(--neu-shadow-hover);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: var(--text-sm);
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + var(--space-sm));
  right: 0;
  min-width: 200px;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  box-shadow: var(--neu-shadow-raised);
  z-index: var(--z-dropdown);
  display: none;
  animation: fadeIn var(--transition-fast) ease;
}

.user-menu-dropdown.open {
  display: block;
}

.user-menu-dropdown .menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  font-family: var(--font-body);
}

.user-menu-dropdown .menu-item:hover {
  color: var(--primary);
  background: var(--bg-input);
}

.user-menu-dropdown .menu-item.danger:hover {
  color: var(--danger);
}

.user-menu-dropdown .menu-divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--space-xs) 0;
}

/* ── Theme toggle ──────────────────────────────────────────────────── */
.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  box-shadow: var(--neu-shadow-raised-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  box-shadow: var(--neu-shadow-hover);
  color: var(--primary);
}

.theme-toggle:active {
  box-shadow: var(--neu-shadow-inset);
}

/* ── Sidebar overlay (mobile) ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}
