/* =========================================================
   style.css — Componentes del sistema de semilleros
   Usa los tokens de /css/theme.css
   ========================================================= */


/* ─── TRANSICIÓN DE TEMA (Task 1) ───────────────────── */

body,
.layout,
.content,
.sidebar,
.navbar,
.kpi-card,
.quick-link-card,
#crudModal .crudModalBox,
#crudModal form,
.login-card,
.login-header,
.login-footer,
table,
th, td,
input, select, textarea,
.btn {
  transition: var(--transition-theme);
}


/* ─── BASE RESET ─────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}


/* ─── LAYOUT ─────────────────────────────────────────── */

.layout {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
}

/* Navbar */
.navbar {
  background: var(--color-nav);
  color: var(--color-text-invert);
  /* safe-area-inset-top: espacio para el notch / Dynamic Island de iPhone */
  padding: calc(var(--space-3) + env(safe-area-inset-top, 0px)) var(--space-6) var(--space-3);
  height: calc(56px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: flex-end;   /* alinea al borde inferior de la zona segura */
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-md);
  border-bottom: 1px solid var(--color-nav-border);
}

.navbar .logo strong {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  color: var(--color-text-invert);
}

.navbar .user-info {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.navbar .username {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.72);
  font-weight: var(--weight-medium);
}

/* Campana de notificaciones */
.bell-btn {
  position: relative;
  width: 44px; height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.bell-btn:hover {
  background: rgba(255,255,255,0.20);
  color: #fff;
  transform: rotate(-10deg);
}

.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 18px; height: 18px;
  background: var(--color-error);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid var(--color-nav);
  line-height: 1;
  pointer-events: none;
}

/* Animación de sacudida cuando hay nuevas notificaciones */
@keyframes bellShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-15deg); }
  40% { transform: rotate(15deg); }
  60% { transform: rotate(-10deg); }
  80% { transform: rotate(10deg); }
}

.bell-btn.has-unread { animation: bellShake 0.5s ease; }

/* Notificaciones no leídas en la lista */
.notif-unread {
  background: var(--color-primary-light) !important;
}

/* Theme toggle button */
.btn-theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
  min-height: unset;
}

.btn-theme-toggle:hover {
  background: rgba(255,255,255,0.20);
  color: #fff;
  transform: rotate(20deg);
}

/* Hamburger */
.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--color-text-invert);
  cursor: pointer;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 18px;
  line-height: 1;
  transition: background 0.2s ease;
  min-height: unset;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }

/* Overlay mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 299; }
.sidebar-overlay.active { display: block; }

/* Main */
.main { display: flex; min-height: calc(100vh - 56px - env(safe-area-inset-top, 0px)); }

/* Sidebar */
.sidebar {
  width: 224px;
  min-width: 224px;
  background: var(--color-sidebar);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar .menu { display: flex; flex-direction: column; gap: var(--space-1); }

.sidebar a,
.sidebar button.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  color: var(--color-sidebar-text);
  text-decoration: none;
  border: none;
  background: transparent;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-body);
  transition: background 0.2s ease, color 0.2s ease;
  text-align: left;
}

.sidebar a:hover,
.sidebar button.nav-link:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar a.active {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-text-active);
}

.sidebar a:focus-visible,
.sidebar button.nav-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Content */
.content {
  flex: 1;
  min-width: 0;
  padding: var(--space-6);
  background: var(--color-surface);
}


/* ─── SISTEMA .BTN (Task 2) ──────────────────────────── */

/* Base — nunca overflow, siempre flex-alineado */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;           /* 6px icono-texto */
  padding: 0.5rem 1rem;    /* 8px 16px */
  font-size: 0.875rem;     /* 14px */
  font-weight: var(--weight-semibold);
  line-height: 1;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  white-space: nowrap;     /* NUNCA wrap el texto dentro del botón */
  text-decoration: none;
  font-family: var(--font-body);
  min-height: 36px;
  transition: all 0.2s ease;
}

.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:hover  { transform: translateY(-1px); box-shadow: var(--shadow-btn); }
.btn:active { transform: translateY(0);    box-shadow: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }

/* Variantes */
.btn-primary {
  background: var(--color-gradient);
  color: #fff;
  border: none;
}
.btn-primary:hover { background: var(--color-gradient-hover); }

.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--color-primary);
  color: var(--color-primary);
}
.btn-secondary:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.btn-danger {
  background: var(--color-error-light);
  color: #dc2626;
  border: 1px solid var(--color-error-border);
}
.btn-danger:hover {
  background: #fee2e2;
  box-shadow: 0 4px 12px rgba(220,38,38,0.25);
}

