/* ============================================================
   Sistema de Reservas CONALEP 295
   Paleta: Verde CONALEP #006B3C + Naranja #F47920
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@400;500;600;700&family=Inter:wght@400;500&display=swap');

:root {
  --verde: #006B3C;
  --verde-claro: #008A4E;
  --verde-oscuro: #004D2B;
  --verde-100: #E6F3EC;
  --verde-200: #B3D9C5;
  --naranja: #F47920;
  --naranja-claro: #F69140;
  --naranja-oscuro: #D4620E;
  --naranja-100: #FEF0E6;
  --blanco: #FFFFFF;
  --gris-50: #F7F8F6;
  --gris-100: #EEF0EC;
  --gris-200: #D4D8D0;
  --gris-400: #9AA096;
  --gris-700: #444B40;
  --gris-900: #1C2019;
  --sombra-sm: 0 1px 3px rgba(0,0,0,0.08);
  --sombra: 0 4px 12px rgba(0,0,0,0.10);
  --sombra-lg: 0 8px 32px rgba(0,0,0,0.14);
  --radio: 10px;
  --radio-lg: 16px;
  --trans: 0.18s ease;
}

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

body {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--gris-900);
  background: var(--gris-50);
  min-height: 100vh;
}

/* ── TIPOGRAFÍA ─────────────────────────────────── */
h1, h2, h3, h4, .font-display { font-family: 'Exo 2', sans-serif; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { line-height: 1.6; }

/* ── LAYOUT ─────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}
.topbar {
  grid-column: 1 / -1;
  background: var(--verde-oscuro);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 60px;
  box-shadow: var(--sombra);
  position: sticky; top: 0; z-index: 100;
}
.topbar-logo {
  display: flex; align-items: center; gap: 10px;
}
.topbar-logo .badge {
  background: var(--naranja);
  color: #fff;
  font-family: 'Exo 2', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}
.topbar h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; color: var(--verde-200);
}
.topbar-user strong { color: #fff; }
.topbar-user .rol-badge {
  background: var(--naranja);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── SIDEBAR ────────────────────────────────────── */
.sidebar {
  background: var(--verde);
  color: #fff;
  padding: 20px 0;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 60px);
}
.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--verde-200);
  padding: 16px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all var(--trans);
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-left-color: var(--naranja);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }

/* ── CONTENIDO PRINCIPAL ────────────────────────── */
.main-content {
  padding: 28px 32px;
  overflow-y: auto;
}
.page { display: none; }
.page.active { display: block; }

/* ── CARDS ──────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-sm);
  padding: 24px;
  border: 1px solid var(--gris-100);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.card-header h2 { color: var(--gris-900); }

/* ── ESTADÍSTICAS DASHBOARD ─────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radio-lg);
  padding: 20px 22px;
  border: 1px solid var(--gris-100);
  box-shadow: var(--sombra-sm);
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--verde);
}
.stat-card.naranja::before { background: var(--naranja); }
.stat-card .num {
  font-family: 'Exo 2', sans-serif;
  font-size: 2rem; font-weight: 700;
  color: var(--verde);
  line-height: 1;
}
.stat-card.naranja .num { color: var(--naranja); }
.stat-card .label { font-size: 0.82rem; color: var(--gris-400); }

/* ── BOTONES ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 0.88rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--trans);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: var(--verde);
  color: #fff;
}
.btn-primary:hover { background: var(--verde-claro); box-shadow: 0 3px 10px rgba(0,107,60,0.25); }
.btn-naranja {
  background: var(--naranja);
  color: #fff;
}
.btn-naranja:hover { background: var(--naranja-claro); box-shadow: 0 3px 10px rgba(244,121,32,0.25); }
.btn-outline {
  background: transparent;
  color: var(--verde);
  border: 1.5px solid var(--verde);
}
.btn-outline:hover { background: var(--verde-100); }
.btn-ghost {
  background: transparent;
  color: var(--gris-400);
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--gris-100); color: var(--gris-700); }
.btn-danger {
  background: #E74C3C; color: #fff;
}
.btn-danger:hover { background: #C0392B; }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }
.btn svg { width: 16px; height: 16px; }

/* ── FORMULARIOS ────────────────────────────────── */
.form-grid { display: grid; gap: 16px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
  font-size: 0.82rem; font-weight: 600;
  color: var(--gris-700);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--gris-200);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--gris-900);
  background: #fff;
  transition: border-color var(--trans);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--verde);
  box-shadow: 0 0 0 3px rgba(0,107,60,0.10);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── TABLAS ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.88rem;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gris-400);
  border-bottom: 2px solid var(--gris-100);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--gris-100); transition: background var(--trans); }
tbody tr:hover { background: var(--gris-50); }
tbody td { padding: 11px 14px; color: var(--gris-700); vertical-align: middle; }

