/* =========================================================
   IEM San Andrés — Shell de navegación (revamp Opción B)
   Header slim + offcanvas agrupado + hub por secciones
   ========================================================= */

:root {
  --iem-navy: #0a2540;
  --iem-navy-soft: #123052;
  --iem-cyan: #00a8e8;
  --iem-cyan-soft: #e6f7fc;
  --iem-bg: #f0f4f8;
  --iem-surface: #ffffff;
  --iem-text: #1a2332;
  --iem-muted: #5c6b7a;
  --iem-border: #e2e8f0;
  --iem-amber: #f2a53c;
  --iem-amber-soft: #fdf1df;
  --iem-header-h: 64px;
  --iem-accent-h: 2px;
  --primary-color: #0d6efd;
  --secondary-color: #6c757d;
  --success-color: #198754;
  --info-color: #0dcaf0;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --light-color: #f8f9fa;
  --dark-color: #212529;
  --iem-blue: #00a8e8;
  --iem-light-blue: #87ceeb;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  background-color: var(--iem-bg) !important;
  margin: 0 !important;
  padding-top: calc(var(--iem-header-h) + var(--iem-accent-h) + env(safe-area-inset-top, 0px)) !important;
  color: var(--iem-text);
}

html {
  scroll-behavior: smooth;
}

/* ---------- Header slim ---------- */
.main-header {
  background: var(--iem-navy) !important;
  box-shadow: none !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1030 !important;
  height: calc(var(--iem-header-h) + env(safe-area-inset-top, 0px)) !important;
  padding-top: env(safe-area-inset-top, 0px);
  border-bottom: none !important;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 1.25rem;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}

.btn-menu {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font-size: 1rem;
  transition: background 0.15s ease, border-color 0.15s ease;
  z-index: 1032;
  line-height: 1;
}

.btn-menu:hover,
.btn-menu:focus {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(0, 168, 232, 0.5);
  box-shadow: none;
}

.emblema-centro {
  position: absolute !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  display: flex !important;
  align-items: center !important;
  gap: 0.65rem !important;
  text-decoration: none !important;
  color: inherit !important;
  z-index: 1031 !important;
}

.emblema-centro img {
  height: 40px;
  width: auto;
  border-radius: 8px;
  transition: transform 0.15s ease;
  box-shadow: none;
  filter: none;
}

.emblema-centro:hover img {
  transform: scale(1.04);
  box-shadow: none;
}

.emblema-centro .titulo-escuela {
  color: #fff !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  margin: 0 !important;
  text-shadow: none !important;
  letter-spacing: 0.01em;
  white-space: nowrap !important;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  z-index: 1032;
}

.user-name {
  margin-right: 0.25rem;
  font-weight: 500;
  font-size: 0.9rem;
  text-shadow: none;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-logout:hover {
  background: rgba(220, 53, 69, 0.25);
  border-color: rgba(220, 53, 69, 0.45);
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* Botón primario del shell (login / CTAs) */
.iem-btn-primary {
  background: var(--iem-cyan) !important;
  border-color: var(--iem-cyan) !important;
  color: #fff !important;
}
.iem-btn-primary:hover,
.iem-btn-primary:focus {
  background: #0090c8 !important;
  border-color: #0090c8 !important;
  color: #fff !important;
}

/* Línea cian estática (reemplaza listón LED) */
.liston-led {
  position: fixed !important;
  top: calc(var(--iem-header-h) + env(safe-area-inset-top, 0px)) !important;
  left: 0 !important;
  right: 0 !important;
  height: var(--iem-accent-h) !important;
  background: var(--iem-cyan) !important;
  background-size: auto !important;
  z-index: 1029 !important;
  animation: none !important;
  box-shadow: none !important;
}

.main-content {
  padding: 0;
  background: transparent;
}

/* ---------- Offcanvas nav ---------- */
.iem-nav-offcanvas {
  --bs-offcanvas-width: min(340px, 92vw);
  border-right: 1px solid var(--iem-border);
}

.iem-nav-offcanvas .offcanvas-header {
  background: var(--iem-navy);
  color: #fff;
  padding: 1rem 1.1rem;
}

.iem-nav-offcanvas .offcanvas-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.iem-nav-offcanvas .btn-close {
  filter: invert(1) grayscale(100%);
  opacity: 0.85;
}

.iem-nav-search {
  padding: 0.85rem 1rem 0.5rem;
  border-bottom: 1px solid var(--iem-border);
  background: var(--iem-surface);
}

.iem-nav-search .form-control {
  border-radius: 10px;
  border-color: var(--iem-border);
  font-size: 0.9rem;
}

.iem-nav-search .form-control:focus {
  border-color: var(--iem-cyan);
  box-shadow: 0 0 0 0.2rem rgba(0, 168, 232, 0.15);
}

.iem-nav-body {
  padding: 0.5rem 0 1rem;
  overflow-y: auto;
}

.iem-nav-group {
  padding: 0.35rem 0;
}

.iem-nav-group-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--iem-muted);
}

