/* ══════════════════════════════════════════════════════════════
   ASISTENCIAS IESTP NASCA — PWA Mobile-First
   ══════════════════════════════════════════════════════════════ */

:root {
  --primary: #185FA5;
  --primary-light: #E6F1FB;
  --primary-dark: #0D4A80;
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --text: #1A1A18;
  --text-secondary: #6B6B67;
  --border: #E0DFDB;
  --green: #3B6D11;
  --red: #A32D2D;
  --amber: #854F0B;

  /* Estados */
  --estado-a-bg: #E8F5E9;  --estado-a-text: #2E7D32;
  --estado-i-bg: #FFEBEE;  --estado-i-text: #C62828;
  --estado-mi-bg: #FFF8E1; --estado-mi-text: #F57F17;
  --estado-j-bg: #E3F2FD;  --estado-j-text: #1565C0;
  --estado-f-bg: #EDE7F6;  --estado-f-text: #4527A0;
  --estado-nl-bg: #FFF3E0; --estado-nl-text: #E65100;
  --estado-d-bg: #F5F5F5;  --estado-d-text: #9E9E9E;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ── HEADER ─────────────────────────────────────────────── */
.app-header {
  background: var(--primary);
  color: white;
  padding: 16px 20px;
  padding-top: max(16px, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
}

.app-header .subtitle {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 2px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
}

/* ── LOGIN ──────────────────────────────────────────────── */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-logo {
  width: 80px;
  height: 80px;
  background: white;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-lg);
}

.login-logo svg {
  width: 48px;
  height: 48px;
  fill: var(--primary);
}

.login-title {
  color: white;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  text-align: center;
}

.login-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  margin-bottom: 32px;
  text-align: center;
}

.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
}

.form-input::placeholder {
  color: #BBBBB8;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-install {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 2px solid rgba(255,255,255,0.3);
  margin-top: 16px;
  padding: 12px;
  font-size: 14px;
}

.btn-install:active {
  background: rgba(255,255,255,0.25);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.login-help {
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  text-align: center;
  margin-top: 24px;
  line-height: 1.4;
}

.error-msg {
  background: var(--estado-i-bg);
  color: var(--estado-i-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.error-msg.show {
  display: block;
}

/* ── CAMBIO DE CLAVE ─────────────────────────────────────── */
.change-pw-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.change-pw-card {
  background: white;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow);
}

.change-pw-card h2 {
  font-size: 20px;
  margin-bottom: 8px;
  color: var(--text);
}

.change-pw-card .info {
  background: var(--estado-j-bg);
  color: var(--estado-j-text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.4;
}

/* ── CONTENIDO PRINCIPAL ─────────────────────────────────── */
.page-content {
  padding: 16px;
  padding-bottom: 80px;
}

/* ── SELECTOR DE MES ─────────────────────────────────────── */
.mes-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.mes-selector button {
  background: var(--primary-light);
  border: none;
  color: var(--primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mes-selector button:active {
  background: var(--primary);
  color: white;
}

.mes-selector .mes-label {
  font-size: 16px;
  font-weight: 600;
  min-width: 160px;
  text-align: center;
}

/* ── TARJETAS RESUMEN ────────────────────────────────────── */
.resumen-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.resumen-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.resumen-card .numero {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}

.resumen-card .etiqueta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ── LISTA DE DIAS ───────────────────────────────────────── */
.dias-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dia-item {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
  gap: 12px;
}

.dia-item:active {
  transform: scale(0.98);
}

.dia-item.inactivo {
  opacity: 0.5;
}

.dia-item.especial,
.dia-item.fin-semana {
  background: #FAFAF8;
}

.dia-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}

.dia-num .dia-nombre {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  opacity: 0.7;
}

.dia-info {
  flex: 1;
  min-width: 0;
}

.dia-info .hora-line {
  font-size: 14px;
  color: var(--text);
}

.dia-info .marcas-line {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.dia-horas {
  text-align: right;
  flex-shrink: 0;
}

.dia-horas .horas-val {
  font-size: 15px;
  font-weight: 600;
}

.dia-horas .horas-label {
  font-size: 10px;
  color: var(--text-secondary);
}

/* ── BADGES DE ESTADO ────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  min-width: 32px;
  flex-shrink: 0;
}

.badge-A   { background: var(--estado-a-bg);  color: var(--estado-a-text); }
.badge-I   { background: var(--estado-i-bg);  color: var(--estado-i-text); }
.badge-MI  { background: var(--estado-mi-bg); color: var(--estado-mi-text); }
.badge-J   { background: var(--estado-j-bg);  color: var(--estado-j-text); }
.badge-F   { background: var(--estado-f-bg);  color: var(--estado-f-text); }
.badge-NL  { background: var(--estado-nl-bg); color: var(--estado-nl-text); }
.badge-D   { background: var(--estado-d-bg);  color: var(--estado-d-text); }

.badge-pendiente   { background: var(--estado-mi-bg); color: var(--estado-mi-text); }
.badge-justificada { background: var(--estado-j-bg);  color: var(--estado-j-text); }
.badge-notificar   { background: var(--estado-i-bg);  color: var(--estado-i-text); }

/* ── MODAL / BOTTOM SHEET ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 8px 20px 32px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.modal-overlay.show .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 40px;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  margin: 8px auto 16px;
}

.modal-sheet h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h4 {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.marca-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.marca-item:last-child { border-bottom: none; }

.marca-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.marca-dot.entrada { background: var(--green); }
.marca-dot.salida  { background: var(--red); }

.marca-hora {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.marca-tipo {
  font-size: 13px;
  color: var(--text-secondary);
}

.horas-summary {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.horas-summary div {
  text-align: center;
}

.horas-summary .val {
  font-size: 20px;
  font-weight: 700;
}

.horas-summary .lbl {
  font-size: 11px;
  color: var(--text-secondary);
}

.inc-detail {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
}

/* ── INCONSISTENCIAS ─────────────────────────────────────── */
.inc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inc-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.inc-item .inc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.inc-item .inc-fecha {
  font-weight: 600;
  font-size: 14px;
}

.inc-item .inc-tipo {
  font-size: 13px;
  color: var(--text-secondary);
}

.inc-item .inc-just {
  font-size: 13px;
  color: var(--estado-j-text);
  background: var(--estado-j-bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* ── PERFIL ──────────────────────────────────────────────── */
.perfil-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.perfil-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin: 0 auto 12px;
}

.perfil-card .nombre {
  font-size: 18px;
  font-weight: 700;
}

.perfil-card .cargo {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.menu-list {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.menu-item {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 14px;
  font-size: 15px;
  transition: background 0.15s;
}

.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg); }

.menu-item .icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}

.menu-item .arrow {
  margin-left: auto;
  color: var(--text-secondary);
}

.menu-item.danger { color: var(--red); }

/* ── BOTTOM NAV ──────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  gap: 4px;
  transition: color 0.15s;
  border: none;
  background: none;
}

.nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
}

.nav-item.active {
  color: var(--primary);
}

/* ── LOADING ─────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}

.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* ── SWITCH / TOGGLE ─────────────────────────────────────── */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 28px;
  margin-left: auto;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: var(--shadow);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ── UTILITIES ───────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
