:root {
  --tec-bg-dark: #0a0e27;
  --tec-bg-darker: #060815;
  --tec-bg-gradient: radial-gradient(circle at 30% 20%, #131a3a 0%, #0a0e27 45%, #060815 100%);
  --tec-primary: #2f6fed;
  --tec-primary-dark: #1e4fbf;
  --tec-accent: #4dd0e1;
  --tec-card-bg: #ffffff;
  --tec-text-light: #e8ecf7;
  --tec-text-muted: #8a92b2;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--tec-bg-gradient);
  color: var(--tec-text-light);
  min-height: 100vh;
}

/* ---------- LOGIN ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(47, 111, 237, 0.45);
  overflow: hidden;
}

.login-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #fff;
}

.login-subtitle {
  color: var(--tec-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

.login-card .form-label {
  color: var(--tec-text-muted);
  font-size: 0.85rem;
  text-align: left;
  display: block;
}

.login-card .input-group-text {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--tec-text-muted);
}

.login-card .form-control {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
}

.login-card .form-control:focus {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--tec-primary);
  box-shadow: 0 0 0 0.2rem rgba(47, 111, 237, 0.25);
  color: #fff;
}

.login-card .form-control::placeholder {
  color: rgba(232, 236, 247, 0.35);
}

.validation-summary-valid {
  display: none;
}

.login-card .validation-summary-errors ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.login-btn {
  background: linear-gradient(135deg, var(--tec-primary), var(--tec-primary-dark));
  border: none;
  padding: 0.65rem;
  font-weight: 600;
  border-radius: 8px;
  margin-top: 0.5rem;
}

.login-btn:hover,
.login-btn:focus {
  background: linear-gradient(135deg, var(--tec-primary-dark), var(--tec-primary));
}

.login-footer {
  margin-top: 1.5rem;
  color: var(--tec-text-muted);
  font-size: 0.8rem;
}

/* ---------- SELECTOR DE MÓDULO ---------- */
.module-divider {
  display: flex;
  align-items: center;
  color: var(--tec-text-muted);
  font-size: 0.85rem;
  margin: 1.5rem 0 1rem;
}

.module-divider::before,
.module-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.module-divider span {
  padding: 0 0.75rem;
}

.module-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.module-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 0.875rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  text-align: left;
  color: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.module-item:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.18);
}

.module-item-selected {
  background: rgba(47, 111, 237, 0.15);
  border-color: var(--tec-primary);
}

.module-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
}