.iem-nav-group-title i {
  color: var(--iem-cyan);
  font-size: 0.85rem;
}

.iem-nav-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 1.1rem;
  color: var(--iem-text);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.iem-nav-link:hover {
  background: var(--iem-cyan-soft);
  color: var(--iem-navy);
  border-left-color: var(--iem-cyan);
}

.iem-nav-link i {
  width: 1.15rem;
  text-align: center;
  flex-shrink: 0;
}

.iem-nav-empty {
  padding: 1.5rem 1.1rem;
  color: var(--iem-muted);
  text-align: center;
  font-size: 0.9rem;
}

.iem-nav-footer {
  border-top: 1px solid var(--iem-border);
  padding: 0.85rem 1.1rem;
  font-size: 0.8rem;
  color: var(--iem-muted);
}

/* ---------- Hub (menu.php) ---------- */
.iem-hub {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2.5rem;
}

.iem-hub-hero {
  margin-bottom: 1.5rem;
}

.iem-hub-hero h1 {
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--iem-navy);
  margin: 0 0 0.25rem;
}

.iem-hub-hero p {
  margin: 0;
  color: var(--iem-muted);
  font-size: 0.95rem;
}

.iem-hub-search {
  max-width: 420px;
  margin: 0 0 1.75rem;
}

.iem-hub-search .input-group-text,
.iem-hub-search .form-control {
  border-color: var(--iem-border);
  background: var(--iem-surface);
}

.iem-hub-search .form-control:focus {
  border-color: var(--iem-cyan);
  box-shadow: 0 0 0 0.2rem rgba(0, 168, 232, 0.12);
}

.iem-hub-section {
  margin-bottom: 1.75rem;
}

.iem-hub-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--iem-border);
}

.iem-hub-section-header i {
  color: var(--iem-cyan);
  font-size: 1rem;
}

.iem-hub-section-header h2 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--iem-muted);
  margin: 0;
}

.iem-hub-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

@media (min-width: 576px) {
  .iem-hub-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 992px) {
  .iem-hub-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.iem-hub-tile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  background: var(--iem-surface);
  border: 1px solid var(--iem-border);
  border-radius: 12px;
  text-decoration: none !important;
  color: var(--iem-text) !important;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  min-height: 64px;
}

.iem-hub-tile:hover {
  border-color: var(--iem-cyan);
  background: #f8fcfe;
  transform: translateY(-1px);
  color: var(--iem-navy) !important;
}

.iem-hub-tile-icon {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--iem-cyan-soft);
}

.iem-hub-tile-icon i {
  font-size: 1.15rem;
}

.iem-hub-tile-label {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}

.iem-hub-no-results {
  display: none;
  text-align: center;
  padding: 2rem 1rem;
  color: var(--iem-muted);
}

