/* portal.css — Portal del Trabajador: mobile-first, dark theme */

:root {
  --bg:       #0f172a;
  --bg-card:  #1e293b;
  --bg-input: #0f172a;
  --border:   #334155;
  --text:     #f1f5f9;
  --muted:    #94a3b8;
  --primary:  #3b82f6;
  --primary-h:#2563eb;
  --success:  #22c55e;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --nav-h:    60px;
  --hdr-h:    56px;
  --radius:   12px;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ────────────────────────────────────────────── */

.portal-body {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 16px;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
  font-size: 0.9rem;
}

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  color: #fca5a5;
  padding: 10px 14px;
  font-size: 0.875rem;
  margin-bottom: 12px;
}

.login-help {
  color: var(--muted);
  text-align: center;
  font-size: 0.8rem;
  margin-top: 20px;
}

/* ── Formulario ───────────────────────────────────────── */

.field-group {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-input {
  display: block;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 12px 14px;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.field-input::placeholder { color: var(--muted); }

.field-input--sm { padding: 9px 12px; font-size: 0.9rem; }

.field-inline { display: flex; align-items: center; gap: 10px; margin-bottom: 0; }
.field-inline .field-label { margin-bottom: 0; white-space: nowrap; }
.field-inline .field-input { flex: 1; }

.field-row { display: flex; gap: 12px; }
.field-row .field-group { flex: 1; }

textarea.field-input { resize: vertical; min-height: 80px; }

/* ── Botones ──────────────────────────────────────────── */

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 13px 20px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}

.btn-secondary:hover { background: rgba(59,130,246,0.08); }

.btn-full { width: 100%; }

.btn-sm { padding: 7px 14px; font-size: 0.85rem; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.btn-icon:hover { color: var(--text); background: rgba(255,255,255,0.05); }

/* ── Layout app ───────────────────────────────────────── */

.portal-app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.portal-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--hdr-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.header-info {
  display: flex;
  flex-direction: column;
}

.header-empresa {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1;
}

.header-nombre {
  font-size: 0.95rem;
  font-weight: 600;
}

.header-page-title {
  font-size: 1rem;
  font-weight: 600;
}

.portal-main {
  margin-top: var(--hdr-h);
  margin-bottom: var(--nav-h);
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

.portal-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 500;
  transition: color 0.15s;
}

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

/* ── Secciones dashboard ──────────────────────────────── */

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

.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 10px;
}

/* Estado card */
.estado-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.estado-badge {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.estado-badge--cumplido           { background: var(--success); }
.estado-badge--ausente            { background: var(--danger); }
.estado-badge--tardanza           { background: var(--warning); }
.estado-badge--salida_temprana    { background: var(--warning); }
.estado-badge--tardanza_y_salida  { background: #f97316; }
.estado-badge--libre              { background: var(--muted); }

.estado-label {
  font-size: 0.95rem;
  font-weight: 500;
}

/* Jornada info */
.jornada-info {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.jornada-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.jornada-nombre  { font-weight: 600; font-size: 0.95rem; }
.jornada-horario { color: var(--primary); font-weight: 500; font-size: 0.9rem; }
.jornada-dias    { color: var(--muted); font-size: 0.8rem; }

/* Marcaciones list */
.marcs-list { display: flex; flex-direction: column; gap: 8px; }

.marc-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.marc-tipo {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.marc-tipo--entrada { color: var(--success); }
.marc-tipo--salida  { color: var(--warning); }

.marc-hora { font-size: 1.2rem; font-weight: 700; }

.marc-metodo {
  font-size: 0.75rem;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  padding: 2px 8px;
  border-radius: 12px;
}

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.kpi-wide {
  grid-column: 1 / -1;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ── Historial marcaciones ────────────────────────────── */

.filter-bar {
  position: fixed;
  top: var(--hdr-h);
  left: 0; right: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 90;
}

/* Ajuste del main cuando hay filter-bar */
.portal-main.has-filter { margin-top: calc(var(--hdr-h) + 56px); }

.dia-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.dia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.dia-fecha {
  font-weight: 600;
  font-size: 0.9rem;
}

.dia-semana {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 1px;
}

.dia-estado-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.est--cumplido           { background: rgba(34,197,94,0.12);  color: #86efac; }
.est--ausente            { background: rgba(239,68,68,0.12);   color: #fca5a5; }
.est--tardanza           { background: rgba(245,158,11,0.12);  color: #fde68a; }
.est--salida_temprana    { background: rgba(245,158,11,0.12);  color: #fde68a; }
.est--tardanza_y_salida  { background: rgba(249,115,22,0.12);  color: #fdba74; }
.est--ausencia           { background: rgba(139,92,246,0.12);  color: #c4b5fd; }
.est--libre              { background: rgba(148,163,184,0.08); color: var(--muted); }

.dia-body { padding: 10px 16px; display: flex; flex-direction: column; gap: 6px; }

.dia-horario {
  display: flex;
  gap: 16px;
  font-size: 0.85rem;
}

.dia-horario span { color: var(--muted); margin-right: 4px; }

.dia-horas {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Ausencias ────────────────────────────────────────── */

.aus-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
}

.aus-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.aus-tipo-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.aus-estado-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}

.aus-est--pendiente  { background: rgba(245,158,11,0.12); color: #fde68a; }
.aus-est--aprobado   { background: rgba(34,197,94,0.12);  color: #86efac; }
.aus-est--rechazado  { background: rgba(239,68,68,0.12);  color: #fca5a5; }
.aus-est--anulado    { background: rgba(148,163,184,0.08); color: var(--muted); }

.aus-fechas {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.aus-dias {
  font-size: 0.8rem;
  color: var(--muted);
}

.dias-calculados {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Modal ────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 20px 32px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ── Spinner / empty ──────────────────────────────────── */

.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

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

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

.empty-msg {
  color: var(--muted);
  text-align: center;
  padding: 48px 20px;
  font-size: 0.9rem;
}

/* ── Responsive ───────────────────────────────────────── */

@media (min-width: 480px) {
  .login-card  { padding: 40px 36px; }
  .portal-main { padding: 20px; }
}

@media (min-width: 768px) {
  .portal-header { max-width: 600px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
  .portal-nav    { max-width: 600px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
  .filter-bar    { max-width: 600px; left: 50%; transform: translateX(-50%); right: auto; width: 100%; }
  .portal-main   { max-width: 600px; margin-left: auto; margin-right: auto; }
}
