/* ═══════════════════════════════════════════════════════════
   HJNS — Sistema de Inscripción de Turnos
   Identidad visual: Morado/Uva, Lila, Corinto, Negro, Blanco
   ═══════════════════════════════════════════════════════════ */

/* ── Variables de color ─────────────────────────────────── */
:root {
  --uva:        #4A0E5C;
  --uva-dark:   #320A3E;
  --uva-light:  #6B1F82;
  --lila:       #9B59B6;
  --lila-light: #C39BD3;
  --lila-pale:  #F0E6F6;
  --corinto:    #7B1D3A;
  --corinto-light: #A52950;
  --negro:      #1A1A1A;
  --gris-dark:  #3D3D3D;
  --gris:       #6B6B6B;
  --gris-light: #AFAFAF;
  --gris-pale:  #F4F4F4;
  --blanco:     #FFFFFF;
  --borde:      #D9CCE3;
  --sombra:     rgba(74, 14, 92, 0.12);
  --sombra-hover: rgba(74, 14, 92, 0.22);

  /* Semánticos */
  --exito:      #27AE60;
  --exito-pale: #E8F8F0;
  --error:      #C0392B;
  --error-pale: #FDECEA;
  --advertencia:#D4820A;
  --adv-pale:   #FEF3E2;
  --info:       #2980B9;
  --info-pale:  #EAF4FB;

  /* Tipografía */
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-size-base: 15px;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 60px;
  --radio: 8px;
  --radio-lg: 12px;
  --logo-height: 52px;
}

/* ── Reset y base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--font-size-base); scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--negro);
  background: var(--gris-pale);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--uva); text-decoration: none; }
a:hover { color: var(--lila); text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* ── Tipografía ─────────────────────────────────────────── */
h1, h2, h3, h4 { color: var(--uva-dark); font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p { margin-bottom: 0.5rem; }

/* ── Botones ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border: none;
  border-radius: var(--radio);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, box-shadow 0.18s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--uva);
  color: var(--blanco);
}
.btn-primary:hover:not(:disabled) {
  background: var(--uva-dark);
  box-shadow: 0 4px 12px var(--sombra-hover);
  text-decoration: none;
  color: var(--blanco);
}

.btn-secondary {
  background: var(--blanco);
  color: var(--uva);
  border: 1.5px solid var(--uva);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--lila-pale);
  text-decoration: none;
  color: var(--uva);
}

.btn-danger {
  background: var(--corinto);
  color: var(--blanco);
}
.btn-danger:hover:not(:disabled) {
  background: var(--corinto-light);
  text-decoration: none;
  color: var(--blanco);
}

.btn-ghost {
  background: transparent;
  color: var(--gris-dark);
  border: 1.5px solid var(--borde);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gris-pale);
  text-decoration: none;
  color: var(--negro);
}

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Formularios ────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gris-dark);
  margin-bottom: 5px;
}
label .req { color: var(--corinto); margin-left: 2px; }

input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--borde);
  border-radius: var(--radio);
  font-family: var(--font);
  font-size: 0.92rem;
  color: var(--negro);
  background: var(--blanco);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--uva);
  box-shadow: 0 0 0 3px rgba(74, 14, 92, 0.1);
}
input.error, select.error, textarea.error {
  border-color: var(--error);
}
textarea { resize: vertical; min-height: 80px; }

.field-error {
  font-size: 0.78rem;
  color: var(--error);
  margin-top: 4px;
  display: none;
}
.field-error.visible { display: block; }

/* ── Alertas ────────────────────────────────────────────── */
.alert {
  padding: 11px 16px;
  border-radius: var(--radio);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-left: 4px solid transparent;
}
.alert-error   { background: var(--error-pale);   border-color: var(--error);      color: #7B241C; }
.alert-success { background: var(--exito-pale);   border-color: var(--exito);      color: #1E8449; }
.alert-warning { background: var(--adv-pale);     border-color: var(--advertencia);color: #9C5F00; }
.alert-info    { background: var(--info-pale);    border-color: var(--info);       color: #1A5276; }
.alert.hidden  { display: none; }

/* ── Tarjetas ───────────────────────────────────────────── */
.card {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: 0 2px 8px var(--sombra);
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: 0.8rem;
  border-bottom: 1.5px solid var(--lila-pale);
}
.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--uva-dark);
}

/* ── Tablas ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radio); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead tr {
  background: var(--uva);
  color: var(--blanco);
}
thead th {
  padding: 11px 14px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--borde);
  transition: background 0.12s;
}
tbody tr:hover { background: var(--lila-pale); }
tbody td {
  padding: 10px 14px;
  vertical-align: middle;
}
tbody tr:last-child { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-activo   { background: var(--exito-pale); color: var(--exito); }
.badge-inactivo { background: var(--gris-pale);  color: var(--gris); }
.badge-admin    { background: var(--lila-pale);  color: var(--uva); }
.badge-usuario  { background: #EAF4FB;            color: var(--info); }
.badge-activa   { background: var(--exito-pale); color: var(--exito); }
.badge-cancelada{ background: var(--error-pale); color: var(--error); }

/* ── Layout principal (dashboard) ───────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--uva-dark);
  color: var(--blanco);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.25s;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo img {
  height: var(--logo-height);
  width: auto;
  object-fit: contain;
}
.sidebar-logo-text { font-size: 0.82rem; line-height: 1.3; color: var(--lila-light); }
.sidebar-logo-text strong { display: block; color: var(--blanco); font-size: 0.95rem; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  /* Scrollbar delgada: pista del color del sidebar, barra blanca */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.5) var(--uva-dark);
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: var(--uva-dark); }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.55);
  border-radius: 50px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.8); }
