/* ── Variables Terrano ─────────────────────────────────────────── */
:root {
  --amarillo:   #FFD60A;
  --amarillo-d: #E6BE00;
  --gris-bg:    #F4F4F2;
  --gris-card:  #FFFFFF;
  --texto:      #1A1A1A;
  --tenue:      #6B6B6B;
  --rojo:       #D7263D;
  --verde:      #2A9D3F;
  --aviso-bg:   #FFF4C2;
  --aviso-bd:   #E6BE00;
  --sombra:     0 2px 8px rgba(0,0,0,0.08);

  --sidebar-w:  220px;
  --header-h:   64px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--gris-bg); color: var(--texto); }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
a { text-decoration: none; color: inherit; }

/* ── Layout app ─────────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* Header superior fijo */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--amarillo); z-index: 200;
  display: flex; align-items: center; padding: 0 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,.10);
}
.app-header img { height: 50px; display: block; }
.app-header-title {
  font-size: 1.25rem; font-weight: 700; color: #000000;
  margin-left: 32px; line-height: var(--header-h); white-space: nowrap;
  letter-spacing: .01em;
}

/* Sidebar — tema claro */
.sidebar {
  width: var(--sidebar-w);
  background: #ffffff;
  border-right: 1px solid #e8e8e8;
  display: flex; flex-direction: column;
  position: fixed; top: var(--header-h); left: 0;
  height: calc(100vh - var(--header-h));
  z-index: 100; overflow-y: auto;
}

.nav-links { padding: 6px 0; flex: 1; }
.nav-links a {
  display: flex; align-items: center;
  padding: 12px 20px;
  color: #374151; font-size: .88rem; font-weight: 400;
  transition: background .12s, color .12s;
  min-height: 44px; border-radius: 0;
}
.nav-links a:hover  { background: #f5f5f3; color: #1a1a1a; }
.nav-links a.active { background: #fff8d6; color: var(--texto); font-weight: 700; }

.sidebar-footer {
  padding: 10px 12px; border-top: 1px solid #e8e8e8;
}

/* Contenido principal */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  flex: 1; display: flex; flex-direction: column;
  min-height: calc(100vh - var(--header-h));
}

/* Header amarillo sticky */
.page-header {
  background: var(--amarillo);
  padding: 14px 18px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--sombra);
  display: flex; align-items: center; justify-content: space-between;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--texto); margin: 0; }

.page-body { padding: 16px 18px; padding-bottom: 70px; flex: 1; }