.btn-success {
  background: var(--color-success-light);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}
.btn-success:hover { background: #a7f3d0; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.btn-ghost:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  box-shadow: none;
  transform: none;
}

.btn-warning {
  background: var(--color-warning-light);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
}

/* Tamaños */
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; min-height: 30px; }
.btn-lg { padding: 0.75rem 1.5rem;   font-size: 1rem;      min-height: 44px; }
.btn-full { width: 100%; }

/* Botones específicos del layout */
#logoutBtn { min-height: 44px; }


/* ─── TIPOGRAFÍA DE CONTENIDO ────────────────────────── */

.content h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
  line-height: var(--leading-tight);
}

.content h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-4);
  letter-spacing: -0.01em;
  line-height: var(--leading-tight);
}

.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.record-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  margin-top: var(--space-1);
}


/* ─── TABLAS ─────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

thead tr { border-bottom: 2px solid var(--color-border); }

th {
  background: var(--color-surface-2);
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  white-space: nowrap;
}

td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

/* Columna de acciones — ancho fijo para que los botones no empujen contenido */
td.actions-col, th.actions-col {
  width: 180px;
  min-width: 160px;
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
  align-items: center;
}

tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: var(--color-surface-2); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.03em;
}

.badge-active   { background: var(--color-success-light);  color: var(--color-success-text);  border: 1px solid var(--color-success-border); }
.badge-inactive { background: var(--color-surface-2);       color: var(--color-text-muted);    border: 1px solid var(--color-border); }
.badge-pending  { background: var(--color-warning-light);  color: var(--color-warning-text);  border: 1px solid var(--color-warning-border); }
.badge-approved { background: var(--color-success-light);  color: var(--color-success-text);  border: 1px solid var(--color-success-border); }
.badge-rejected { background: var(--color-error-light);    color: var(--color-error-text);    border: 1px solid var(--color-error-border); }

/* DataTables */
.dataTables_wrapper { font-size: var(--text-sm); color: var(--color-text); }
.dataTables_filter input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 6px var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
  transition: all 0.2s ease;
}
.dataTables_filter input:focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.dataTables_length select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  padding: 5px var(--space-2);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
}
.dt-buttons { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-3); }
.dt-button {
  background: var(--color-surface) !important;
  color: var(--color-text-muted) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: var(--radius-btn) !important;
  padding: 6px var(--space-3) !important;
  font-size: var(--text-xs) !important;
  font-family: var(--font-body) !important;
  font-weight: var(--weight-medium) !important;
  cursor: pointer;
  transition: all 0.2s ease !important;
  box-shadow: none !important;
}
.dt-button:hover { background: var(--color-primary-light) !important; border-color: var(--color-primary) !important; color: var(--color-primary-text) !important; }
.dataTables_paginate .paginate_button { border-radius: var(--radius-sm) !important; border: 1px solid var(--color-border) !important; padding: 4px 10px !important; font-size: var(--text-sm) !important; cursor: pointer; }
.dataTables_paginate .paginate_button.current { background: var(--color-gradient) !important; color: #fff !important; border-color: var(--color-primary) !important; }
.dataTables_paginate .paginate_button:hover:not(.current) { background: var(--color-primary-light) !important; color: var(--color-primary-text) !important; }
.dataTables_info { font-size: var(--text-xs); color: var(--color-text-muted); }


/* ─── EMPTY STATE ────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  gap: var(--space-4);
  background: var(--color-surface-2);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-card);
  margin-top: var(--space-4);
}

.empty-state-icon {
  width: 64px; height: 64px;
  background: var(--color-primary-light);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--color-primary);
}

.empty-state h3 { font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-text); margin: 0; }
.empty-state p  { font-size: var(--text-sm);  color: var(--color-text-muted); margin: 0; max-width: 320px; }


/* ─── SKELETON ────────────────────────────────────────── */

@keyframes shimmer {
  0%   { background-position: -800px 0; }
  100% { background-position:  800px 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--color-surface-2) 25%, var(--color-border) 50%, var(--color-surface-2) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

.skeleton-row  { height: 44px; margin-bottom: var(--space-2); border-radius: var(--radius-btn); }
.skeleton-card { height: 100px; border-radius: var(--radius-card); }


/* ─── MODAL ──────────────────────────────────────────── */

#crudModal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: var(--space-4);
  animation: fadeInOverlay 140ms ease;
}

@keyframes fadeInOverlay { from { opacity: 0; } to { opacity: 1; } }

#crudModal .crudModalBox,
#crudModal form {
  background: var(--color-surface);
  border-radius: var(--radius-card);
  padding: var(--space-8);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-card);
  animation: slideUpModal 180ms ease;
}

