/* =========================================================
   ESTILOS GLOBALES - COMEDOR Y CANTINA XÀTIVA
   (Adaptado a la identidad visual corporativa del logo)
   ========================================================= */

:root {
  --bg: #f9f7f5;
  --panel: #ffffff;
  --card: #ffffff;
  --dark: #2a1b22;         /* Tono oscuro profundo en sintonía con el granate */
  --dark-strong: #1a1015;
  --burgundy: #7a203a;     /* Granate corporativo extraído del logo */
  --burgundy-soft: #f4e8ec; /* Fondo suave para destacar elementos */
  --burgundy-deep: #5e152b;
  --accent: #7a203a;
  --accent-soft: #f4e8ec;
  --text: #2d2427;
  --muted: #6b5e63;
  --line: #e6dadf;
  --shadow: 0 14px 32px rgba(42, 27, 34, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* =========================================================
   PORTAL PRINCIPAL (INDEX) Y LOGIN - LOGO CENTRADO
   ========================================================= */

.portal-shell {
  width: min(470px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  text-align: center;
}

.login-shell {
  width: min(100%, 460px);
}

.login-box {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 22px;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 4vw, 2.7rem);
}

.login-box p {
  margin: 0 0 18px;
  color: var(--muted);
}

/* Logo principal perfectamente centrado */
.logo-card {
  background: var(--panel);
  width: 140px;
  height: 140px;
  border-radius: 28px;
  margin: 0 auto 20px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(122, 32, 58, 0.08);
  border: 1px solid var(--line);
}

.logo-card img,
.portal-logo {
  max-width: 110px;
  width: 100%;
  height: auto;
  object-fit: contain;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 1.1;
  letter-spacing: -0.05em;
  font-weight: 700;
  color: var(--dark-strong);
}

.subtitle {
  margin: 8px 0 26px;
  font-size: clamp(1.05rem, 2vw, 1.4rem);
  color: var(--muted);
  font-weight: 400;
}

/* Tarjetas de Selección de Usuario */
.users-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.user-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  min-height: 80px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.user-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(122, 32, 58, 0.12);
  border-color: var(--burgundy);
}

.admin-card {
  color: rgb(8, 8, 8);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.dark-icon {
  background: rgba(255, 255, 255, 0.12);
}

.orange-icon {
  background: var(--burgundy-soft);
  color: var(--burgundy);
}

.text-wrap {
  text-align: left;
}

.text-wrap h2 {
  margin: 0 0 2px;
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.text-wrap p {
  margin: 0;
  color: inherit;
  opacity: 0.8;
  font-size: 0.9rem;
}

.admin-card .text-wrap p {
  color: rgba(255, 255, 255, 0.8);
}

.mini-btn {
  appearance: none;
  border: 0;
  background: white;
  color: var(--dark);
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-card .mini-btn {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.mini-btn:hover {
  transform: translateY(-1px);
}
/* Estructura general del panel de administración */
.admin-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  overflow-x: hidden;
}

/* Barra lateral fija y adaptada a la altura de la pantalla */
.sidebar {
  width: 260px;
  min-width: 260px;
  background-color: var(--burgundy, #7a203a);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1000;
}

/* Contenido principal */
.admin-main {
  flex: 1;
  background-color: #f8f9fa;
  min-width: 0; /* Evita que las tablas rompan el flex */
  overflow-y: auto;
}

/* =========================================================
   LAYOUT DE ADMINISTRACIÓN Y PANELES
   ========================================================= */

body:has(.admin-layout) {
  display: block;
  padding: 0;
}

.admin-layout {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: linear-gradient(180deg, #fbf7f8 0%, #f4ecef 100%);
}

.sidebar {
  background: linear-gradient(180deg, var(--dark) 0%, var(--dark-strong) 100%);
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-dot {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--burgundy);
  color: white;
  font-weight: 800;
}

.brand-box strong,
.brand-box small {
  display: block;
}

.brand-box small {
  opacity: 0.7;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.sidebar-nav a {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.9);
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
  transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: rgba(122, 32, 58, 0.35);
  transform: translateX(2px);
}

.logout-btn {
  border: 0;
  border-radius: 10px;
  background: var(--burgundy);
  color: white;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(122, 32, 58, 0.3);
  width: 100%;
}

.admin-main {
  padding: 28px;
  background: rgba(255, 255, 255, 0.12);
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow-admin {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* =========================================================
   TARJETAS, ESTADÍSTICAS Y CONTENIDO
   ========================================================= */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 20px;
  display: grid;
  gap: 8px;
}

.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat-value {
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  letter-spacing: -0.06em;
  color: var(--dark-strong);
}

.content-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.panel-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  font-weight: 700;
}

.panel-body {
  padding: 18px 20px 22px;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
}

/* =========================================================
   MODALES Y FORMULARIOS
   ========================================================= */

.password-modal {
  position: fixed;
  inset: 0;
  background: rgba(42, 27, 34, 0.55);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 16px;
}

.password-modal.hidden {
  display: none;
}

.password-modal-card {
  background: white;
  width: min(420px, calc(100vw - 32px));
  border-radius: 18px;
  padding: 24px 20px;
  box-shadow: var(--shadow);
  text-align: center;
}

.password-modal-card h3 {
  margin-bottom: 12px;
  color: var(--dark-strong);
}

.password-modal-card p {
  margin-bottom: 18px;
  font-size: 1.05rem;
  color: var(--text);
  word-break: break-word;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfcfd;
}

.submit-btn {
  margin-top: 16px;
  width: 100%;
  background: var(--burgundy);
  color: white;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
}

/* =========================================================
   SELECTOR DE IDIOMA (I18N)
   ========================================================= */

.lang-switch-wrap {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
  width: 100%;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--dark);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.lang-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 22px;
  background: var(--burgundy);
  border-radius: 999px;
  display: inline-block;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s ease;
}

.lang-switch[aria-pressed="true"] .switch-thumb {
  transform: translateX(20px);
}

/* =========================================================
   PÁGINAS DE ROLES (PADRES, PROFESORES, COCINA)
   ========================================================= */

.role-page {
  min-height: 100vh;
  padding: 32px 18px 64px;
  background: var(--bg);
  color: var(--text);
}

.role-container {
  width: min(1100px, 100%);
  margin: 0 auto;
}

.role-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 20px;
}

.role-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.role-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--muted);
}

.role-card .value {
  font-size: clamp(1.8rem, 2.2vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--dark-strong);
}

/* =========================================================
   DISEÑO ADAPTATIVO / RESPONSIVE (MÓVILES Y TABLETS)
   ========================================================= */

@media (max-width: 980px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: unset;
    height: auto;
    padding: 18px 16px;
  }

  .sidebar-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-main {
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  body {
    padding: 16px 12px;
  }

  .stats-grid,
  .role-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar,
  .role-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .portal-shell {
    width: 100%;
  }

  .logo-card {
    width: 120px;
    height: 120px;
  }

  .user-card {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    gap: 12px;
  }

  .user-info {
    width: 100%;
  }

  .mini-btn {
    width: 100%;
  }
}
/* =========================================================
   MENÚ DE ADMINISTRACIÓN - DISEÑO MÓVIL
   ========================================================= */

@media (max-width: 720px) {

  body:has(.admin-layout) {
    padding: 0;
  }

  .admin-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }

  /* Barra superior */
  .sidebar {
    position: relative;
    top: auto;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: auto;
    padding: 12px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    border-radius: 0 0 18px 18px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  }

  /* Nombre del colegio */
  .brand-box {
    padding: 4px 2px 12px;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
  }

  .brand-dot {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 11px;
    font-size: 0.95rem;
  }

  .brand-box strong {
    font-size: 0.95rem;
  }

  .brand-box small {
    font-size: 0.72rem;
  }

  /* Menú horizontal desplazable */
  .sidebar-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0;
    padding: 2px 0 7px;
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .sidebar-nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 13px;
    border-radius: 10px;
    font-size: 0.82rem;
    background: rgba(255,255,255,0.08);
    transform: none;
  }

  .sidebar-nav a.active {
    background: var(--burgundy);
    color: white;
    box-shadow: 0 3px 9px rgba(0,0,0,0.15);
  }

  .sidebar-nav a:hover {
    transform: none;
  }

  /* Cerrar sesión */
  .logout-btn {
    width: 100%;
    padding: 10px;
    font-size: 0.85rem;
    border-radius: 10px;
    box-shadow: none;
  }

  /* Contenido */
  .admin-main {
    width: 100%;
    min-width: 0;
    padding: 18px 12px;
    overflow-x: hidden;
  }

  .admin-topbar {
    gap: 12px;
    margin-bottom: 18px;
  }
}

/* Móviles pequeños */
@media (max-width: 380px) {

  .sidebar {
    padding: 10px;
  }

  .sidebar-nav a {
    padding: 9px 11px;
    font-size: 0.77rem;
  }

  .admin-main {
    padding: 14px 10px;
  }
}