/* ── Tarjetas ────────────────────────────────────────────────────── */
.card {
  background: var(--gris-card);
  border-radius: 12px;
  box-shadow: var(--sombra);
  margin-bottom: 10px;
  overflow: hidden;
}
.card .head {
  padding: 13px 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
}
.card .body {
  display: none; padding: 0 15px 14px;
  border-top: 1px solid #EEE;
}
.card.open .body { display: block; }
.card.open { box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.card.alerta { border-left: 5px solid var(--rojo); }

/* Tarjeta stat */
.stat-card {
  background: var(--gris-card);
  border-radius: 12px;
  box-shadow: var(--sombra);
  padding: 16px;
}
.stat-val   { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .78rem; color: var(--tenue); margin-top: 4px; }

/* Panel de sección */
.panel {
  background: var(--gris-card);
  border-radius: 12px;
  box-shadow: var(--sombra);
  overflow: hidden;
  margin-bottom: 14px;
}
.panel-head {
  padding: 13px 16px;
  border-bottom: 1px solid #EEE;
  font-weight: 700; font-size: .92rem;
  display: flex; align-items: center; justify-content: space-between;
}

/* ── Badges de estado ──────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 3px 8px; border-radius: 6px; margin-left: 6px;
  vertical-align: middle; letter-spacing: .4px;
}
.badge-rojo   { background: var(--rojo);  color: #fff; }
.badge-verde  { background: var(--verde); color: #fff; }
.badge-gris   { background: #e5e7eb; color: #374151; }
.badge-yellow { background: var(--amarillo); color: var(--texto); }

.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: .74rem; font-weight: 700; white-space: nowrap;
}
.s-presente    { background: #d1fae5; color: #065f46; }
.s-tardanza    { background: #fef3c7; color: #92400e; }
.s-ausente     { background: #fee2e2; color: #991b1b; }
.s-no-lab      { background: #f3f4f6; color: #6b7280; }
.s-sin-horario { background: #dbeafe; color: #1e40af; }

/* ── Botones ─────────────────────────────────────────────────────── */
.btn {
  border: none; border-radius: 10px;
  padding: 11px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .15s;
}
.btn-primary { background: var(--amarillo-d); color: var(--texto); }
.btn-primary:hover { background: #c9a800; }

.btn-dark { background: var(--texto); color: var(--amarillo); }
.btn-dark:hover { background: #333; }

.btn-alerta { background: #fff; color: var(--rojo); border: 2px solid var(--rojo); }
.btn-alerta:hover { background: var(--rojo); color: #fff; }

.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 36px; border-radius: 8px; }

/* ── Inputs ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: .83rem; font-weight: 600; margin-bottom: 5px; color: var(--texto); }
.form-control, .form-select {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 2px solid #DDD; border-radius: 10px;
  background: #FAFAFA; color: var(--texto);
  transition: border .15s;
  -webkit-appearance: none; appearance: none;
}
.form-control:focus, .form-select:focus {
  outline: none; border-color: var(--amarillo-d); background: #fff;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B6B6B' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 36px;
}

/* ── Tabla simple ──────────────────────────────────────────────── */
.tabla { width: 100%; border-collapse: collapse; font-size: .86rem; }
.tabla thead th {
  background: #F8F8F6; padding: 10px 12px;
  text-align: left; font-weight: 700; color: var(--texto);
  border-bottom: 2px solid #EBEBEB; white-space: nowrap;
}
.tabla tbody tr { border-bottom: 1px solid #F0F0EE; }
.tabla tbody tr:hover { background: #FAFAF8; }
.tabla tbody td { padding: 9px 12px; vertical-align: middle; }

/* ── Avisos ──────────────────────────────────────────────────────── */
.aviso {
  background: var(--aviso-bg); border-left: 4px solid var(--aviso-bd);
  padding: 10px 12px; border-radius: 6px; font-size: 14px; margin: 10px 0;
}
.aviso-rojo {
  background: #FFE8EC; border-left: 4px solid var(--rojo);
  padding: 10px 12px; border-radius: 6px;
  font-size: 14px; margin: 10px 0; color: var(--rojo); font-weight: 600;
}

/* ── Skeleton ──────────────────────────────────────────────────── */
.skel { animation: pulse 1.2s infinite; background: #ECECEC; border-radius: 8px; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── Estado vacío ─────────────────────────────────────────────── */
.vacio { text-align: center; padding: 50px 20px; color: var(--tenue); }
.vacio .ico { font-size: 52px; margin-bottom: 10px; }

/* ── Toast ────────────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--texto); color: #fff;
  padding: 12px 20px; border-radius: 24px;
  font-size: 15px; box-shadow: 0 4px 16px rgba(0,0,0,.2);
  opacity: 0; transition: opacity .25s;
  pointer-events: none; z-index: 9999;
  max-width: 90vw; text-align: center; white-space: nowrap;
}
.toast.show { opacity: 1; }
.toast.ok   { background: var(--verde); }
.toast.err  { background: var(--rojo); }

/* ── Modal simple ─────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.6); z-index: 200;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 500px; max-height: 90vh;
  overflow-y: auto; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Modal oscuro (sidebar y páginas admin) ───────────────────── */
.modal {
  background: #1e1e2e; border-radius: 12px;
  width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  color: #e0e0e0;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.modal-header .modal-title { font-size: 1rem; font-weight: 700; color: #fff; margin: 0; }
.modal-close {
  background: none; border: none; color: #888; font-size: 1.1rem;
  cursor: pointer; padding: 4px 8px; border-radius: 6px; line-height: 1;
}
.modal-close:hover { background: rgba(255,255,255,.08); color: #fff; }
.modal-body  { padding: 20px; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08);
}
.modal .form-control {
  background: #2a2a3e; border: 1px solid rgba(255,255,255,.12);
  color: #e0e0e0;
}
.modal .form-control::placeholder { color: #666; }
.modal .form-control:focus { border-color: var(--amarillo); outline: none; }
.modal label { color: #aaa; font-size: .82rem; }

/* ── Grid helpers ─────────────────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

/* ── Misc ──────────────────────────────────────────────────────── */
.row-flex { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.text-tenue { color: var(--tenue); }
.text-rojo  { color: var(--rojo); }
.text-verde { color: var(--verde); }
.fw-bold { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-14 { margin-top: 14px; }

/* ── Login ─────────────────────────────────────────────────────── */
.login-bg { background: var(--texto); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.4); padding: 36px 32px; width: 100%; max-width: 380px; }
.login-brand { font-size: 1.5rem; font-weight: 800; color: var(--amarillo); letter-spacing: 1.5px; }

/* ── Dot de dispositivo ────────────────────────────────────────── */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 5px; }
.dot-verde { background: var(--verde); box-shadow: 0 0 5px var(--verde); }
.dot-rojo  { background: var(--rojo); }
.dot-gris  { background: #ccc; }

/* ── Días selector ─────────────────────────────────────────────── */
.dias-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.dia-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid #DDD;
  background: #FAFAFA; cursor: pointer; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.dia-btn.sel { background: var(--amarillo); border-color: var(--amarillo-d); color: var(--texto); }

/* ── Color swatch ─────────────────────────────────────────────── */
.swatch { width: 14px; height: 14px; border-radius: 50%; display: inline-block; vertical-align: middle; }

/* ── Responsive: móvil ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .app-header-title { display: none; }
}