@keyframes slideUpModal {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

#crudModal h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-5);
  letter-spacing: -0.01em;
}

/* Legacy */
#createUserModal, #editUserModal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
#createUserModal form, #editUserModal form {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-card);
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-card);
}

.form-error-banner {
  background: var(--color-error-light);
  border: 1px solid var(--color-error-border);
  border-radius: var(--radius-btn);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-error-text);
  display: flex; align-items: center; gap: var(--space-2);
}

.modal-actions {
  display: flex; gap: var(--space-2);
  margin-top: var(--space-5); justify-content: flex-end;
}


/* ─── FORMULARIOS ────────────────────────────────────── */

.form-group { margin-bottom: var(--space-4); }

.form-group label,
#crudModal label,
#createUserModal label,
#editUserModal label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.required-star { color: var(--color-error); margin-left: 2px; }
.form-legend { font-size: var(--text-xs); color: var(--color-text-muted); margin-bottom: var(--space-4); }

#crudModal input,
#crudModal select,
#crudModal textarea,
#createUserModal input,
#createUserModal select,
#editUserModal input,
#editUserModal select {
  width: 100%;
  padding: 12px var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-surface);
  margin-bottom: 0;
  min-height: 44px;
  box-sizing: border-box;
  outline: none;
  transition: all 0.2s ease;
}

#crudModal input::placeholder,
#crudModal textarea::placeholder { color: var(--color-text-faint); }

#crudModal input:focus,
#crudModal select:focus,
#crudModal textarea:focus,
#createUserModal input:focus,
#createUserModal select:focus,
#editUserModal input:focus,
#editUserModal select:focus {
  border-color: var(--color-primary);
  box-shadow: var(--focus-ring);
  transform: translateY(-1px);
}

#crudModal input.field-valid,   #crudModal select.field-valid   { border-color: var(--color-success); }
#crudModal input.field-invalid, #crudModal select.field-invalid { border-color: var(--color-error); background: var(--color-error-light); }

.field-error-msg { display: block; font-size: var(--text-xs); color: var(--color-error); margin-top: var(--space-1); min-height: 16px; }
.field-error-msg:empty { display: none; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}


/* ─── KPI CARDS ──────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--space-2);
  transition: all 0.2s ease;
}

.kpi-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.kpi-card-header { display: flex; align-items: center; justify-content: space-between; }

.kpi-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-btn);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}

.kpi-icon-red    { background: var(--color-primary-light); color: var(--color-primary); }
.kpi-icon-green  { background: var(--color-success-light);  color: var(--color-success-text); }
.kpi-icon-yellow { background: var(--color-warning-light);  color: var(--color-warning); }
.kpi-icon-blue   { background: var(--color-info-light);     color: var(--color-info); }

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.kpi-label { font-size: var(--text-sm); color: var(--color-text-muted); font-weight: var(--weight-medium); }

.kpi-trend {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
}

.kpi-trend-up   { background: var(--color-success-light); color: var(--color-success-text); }
.kpi-trend-down { background: var(--color-error-light);   color: var(--color-error-text); }
.kpi-trend-flat { background: var(--color-surface-2);     color: var(--color-text-muted); }


/* ─── DASHBOARD ──────────────────────────────────────── */

.dashboard-welcome { margin-bottom: var(--space-6); }
.dashboard-welcome h1 { font-size: var(--text-2xl); font-weight: var(--weight-bold); color: var(--color-text); margin: 0 0 var(--space-1); letter-spacing: -0.02em; }
.dashboard-welcome p  { color: var(--color-text-muted); margin: 0; font-size: var(--text-base); }

.accent-divider { width: 80px; height: 4px; background: var(--gradient-accent); border-radius: var(--radius-full); margin: var(--space-3) 0; }

.section-title {
  font-size: var(--text-lg); font-weight: var(--weight-semibold); color: var(--color-text);
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.quick-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }

.quick-link-card {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--color-text);
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-2);
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
}

.quick-link-card:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary);
  color: var(--color-primary-text);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quick-link-card .ql-icon { font-size: 24px; }

/* Chart containers */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.chart-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-4);
}

.chart-card-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0;
}

.chart-card-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: 2px 0 0;
}

.chart-wrapper {
  position: relative;
  height: 220px;
}


/* ─── ALERT BLOCKS ────────────────────────────────────── */