/* ── BADGES ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-verde { background: var(--verde-100); color: var(--verde-oscuro); }
.badge-naranja { background: var(--naranja-100); color: var(--naranja-oscuro); }
.badge-gris { background: var(--gris-100); color: var(--gris-700); }
.badge-rojo { background: #FDECEA; color: #C0392B; }

/* ── CALENDARIO ─────────────────────────────────── */
.calendar-nav {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.calendar-nav .month-label {
  font-family: 'Exo 2', sans-serif;
  font-size: 1.05rem; font-weight: 700;
  color: var(--gris-900);
  min-width: 180px; text-align: center;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-grid .day-name {
  text-align: center; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gris-400); padding: 6px 0;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  transition: all var(--trans);
  border: 1.5px solid transparent;
  position: relative;
}
.cal-day:empty { cursor: default; }
.cal-day:not(:empty):hover { background: var(--verde-100); color: var(--verde); }
.cal-day.today { border-color: var(--naranja); color: var(--naranja-oscuro); font-weight: 700; }
.cal-day.selected { background: var(--verde); color: #fff !important; }
.cal-day.has-reservas::after {
  content: '';
  position: absolute; bottom: 4px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--naranja);
}
.cal-day.otro-mes { color: var(--gris-200); }

/* ── HORARIO (TIMESLOTS) ─────────────────────────── */
.timeslot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.timeslot {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid var(--gris-200);
  text-align: center;
  cursor: pointer;
  transition: all var(--trans);
  font-size: 0.82rem; font-weight: 600;
  color: var(--gris-700);
  background: #fff;
}
.timeslot:hover { border-color: var(--verde); color: var(--verde); background: var(--verde-100); }
.timeslot.selected { background: var(--verde); color: #fff; border-color: var(--verde); }
.timeslot.ocupado { background: var(--gris-100); color: var(--gris-400); cursor: not-allowed; border-color: var(--gris-100); text-decoration: line-through; }
.timeslot.ocupado:hover { border-color: var(--gris-100); color: var(--gris-400); background: var(--gris-100); }

/* ── MODAL ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff;
  border-radius: var(--radio-lg);
  padding: 28px;
  width: 100%; max-width: 480px;
  box-shadow: var(--sombra-lg);
  transform: translateY(-12px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px; padding-top: 16px;
  border-top: 1px solid var(--gris-100);
}

/* ── LOGIN ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--verde-oscuro) 0%, var(--verde) 50%, var(--verde-claro) 100%);
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: var(--radio-lg);
  padding: 40px 36px;
  width: 100%; max-width: 400px;
  box-shadow: var(--sombra-lg);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: var(--verde);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
}
.login-logo h2 { color: var(--verde); margin-bottom: 4px; }
.login-logo p { font-size: 0.85rem; color: var(--gris-400); }

/* ── ALERTAS ─────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 8px;
}
.alert-error { background: #FDECEA; color: #C0392B; border-left: 3px solid #E74C3C; }
.alert-success { background: var(--verde-100); color: var(--verde-oscuro); border-left: 3px solid var(--verde); }
.alert-info { background: var(--naranja-100); color: var(--naranja-oscuro); border-left: 3px solid var(--naranja); }
.alert:empty { display: none; }

/* ── TABS ────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gris-100); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 18px;
  font-size: 0.88rem; font-weight: 600;
  color: var(--gris-400);
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--trans);
}
.tab-btn:hover { color: var(--verde); }
.tab-btn.active { color: var(--verde); border-bottom-color: var(--verde); }

/* ── TOAST ───────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  background: var(--gris-900);
  color: #fff;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 0.88rem; font-weight: 500;
  box-shadow: var(--sombra-lg);
  display: flex; align-items: center; gap: 8px;
  animation: slideIn 0.25s ease;
  max-width: 320px;
}
.toast.success { border-left: 4px solid var(--verde-claro); }
.toast.error { border-left: 4px solid #E74C3C; }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } }

/* ── RECURSO CARD ────────────────────────────────── */
.recurso-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.recurso-card {
  background: #fff;
  border: 1.5px solid var(--gris-100);
  border-radius: var(--radio-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--trans);
  position: relative;
}
.recurso-card:hover { border-color: var(--verde); box-shadow: 0 4px 16px rgba(0,107,60,0.12); }
.recurso-card.selected { border-color: var(--verde); background: var(--verde-100); }
.recurso-card .tipo-badge {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--gris-400); margin-bottom: 4px;
}
.recurso-card h3 { font-size: 0.95rem; color: var(--gris-900); margin-bottom: 4px; }
.recurso-card .desc { font-size: 0.8rem; color: var(--gris-400); }
.tipo-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 5px;
}
.tipo-laboratorio { background: var(--verde); }
.tipo-taller { background: var(--naranja); }
.tipo-monitor { background: #3498DB; }
.tipo-otro { background: #9B59B6; }

/* ── BOTÓN HAMBURGUESA ───────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px; height: 36px;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  border: none;
  flex-shrink: 0;
}
.hamburger span {
  display: block;
  width: 100%; height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: all 0.25s ease;
  transform-origin: center;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── OVERLAY MÓVIL ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 149;
}
.sidebar-overlay.open { display: block; }

/* ── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  /* Hamburguesa visible en móvil */
  .hamburger { display: flex; }

  /* Sidebar como drawer lateral deslizable */
  .sidebar {
    position: fixed;
    top: 60px; left: 0;
    width: 260px;
    height: calc(100vh - 60px);
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { padding: 16px; }
  .form-grid-2 { grid-template-columns: 1fr; }

  /* Topbar compacta */
  .topbar h1 { font-size: 0.88rem; }
  .topbar-user { gap: 6px; font-size: 0.8rem; }
  .topbar-user > span:first-child { display: none; }

  /* Stats en 2 columnas */
  .stats-grid { grid-template-columns: 1fr 1fr; }

  /* Timeslots más compactos */
  .timeslot-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }

  /* Recurso cards en columna */
  .recurso-cards { grid-template-columns: 1fr; }

  /* Tabla con scroll horizontal */
  .table-wrap { overflow-x: auto; }
  table { min-width: 520px; }
}