.module-icon-admin {
  background: linear-gradient(135deg, #8e6cf0, #6a4bd6);
}

.module-icon-slep {
  background: linear-gradient(135deg, var(--tec-accent), var(--tec-primary));
}

.module-icon-apoderados {
  background: linear-gradient(135deg, #35c17a, #1e8e5a);
}

.module-icon-docentes {
  background: linear-gradient(135deg, #ff9a44, #e67e22);
}

.module-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.module-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--tec-text-light);
}

.module-desc {
  font-size: 0.78rem;
  color: var(--tec-text-muted);
  margin-top: 0.1rem;
}

.module-chevron {
  color: var(--tec-text-muted);
}

.module-check {
  display: none;
  color: var(--tec-primary);
  font-size: 1.1rem;
}

.module-item-selected .module-check {
  display: inline-block;
}

.module-item-selected .module-chevron {
  display: none;
}

/* ---------- APP SHELL (sidebar + dashboard) ---------- */
.app-shell-body {
  min-height: 100vh;
  padding: 0;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar-toggle-checkbox {
  display: none;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--tec-bg-darker);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.25rem;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 40;
  transition: transform 0.2s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 2rem;
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-brand-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

.sidebar-brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav-label {
  color: var(--tec-text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.5rem 0.75rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: var(--tec-text-light);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav-item i {
  width: 20px;
  text-align: center;
  color: var(--tec-text-muted);
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.sidebar-nav-item-active {
  background: rgba(47, 111, 237, 0.18);
  color: #fff;
}

.sidebar-nav-item-active i {
  color: var(--tec-accent);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1rem;
  margin-top: 1rem;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.6rem;
}

.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--tec-primary), var(--tec-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-email {
  font-size: 0.75rem;
  color: var(--tec-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-badge {
  display: inline-block;
  background: rgba(77, 208, 225, 0.15);
  color: var(--tec-accent);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #e57373;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  transition: background 0.15s ease;
}

.sidebar-logout:hover {
  background: rgba(229, 115, 115, 0.12);
  color: #e57373;
}

.sidebar-backdrop {
  display: none;
}

.app-main {
  flex: 1;
  margin-left: 260px;
  padding: 1.75rem 2rem 2.5rem;
  min-width: 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.sidebar-open-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.app-topbar-titles {
  flex: 1;
  min-width: 0;
}

.app-topbar-titles h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.app-topbar-titles p {
  color: var(--tec-text-muted);
  font-size: 0.85rem;
  margin: 0.15rem 0 0;
}

.app-topbar-date {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--tec-text-light);
  font-size: 0.82rem;
  padding: 0.5rem 0.9rem;
  border-radius: 10px;
  white-space: nowrap;
}

.app-topbar-date i {
  color: var(--tec-accent);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  color: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  margin-bottom: 0.85rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.8rem;
  opacity: 0.9;
  margin-top: 0.2rem;
}

.stat-blue   { background: linear-gradient(135deg, var(--tec-accent), var(--tec-primary)); }
.stat-teal   { background: linear-gradient(135deg, #35c17a, #1e8e5a); }
.stat-purple { background: linear-gradient(135deg, #8e6cf0, #6a4bd6); }
.stat-orange { background: linear-gradient(135deg, #ff9a44, #e67e22); }

.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.1rem;
}

.chart-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 1.25rem 1.4rem 1.5rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.chart-card-header {
  margin-bottom: 1rem;
}

.chart-card-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.chart-card-subtitle {
  font-size: 0.78rem;
  color: var(--tec-text-muted);
}

.chart-card-body {
  position: relative;
  height: 260px;
}

.app-version-footer {
  text-align: center;
  color: var(--tec-text-muted);
  font-size: 0.8rem;
  margin-top: 2rem;
}

@media (max-width: 991px) {
  .app-sidebar {
    transform: translateX(-100%);
  }

  .sidebar-toggle-checkbox:checked ~ .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle-checkbox:checked ~ .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 30;
  }

  .app-main {
    margin-left: 0;
    padding: 1.25rem 1.1rem 2rem;
  }

  .sidebar-open-btn {
    display: flex;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .app-topbar-date {
    display: none;
  }
}

/* ---------- DASHBOARD ---------- */
.dashboard-body {
  min-height: 100vh;
  padding-bottom: 2rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #ffffff;
  color: #222;
  padding: 0.75rem 1rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.topbar-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eef1f8;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  flex-shrink: 0;
}

.topbar-email {
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  border: none;
  background: transparent;
  color: #c0392b;
  font-size: 1.1rem;
  padding: 0.25rem 0.4rem;
}

.map-area {
  position: relative;
  height: 45vh;
  min-height: 260px;
  overflow: hidden;
  background: linear-gradient(160deg, #10182e 0%, #0c1224 100%);
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-placeholder {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 40px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 40px),
    linear-gradient(160deg, #10182e 0%, #0c1224 100%);
}

.map-placeholder-text {
  color: var(--tec-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

.map-pin {
  font-size: 2.5rem;
  color: #e74c3c;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.5));
  animation: bounce 2.2s ease-in-out infinite;
}

.action-card:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 1.25rem;
}

.action-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 1.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.action-card:active {
  transform: scale(0.96);
}

.action-card:hover {
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4);
}

/* Tiles que navegan (enlace) en vez de marcar: sin subrayado ni color de link. */
.action-card--link {
  text-decoration: none;
  color: inherit;
}

/* El tile del portal queda solo en la última fila: ocupa el ancho completo. */
.action-card[data-action="portal"] {
  grid-column: 1 / -1;
}

.action-label {
  font-weight: 600;
  color: var(--tec-text-light);
  font-size: 0.95rem;
  text-align: center;
}

.action-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.icon-purple  { background: #efe6fb; color: #8e44ad; }
.icon-orange  { background: #fdecd8; color: #e67e22; }
.icon-teal    { background: #dcf3ef; color: #16a085; }
.icon-olive   { background: #eef1d6; color: #8e9c1f; }
.icon-blue    { background: #dbe9fb; color: #2f6fed; }
.icon-red     { background: #fbdede; color: #e74c3c; }
.icon-green   { background: #daf1e6; color: #1e8e5a; }

.version-footer {
  text-align: center;
  color: var(--tec-text-muted);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

/* ---------- MODALES DE MARCA ---------- */
.marca-modal {
  background: #101733;
  color: var(--tec-text-light);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
}

.marca-modal .modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.marca-modal-subtitle {
  color: var(--tec-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.resultado-icono {
  font-size: 3.25rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.resultado-icono.resultado-ok {
  color: #2ecc71;
}

.resultado-icono.resultado-error {
  color: #e74c3c;
}

.resultado-mensaje {
  color: var(--tec-text-light);
  font-size: 1rem;
  margin: 0;
}

.map-retry-btn {
  margin-top: 0.25rem;
}

/* En error de ubicación: se detiene el rebote y el pin se atenúa. */
.map-placeholder-error .map-pin {
  animation: none;
  color: var(--tec-text-muted);
}

.rostro-modal .modal-body {
  text-align: center;
}

#video-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 1rem;
  overflow: hidden;
  border-radius: 20px;
  border: 6px solid #1e8e5a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.rostro-hora {
  font-size: 2.4rem;
  font-weight: 700;
  color: #4dd0e1;
  margin: 0;
}

.rostro-fecha {
  color: var(--tec-text-muted);
  font-size: 0.85rem;
  text-transform: capitalize;
  margin-bottom: 0.75rem;
}

.rostro-user {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 0.6rem;
}

.rostro-nombre {
  font-weight: 700;
  margin: 0;
}

.rostro-rut {
  color: var(--tec-text-muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ---------- PRELOADER ---------- */
.preloader-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
}

.preloader-spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--tec-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