.alert-warning {
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-btn);
  padding: var(--space-4);
  display: flex; align-items: flex-start; gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-warning-text);
}
.alert-warning i { color: var(--color-warning); margin-top: 2px; flex-shrink: 0; }


/* ─── MOBILE ─────────────────────────────────────────── */

@media (max-width: 768px) {
  .hamburger-btn { display: flex; align-items: center; justify-content: center; }

  /* Sidebar off-canvas — accesible via hamburger */
  .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0;
    z-index: 300; transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: translateX(0); }

  /* Padding básico — pwa.css añade el padding-bottom para el bottom nav */
  .content { padding: var(--space-4); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .quick-links-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }

  #crudModal { align-items: flex-end; padding: 0; }
  #crudModal .crudModalBox,
  #crudModal form { max-width: 100%; border-radius: var(--radius-card) var(--radius-card) 0 0; max-height: 85vh; padding: var(--space-6); }

  .dt-buttons { display: none; }
  .dataTables_filter { text-align: left !important; }
  .dataTables_filter input { font-size: 1rem !important; min-height: 44px; }

  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  /* 16px mínimo en iOS para evitar auto-zoom en inputs */
  #crudModal input, #crudModal select, #crudModal textarea,
  #createUserModal input, #createUserModal select,
  #editUserModal input, #editUserModal select {
    font-size: 1rem !important;
    min-height: 48px;
  }

  .mobile-card-table thead { display: none; }
  .mobile-card-table tbody tr {
    display: block; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius-card);
    margin-bottom: var(--space-3); padding: var(--space-3); box-shadow: var(--shadow-sm);
  }
  .mobile-card-table td {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); font-size: var(--text-sm);
  }
  .mobile-card-table td:last-child { border-bottom: none; justify-content: flex-start; gap: var(--space-2); flex-wrap: wrap; padding-top: var(--space-3); }
  .mobile-card-table td::before { content: attr(data-label); font-weight: var(--weight-semibold); font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .navbar .username { display: none; }
}


/* ─── UTILIDADES ─────────────────────────────────────── */

.text-muted   { color: var(--color-text-muted); }
.text-error   { color: var(--color-error); }
.text-success { color: var(--color-success); }
.text-primary { color: var(--color-primary); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }


/* ─── LOGIN (estilo login.php) ───────────────────────── */

.login-bg {
  min-height: 100vh;
  background-color: var(--color-bg);
  background-image: var(--bg-pattern);
  background-size: var(--bg-pattern-size);
  display: flex; flex-direction: column;
}

.login-header { background: var(--color-surface); border-bottom: 1px solid var(--color-border-muted); box-shadow: var(--shadow-sm); }
.login-header-inner { max-width: 80rem; margin: 0 auto; padding: 0 var(--space-6); height: 64px; display: flex; align-items: center; justify-content: space-between; }
.login-header-brand { display: flex; align-items: center; gap: var(--space-3); }
.login-header-brand h1 { font-size: var(--text-lg); font-weight: var(--weight-bold); color: var(--color-text); margin: 0; }
.login-header-brand p  { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0; }
.login-header-links { display: flex; align-items: center; gap: var(--space-6); }
.login-header-links a { font-size: var(--text-sm); color: var(--color-text-muted); text-decoration: none; transition: color 0.2s ease; }
.login-header-links a:hover { color: var(--color-primary); }

.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--space-12) var(--space-4); }
.login-grid { max-width: 72rem; width: 100%; display: grid; gap: var(--space-12); align-items: center; }
@media (min-width: 1024px) { .login-grid { grid-template-columns: 1fr 1fr; } }

.login-welcome { animation: slideInLeft 0.8s ease-out; }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-50px); } to { opacity: 1; transform: translateX(0); } }

