/**
 * SECOM Ventas — Tema base v3 (Navbar Mejorada)
 *
 * Estructura del documento:
 * 1. Variables CSS.
 * 2. Estilos Globales.
 * 3. Componentes Principales.
 * 4. Barra de Navegación (Navbar Layout).
 * 5. Elementos Específicos.
 * 6. Tema Oscuro (Dark Mode).
 */

/* ==========================================================================
   1. VARIABLES CSS
   ========================================================================== */
:root {
  --brand-primary: #3B82F6;
  --brand-secondary: #10B981;
  --brand-accent: #EF4444;
  --brand-bg: #F8F9FA;
  --surface: #FFFFFF;
  --brand-text: #2D3748;
  --brand-muted: #718096;
  --border-color: #E2E8F0;
  --success-bg: #D1FAE5;
  --success-text: #065F46;
  --error-bg: #FEE2E2;
  --error-text: #991B1B;
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   2. ESTILOS GLOBALES
   ========================================================================== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--brand-text);
  background: var(--brand-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}
a { color: inherit; text-decoration: none; }

/* ==========================================================================
   3. COMPONENTES PRINCIPALES
   ========================================================================== */
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.btn {
  background: var(--brand-primary);
  color: #fff;
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius);
  padding: 10px 16px;
  cursor: pointer;
  transition: all .2s ease;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn.outline { background: transparent; color: var(--brand-primary); }
.btn.outline:hover { background: var(--brand-primary); color: white; }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   4. BARRA DE NAVEGACIÓN (NAVBAR LAYOUT)
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 24px; /* Espacio entre el logo y el resto */
  border-bottom: 1px solid var(--border-color);
}
.navbar .brand { font-weight: 700; font-size: 1.25rem; color: var(--brand-primary); flex-shrink: 0; /* Evita que el logo se encoja */ }
.navbar-toggle-checkbox { display: none; }
.navbar-toggle-label { display: none; cursor: pointer; padding: 10px; }
.hamburger { position: relative; display: block; width: 24px; height: 2px; background: var(--brand-text); transition: transform 0.3s ease; }
.hamburger::before, .hamburger::after { content: ''; position: absolute; left: 0; width: 100%; height: 2px; background: var(--brand-text); transition: all 0.3s ease; }
.hamburger::before { top: -8px; }
.hamburger::after { top: 8px; }

/* Contenedor principal de navegación en Escritorio */
.nav-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between; /* CLAVE: Separa los enlaces de las acciones */
  flex-grow: 1; /* CLAVE: Hace que ocupe todo el espacio disponible */
}
.nav { display: flex; align-items: center; gap: 10px; }
.nav a {
  color: var(--brand-muted);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-weight: 500;
  transition: all 0.2s ease;
}
.nav a.active, .nav a:hover {
  background-color: var(--brand-primary);
  color: white;
}
.nav-actions { display: flex; align-items: center; gap: 12px; }
.user-info { font-size: 0.9rem; color: var(--brand-muted); white-space: nowrap; }

/* Estilos de la Navbar en Móvil */
@media (max-width: 1024px) {
  .navbar {
    justify-content: space-between;
  }
  .navbar-toggle-label { display: block; }
  .nav-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: absolute;
    top: 65px;
    left: 0;
    background: var(--surface);
    box-shadow: var(--shadow);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
  .navbar-toggle-checkbox:checked ~ .nav-wrapper {
    max-height: 100vh;
    border-top: 1px solid var(--border-color);
    padding-bottom: 16px;
  }
  .nav, .nav-actions {
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    align-items: stretch; /* Estira los elementos */
    gap: 0; /* Quita el espacio horizontal */
  }
  .nav a, .nav-actions a, .nav-actions .btn {
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
  }
  /* Oculta en móvil lo que no es necesario */
  .nav-actions .user-info, .nav-actions .btn.outline { 
    display: none; 
  }
  
  /* Animación del icono hamburguesa a 'X' */
  .navbar-toggle-checkbox:checked + .navbar-toggle-label .hamburger { transform: rotate(45deg); }
  .navbar-toggle-checkbox:checked + .navbar-toggle-label .hamburger::before { transform: rotate(90deg); top: 0; }
  .navbar-toggle-checkbox:checked + .navbar-toggle-label .hamburger::after { transform: rotate(90deg); top: 0; opacity: 0; }
}

/* ==========================================================================
   5. ELEMENTOS ESPECÍFICOS
   ========================================================================== */
.grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .grid.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.kpi .label { color: var(--brand-muted); font-size: 14px; }
.kpi .value { font-size: 28px; font-weight: 700; }
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #F8F9FA; text-align: left; padding: 12px; font-weight: 600; color: var(--brand-muted); border-bottom: 2px solid var(--border-color); }
tbody td { border-top: 1px solid var(--border-color); padding: 12px; }
.right { text-align: right; }
.muted { color: var(--brand-muted); }
.alerts { margin-bottom: 16px; }
.alert { padding: 12px 16px; border-radius: var(--radius); font-weight: 500; }
.alert.success { background: var(--success-bg); color: var(--success-text); }
.alert.error { background: var(--error-bg); color: var(--error-text); }
input, select, textarea {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  background: var(--surface);
  color: var(--brand-text);
  font-size: 1rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
label.muted { color: var(--brand-muted); font-size: 14px; display: block; margin-bottom: 6px; }

@media (max-width: 768px) {
  .grid, .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .kpi .value { font-size: 24px; }
  .container { margin-top: 16px; }
}

/* ==========================================================================
   6. TEMA OSCURO (DARK MODE)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --brand-bg: #1A202C;
    --surface: #2D3748;
    --brand-text: #E2E8F0;
    --brand-muted: #A0AEC0;
    --border-color: #4A5568;
    --success-bg: #2F855A;
    --success-text: #C6F6D5;
    --error-bg: #C53030;
    --error-text: #FED7D7;
  }
  thead th { background: #2D3748; color: var(--brand-muted); border-bottom: 2px solid var(--border-color); }
  .hamburger, .hamburger::before, .hamburger::after { background: var(--brand-text); }
}