/* ---------- Compat: breadcrumb / cards globales del shell ---------- */
.breadcrumb {
  background: white;
  border-radius: 10px;
  padding: 12px 20px;
  margin-bottom: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .breadcrumb {
  background: var(--iem-surface);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  font-weight: 600;
  color: var(--secondary-color);
}

.card {
  border: none;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.card-header:not(.bg-primary):not(.bg-secondary):not(.bg-success):not(.bg-danger):not(.bg-warning):not(.bg-info):not(.bg-light):not(.bg-dark) {
  background: #f8f9fa;
}

.card-header {
  border-bottom: 1px solid #dee2e6;
  border-radius: 12px 12px 0 0 !important;
  padding: 16px 20px;
}

.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-info { color: var(--info-color) !important; }
.text-secondary { color: var(--secondary-color) !important; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .user-name {
    display: none;
  }

  .emblema-centro .titulo-escuela {
    font-size: 0.82rem !important;
  }

  .emblema-centro img {
    height: 34px;
  }

  .header-content {
    padding: 0 0.75rem;
  }

  .iem-hub-hero h1 {
    font-size: 1.3rem;
  }
}

/* ---------- Dark mode (acotado a [data-bs-theme="dark"], NO fuga a :root ni a legacy) ---------- */
[data-bs-theme="light"] { color-scheme: light; }
[data-bs-theme="dark"] {
  color-scheme: dark;
  --iem-bg: #12161c;
  --iem-surface: #1c222b;
  --iem-text: #f1f3f5;
  --iem-muted: #a0aab4;
  --iem-border: rgba(255, 255, 255, 0.12);
  --iem-cyan-soft: rgba(0, 168, 232, 0.15);
}
[data-bs-theme="dark"] .iem-hub-hero h1 { color: #f1f3f5; }
[data-bs-theme="dark"] .iem-hub-tile:hover { background: #232a34; }
[data-bs-theme="dark"] .iem-nav-offcanvas { background: var(--iem-surface); color: var(--iem-text); }
[data-bs-theme="dark"] .iem-nav-search { background: var(--iem-surface); }
[data-bs-theme="dark"] .iem-nav-search .form-control { background: #151a21; color: #fff; }
[data-bs-theme="dark"] .iem-home-personal-tile:hover { background: #232a34; }
/* Color "dark" del menú (FullBackup, Dashboard Email, etc.): ilegible sobre fondo oscuro */
[data-bs-theme="dark"] .iem-hub-tile-icon .text-dark,
[data-bs-theme="dark"] .iem-home-tile-icon .text-dark,
[data-bs-theme="dark"] .iem-home-action-icon .text-dark,
[data-bs-theme="dark"] .iem-nav-link .text-dark,
[data-bs-theme="dark"] .iem-nav-group-title .text-dark {
  color: #ced4da !important;
}

/* =========================================================
   Home adaptativa — perfil PERSONAL (alumno)
   ========================================================= */
.iem-home-hero-personal {
  background: linear-gradient(135deg, var(--iem-navy) 0%, #123a5c 100%);
  color: #fff;
  border-radius: 16px;
  padding: 1.5rem 1.6rem;
  margin-bottom: 1.5rem;
}
.iem-home-hero-personal h1 {
  margin: 0 0 .2rem;
  font-size: 1.55rem;
  font-weight: 700;
  color: #fff;
}
.iem-home-hero-personal p {
  margin: 0;
  color: #a9c6e2;
  font-size: .95rem;
}
.iem-home-personal-grid {
  display: grid;
  gap: .7rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 576px) {
  .iem-home-personal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 992px) {
  .iem-home-personal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.iem-home-personal-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .6rem;
  padding: 1.2rem .9rem;
  min-height: 120px;
  background: var(--iem-surface);
  border: 1px solid var(--iem-border);
  border-radius: 14px;
  text-decoration: none !important;
  color: var(--iem-text) !important;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}
.iem-home-personal-tile:hover {
  border-color: var(--iem-cyan);
  background: #f8fcfe;
  transform: translateY(-2px);
  color: var(--iem-navy) !important;
}
.iem-home-personal-tile .iem-home-tile-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--iem-cyan-soft);
  font-size: 1.5rem;
}
.iem-home-personal-tile .iem-home-tile-label {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0;
}
/* =========================================================
   Home adaptativa — perfil DOCENTE (accesos del día)
   ========================================================= */
.iem-home-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .8rem;
  margin-bottom: 1.5rem;
}
.iem-home-actions-single { grid-template-columns: minmax(0, 480px); }
@media (max-width: 560px) {
  .iem-home-actions { grid-template-columns: 1fr; }
}
.iem-home-action {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  text-decoration: none !important;
  color: #fff !important;
  box-shadow: 0 1px 2px rgba(10, 37, 64, .08);
  transition: transform .12s ease;
}
.iem-home-action:hover {
  transform: translateY(-2px);
  color: #fff !important;
}
.iem-home-action-primary { background: linear-gradient(135deg, var(--iem-cyan), #0077b6); }
.iem-home-action-warm { background: linear-gradient(135deg, #e88b2a, var(--iem-amber)); }
.iem-home-action-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.iem-home-action-label {
  font-size: 1rem;
  font-weight: 600;
}

/* =========================================================
   Bottom-nav (solo celular)
   ========================================================= */
.iem-bottomnav { display: none; }

.iem-bottomnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .15rem;
  background: none;
  border: none;
  color: var(--iem-muted);
  font-size: .66rem;
  font-weight: 600;
  text-decoration: none;
  padding: .3rem 0;
  cursor: pointer;
}
.iem-bottomnav-item i { font-size: 1.15rem; }
.iem-bottomnav-item:hover,
.iem-bottomnav-item:focus { color: var(--iem-cyan); }

@media (max-width: 768px) {
  .iem-bottomnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1035;
    background: var(--iem-surface);
    border-top: 1px solid var(--iem-border);
    padding: .3rem .25rem;
    padding-bottom: calc(.3rem + env(safe-area-inset-bottom, 0px));
  }
  body {
    padding-bottom: 68px !important;
  }
}
