/* ============================================
   App Layout
   ============================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #8b5cf6 100%);
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: var(--font-size-lg);
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.sidebar-brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-brand-text {
  font-size: var(--font-size-lg);
  font-weight: 800;
  color: var(--text-inverse);
  white-space: nowrap;
  letter-spacing: -0.03em;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-nav-text,
.sidebar.collapsed .sidebar-section-title {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.75rem;
}

.sidebar-section-title {
  padding: 1.25rem 0.75rem 0.5rem;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.35);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.875rem;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: all var(--transition-fast);
  border-radius: var(--border-radius-sm);
  text-decoration: none;
  font-size: var(--font-size-sm);
  margin: 2px 0;
  font-weight: 450;
  border: none;
  border-left: none;
}

.sidebar-nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--text-inverse);
  text-decoration: none;
}

.sidebar-nav-item.active {
  background: var(--bg-sidebar-active);
  color: #c7d2fe;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

.sidebar-nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.5;
}

.sidebar-nav-item:hover .sidebar-nav-icon {
  opacity: 0.9;
}

.sidebar-nav-item.active .sidebar-nav-icon {
  opacity: 1;
}

.sidebar-nav-badge {
  margin-left: auto;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: white;
  font-size: 0.625rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--border-radius-full);
  font-weight: 700;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(244, 63, 94, 0.4);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

/* ===== Nav lateral del perfil Ventas =====
   El sidebar del vendedor lleva la lista de sus clientes como acción principal:
   1 click sobre cualquiera = generar una orden de servicio para ese cliente. */
.sales-nav { padding: 0 0.5rem; }
.sales-nav__cta {
  display: flex; align-items: center; gap: 0.5rem;
  background: linear-gradient(135deg, #16a34a, #15803d);
  color: #fff !important; text-decoration: none;
  padding: 0.75rem 0.875rem; margin: 0.5rem 0; border-radius: 10px;
  font-weight: 800; font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
}
.sales-nav__cta:hover { background: linear-gradient(135deg, #15803d, #166534); }
.sales-nav__cta .ic { font-size: 18px; font-weight: 900; line-height: 1; }

.sales-nav__search {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px; padding: 0.4rem 0.6rem; margin: 6px 0;
}
.sales-nav__search input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #e2e8f0; font-size: 13px; font-family: inherit;
}
.sales-nav__search input::placeholder { color: rgba(255,255,255,0.35); }
.sales-nav__search .ic { font-size: 13px; opacity: 0.6; }

.sales-nav__list {
  max-height: 380px; overflow-y: auto;
  padding-right: 2px; margin-bottom: 8px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sales-nav__list::-webkit-scrollbar { width: 6px; }
.sales-nav__list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.sales-nav__client {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.625rem; margin: 1px 0; border-radius: 7px;
  color: var(--text-sidebar); text-decoration: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sales-nav__client:hover { background: var(--bg-sidebar-hover); color: #fff; text-decoration: none; }
.sales-nav__client .dot { font-size: 12px; line-height: 1; flex: 0 0 auto; }

.sales-nav__hint {
  padding: 0.75rem 0.75rem; font-size: 12px; color: rgba(255,255,255,0.4);
  font-style: italic;
}

.sales-nav__divider {
  height: 1px; background: rgba(255,255,255,0.08);
  margin: 10px 0.5rem;
}

/* Cuando el sidebar está colapsado (rail), ocultamos buscador, lista de
   clientes y el texto del CTA — quedan solo los íconos de pie. */
.sidebar.collapsed .sales-nav__cta,
.sidebar.collapsed .sales-nav__search,
.sidebar.collapsed .sales-nav__list { display: none; }
.sidebar.collapsed .sales-nav__divider { display: none; }

/* ============================================
   Main Content
   ============================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  background: var(--bg-secondary);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   Header
   ============================================ */
.header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

[data-theme="dark"] .header {
  background: rgba(15, 23, 42, 0.8);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-toggle {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}
.header-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--primary-600);
}

.header-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.header-breadcrumb-separator {
  color: var(--text-tertiary);
}

/* ============================================
   Page Content
   ============================================ */
.page-content {
  flex: 1;
  padding: 1.75rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================
   Auth Layout
   ============================================ */
.auth-layout {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-auth);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}

.auth-layout::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  pointer-events: none;
}

.auth-layout::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.2) 0%, transparent 70%);
  bottom: -150px;
  left: -150px;
  pointer-events: none;
}

.auth-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: var(--border-radius-2xl);
  box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 440px;
  padding: 2.75rem;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(20px);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 2.25rem;
}

.auth-logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: var(--font-size-xl);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.auth-logo-text {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #312e81, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-title {
  text-align: center;
  margin-bottom: 0.25rem;
  font-weight: 700;
  font-size: var(--font-size-2xl);
  letter-spacing: -0.02em;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 1.75rem;
  font-size: var(--font-size-sm);
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--primary-600);
  font-weight: 600;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .page-content {
    padding: 1rem;
  }
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }
}