.login-welcome-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 96px; height: 96px;
  background: var(--color-gradient);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg); margin-bottom: var(--space-8);
  animation: bounce-gentle 2s infinite;
}
@keyframes bounce-gentle { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.login-welcome-icon i { font-size: 2rem; color: var(--color-text-invert); }

.login-welcome h2 { font-size: var(--text-4xl); font-weight: var(--weight-bold); color: var(--color-text); margin: 0 0 var(--space-6); line-height: var(--leading-tight); }
.login-welcome h2 .text-gradient { background: var(--color-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.login-welcome p { font-size: var(--text-lg); color: var(--color-text-muted); margin: 0 0 var(--space-8); line-height: var(--leading-relaxed); }

.login-features { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-8); }
.login-feature-item { display: flex; align-items: center; gap: var(--space-3); }
.login-feature-icon { flex-shrink: 0; width: 32px; height: 32px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: 14px; }

.login-social { display: flex; gap: var(--space-3); }
.login-social a { width: 40px; height: 40px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; color: var(--color-text-invert); text-decoration: none; font-size: 14px; transition: all 0.2s ease; }
.login-social a:hover { transform: scale(1.1); filter: brightness(1.1); }

.login-form-side { animation: slideInRight 0.8s ease-out; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(50px); } to { opacity: 1; transform: translateX(0); } }

.login-card { background: var(--color-surface); border-radius: var(--radius-card); padding: var(--space-8) var(--space-10); box-shadow: var(--shadow-card); }
.login-card-header { text-align: center; margin-bottom: var(--space-8); }
.login-logo-wrapper { display: inline-block; background: var(--color-surface); border-radius: var(--radius-full); padding: var(--space-6); margin-bottom: var(--space-6); box-shadow: var(--shadow-lg); }
.login-card-header h1 { font-size: var(--text-3xl); font-weight: var(--weight-bold); color: var(--color-text); margin: 0 0 var(--space-2); }
.login-card-header p  { color: var(--color-text-muted); font-size: var(--text-lg); margin: 0 0 var(--space-4); }
.login-divider { width: 80px; height: 4px; background: var(--gradient-accent); border-radius: var(--radius-full); margin: 0 auto; }

.login-input-group { margin-bottom: var(--space-6); }
.login-input-group label { display: block; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text); margin-bottom: var(--space-2); }

.login-input {
  width: 100%; padding: 12px var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--color-text); background: var(--color-surface);
  outline: none; box-sizing: border-box;
  transition: all 0.2s ease;
}
.login-input::placeholder { color: var(--color-text-faint); }
.login-input:focus { border-color: var(--color-primary); box-shadow: var(--focus-ring); transform: translateY(-2px); }
.login-input.field-invalid { border-color: var(--color-error); background: var(--color-error-light); }

.login-submit-btn {
  width: 100%;
  background: var(--color-gradient);
  color: var(--color-text-invert);
  font-size: var(--text-base); font-weight: var(--weight-semibold);
  padding: 12px var(--space-6);
  border-radius: var(--radius-btn);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: var(--space-2);
  transition: all 0.2s ease;
  min-height: 48px;
  font-family: var(--font-body);
}
.login-submit-btn:hover { background: var(--color-gradient-hover); transform: translateY(-2px); box-shadow: var(--shadow-btn); }
.login-submit-btn:disabled { opacity: 0.65; cursor: not-allowed; transform: none; box-shadow: none; }

.login-links { margin-top: var(--space-8); padding-top: var(--space-6); border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: var(--space-3); }
@media (min-width: 640px) { .login-links { flex-direction: row; justify-content: space-between; align-items: center; } }

.login-links a { font-size: var(--text-sm); text-decoration: none; display: flex; align-items: center; gap: var(--space-2); transition: color 0.2s ease; }
.login-link-primary   { color: var(--color-primary); }
.login-link-primary:hover { color: var(--color-primary-dark); }
.login-link-secondary { color: var(--color-text-muted); }
.login-link-secondary:hover { color: var(--color-primary); }

.login-warning { margin-top: var(--space-6); padding: var(--space-4); background: var(--color-warning-light); border: 1px solid var(--color-warning-border); border-radius: var(--radius-btn); display: flex; align-items: flex-start; gap: var(--space-3); }
.login-warning i { color: var(--color-warning); flex-shrink: 0; }
.login-warning p { font-size: var(--text-sm); color: var(--color-warning-text); margin: 0; }

.login-field-error { display: block; font-size: var(--text-xs); color: var(--color-error); margin-top: var(--space-1); min-height: 16px; }

.login-footer { background: var(--color-surface); border-top: 1px solid var(--color-border); padding: var(--space-6) var(--space-4); }
.login-footer-inner { max-width: 80rem; margin: 0 auto; padding: 0 var(--space-6); display: flex; flex-direction: column; align-items: center; gap: var(--space-4); font-size: var(--text-sm); color: var(--color-text-muted); }
@media (min-width: 768px) { .login-footer-inner { flex-direction: row; justify-content: space-between; } }
.login-footer-links { display: flex; gap: var(--space-6); }
.login-footer-links a { color: var(--color-text-muted); text-decoration: none; transition: color 0.2s ease; }
.login-footer-links a:hover { color: var(--color-primary); }

.fade-in { animation: fadeIn 0.8s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