.nav-section { padding: 6px 16px 2px; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.08em; color: var(--lila-light); text-transform: uppercase; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--blanco); text-decoration: none; }
.nav-item.active {
  background: rgba(155,89,182,0.25);
  color: var(--blanco);
  border-left-color: var(--lila);
}
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: auto;
  background: var(--corinto);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  border-radius: 50px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
  font-size: 0.82rem;
  color: var(--lila-light);
  margin-bottom: 8px;
}
.sidebar-user strong { display: block; color: var(--blanco); font-size: 0.9rem; }

/* Contenido principal */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.top-bar {
  height: var(--header-height);
  background: var(--blanco);
  border-bottom: 1.5px solid var(--borde);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px var(--sombra);
}
.top-bar-title { font-size: 1.1rem; font-weight: 600; color: var(--uva-dark); flex: 1; }
.hamburger { display: none; background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--uva); }

.page-content { padding: 24px; flex: 1; }

/* ── Pantalla de Login ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--uva-dark) 0%, var(--uva) 60%, var(--lila) 100%);
  padding: 20px;
}
.login-card {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.4rem;
}
.login-logo img {
  height: 90px;
  width: auto;
  object-fit: contain;
}
.login-title {
  text-align: center;
  margin-bottom: 0.25rem;
  color: var(--uva-dark);
  font-size: 1.25rem;
}
.login-subtitle {
  text-align: center;
  color: var(--gris);
  font-size: 0.85rem;
  margin-bottom: 1.8rem;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-16px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1.5px solid var(--borde);
}
.modal-title { font-size: 1.05rem; font-weight: 600; color: var(--uva-dark); }
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--gris);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--gris-pale); color: var(--negro); }
.modal-body { padding: 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1.5px solid var(--borde);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Confirmación de inscripción ────────────────────────── */
.confirm-card {
  background: var(--lila-pale);
  border: 1.5px solid var(--borde);
  border-radius: var(--radio);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1rem;
}
.confirm-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--uva);
  margin-bottom: 0.8rem;
}
.confirm-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid var(--borde);
  font-size: 0.9rem;
  gap: 12px;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-label { color: var(--gris-dark); font-size: 0.82rem; white-space: nowrap; }
.confirm-value { font-weight: 600; color: var(--negro); text-align: right; }
.confirm-costo { font-size: 1.15rem; color: var(--uva); font-weight: 700; }

/* ── Filtros ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 1.2rem;
  background: var(--blanco);
  padding: 14px 16px;
  border-radius: var(--radio);
  box-shadow: 0 1px 4px var(--sombra);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 160px; flex: 1; }
.filter-group label { font-size: 0.78rem; font-weight: 600; color: var(--gris-dark); margin-bottom: 0; }
.filter-group input,
.filter-group select { font-size: 0.85rem; padding: 7px 10px; }

/* ── Grid de estadísticas (dashboard) ──────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--blanco);
  border-radius: var(--radio);
  padding: 1.2rem;
  box-shadow: 0 2px 8px var(--sombra);
  border-left: 4px solid var(--uva);
}
.stat-card.corinto { border-left-color: var(--corinto); }
.stat-card.lila    { border-left-color: var(--lila); }
.stat-card.exito   { border-left-color: var(--exito); }
.stat-label { font-size: 0.78rem; color: var(--gris); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--uva-dark); line-height: 1.2; }

/* ── Loader ─────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: var(--blanco);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-dark {
  border-color: rgba(74,14,92,0.2);
  border-top-color: var(--uva);
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
}
.loading-overlay.hidden { display: none; }

/* ── Utilidades ─────────────────────────────────────────── */
.hidden   { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gris); font-size: 0.85rem; }
.text-uva    { color: var(--uva); }
.text-error  { color: var(--error); }
.text-exito  { color: var(--exito); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-100 { width: 100%; }

.divider { border: none; border-top: 1.5px solid var(--borde); margin: 1.2rem 0; }

/* Grid de dos columnas que colapsa a una sola en móvil.
   Úsalo en vez de style="grid-template-columns:1fr 1fr" para que sea responsive. */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .filters-bar { flex-direction: column; }
  .filter-group { min-width: 100%; }
  table { font-size: 0.8rem; }
  thead th, tbody td { padding: 8px 10px; }

  /* Grids de dos columnas pasan a una sola */
  .grid-2 { grid-template-columns: 1fr; gap: 0; }

  /* Botones grandes ocupan todo el ancho para facilitar el toque */
  .btn-lg { width: 100%; justify-content: center; }
  .btn-lg + .btn-lg,
  .mt-3 .btn-lg { margin-left: 0 !important; margin-top: 10px; }

  /* El pie del modal apila los botones y cada uno es tappable */
  .modal-footer { flex-direction: column-reverse; align-items: stretch; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* Top bar un poco más compacta en móvil */
  .top-bar { padding: 0 14px; }
  .top-bar-title { font-size: 1rem; }

  /* Tarjetas con menos padding interno */
  .card { padding: 1.1rem; }
}

@media (max-width: 480px) {
  .login-card { padding: 1.8rem 1.2rem; }
  .stats-grid { grid-template-columns: 1fr; }

  /* Ocultar el nombre del usuario en la barra, dejar solo el avatar y rol */
  .top-bar-user > div { display: none; }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }
}
