/* =====================================================================
   SIEMAV · ASISTENCIA — estilo inspirado en One UI 9 (Samsung)
   Claro/oscuro automático según el sistema, con toggle manual.
   ===================================================================== */

:root {
  --accent: #0381fe;
  --accent-soft: rgba(3, 129, 254, 0.14);
  --danger: #ff453a;
  --warn: #ffb340;
  --ok: #30d158;

  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --radius-pill: 999px;

  --font: -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* ---- Tema claro (default) ---- */
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --text: #191a1d;
  --text-muted: #6c6f78;
  --border: rgba(0, 0, 0, 0.07);
  --shadow: 0 8px 24px rgba(20, 20, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #242427;
    --text: #f2f2f4;
    --text-muted: #9a9aa0;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #242427;
  --text: #f2f2f4;
  --text-muted: #9a9aa0;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 10px 10px 24px; }
.brand-circle {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 16px; }
.brand-text span { font-size: 12px; color: var(--text-muted); }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 15px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.sidebar-link .icon { width: 22px; display: flex; align-items: center; justify-content: center; }
.sidebar-link .icon svg { width: 18px; height: 18px; }
.sidebar-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); margin-top: 12px; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 28px; position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}
.topbar-title { font-size: 22px; font-weight: 800; margin: 0; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-pill);
  border: none; background: var(--surface); color: var(--text);
  font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.icon-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 6px 14px rgba(0,0,0,0.12); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn-success { background: rgba(48,209,88,0.15); color: var(--ok); }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; background: var(--surface); border-radius: var(--radius-pill); box-shadow: var(--shadow); }
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.user-name { font-size: 13px; font-weight: 600; }

.app-content { flex: 1; padding: 8px 28px 40px; }

.only-mobile { display: none; }
.only-desktop { display: flex; }

.menu-movil { position: relative; }
.menu-movil-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 50;
  background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow);
  padding: 8px; min-width: 210px;
  display: none; flex-direction: column; gap: 2px;
}
.menu-movil-panel.abierto { display: flex; }
.menu-movil-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-weight: 600;
}
.menu-movil-link .icon { width: 20px; display: flex; align-items: center; justify-content: center; }
.menu-movil-link .icon svg { width: 17px; height: 17px; }
.menu-movil-link.active { background: var(--accent-soft); color: var(--accent); }
.menu-movil-separador { height: 1px; background: var(--border); margin: 6px 4px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .only-mobile { display: flex; }
  .only-desktop { display: none; }
  .app-content { padding: 8px 16px 40px; }
  .topbar { padding: 16px; }
}

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border-radius: 10px;
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.card-header h2 { font-size: 17px; margin: 0; font-weight: 800; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--surface); border-radius: 10px; padding: 18px; box-shadow: var(--shadow); }
.stat-card .value { font-size: 26px; font-weight: 800; }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.config-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.config-tile {
  background: var(--surface); border-radius: 10px; padding: 22px 16px;
  box-shadow: var(--shadow); text-align: center; cursor: pointer; border: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 10px; font-weight: 700; font-size: 14px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.config-tile .icon { display: flex; align-items: center; justify-content: center; }
.config-tile .icon svg { width: 26px; height: 26px; }
.config-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow), 0 6px 14px rgba(0,0,0,0.12); }
.config-tile:active { transform: scale(0.97); }

/* ---------------------------------------------------------------- buttons */
.btn {
  border: none; border-radius: 10px; padding: 11px 20px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); color: var(--text);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.12); filter: brightness(1.05); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-danger { background: rgba(255,69,58,0.14); color: var(--danger); }
.btn-success { background: rgba(48,209,88,0.14); color: var(--ok); }
.btn-pdf { background: rgba(229,57,53,0.14); color: #e53935; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 14px; font-size: 12.5px; }
.btn-icon { padding: 7px 9px; }
.btn-icon svg { display: block; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea {
  font-family: inherit; font-size: 15px; font-weight: 500; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 14px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }
.checkbox-field { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); }

/* ficha de empleado: secciones con campos en rejilla */
.form-section { margin-bottom: 26px; }
.form-section h3 { font-size: 14px; font-weight: 800; margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); column-gap: 16px; }
.asist-select { font-family: inherit; font-size: 13px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; min-width: 84px; }
.asist-info { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

.filters-bar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.filters-bar .field { margin-bottom: 0; }

/* ---------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; font-size: 12px; text-transform: none; color: var(--text);
  font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 6px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table.sortable th[data-orden] { cursor: pointer; user-select: none; }
.data-table.sortable th[data-orden]:hover { color: var(--text); }
.data-table.sortable th[data-orden].orden-asc::after { content: ' \25B2'; font-size: 10px; }
.data-table.sortable th[data-orden].orden-desc::after { content: ' \25BC'; font-size: 10px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; }
.badge-entrada { background: rgba(48,209,88,0.15); color: var(--ok); }
.badge-salida { background: rgba(3,129,254,0.15); color: var(--accent); }
.badge-almuerzo { background: rgba(255,179,64,0.18); color: var(--warn); }
.badge-sin { background: rgba(255,69,58,0.15); color: var(--danger); }
.badge-manual { background: var(--surface-2); color: var(--text-muted); border: 1px dashed var(--border); }
.row-actions { display: flex; gap: 6px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ---------------------------------------------------------------- modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 100;
  animation: fadeIn .15s ease;
}
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal-box {
  background: var(--surface); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 10px 10px 0 0; padding: 24px; animation: slideUp .2s ease;
}
@media (min-width: 640px) { .modal-box { border-radius: 10px; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { margin: 0; font-size: 18px; font-weight: 800; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(24px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.confirm-icon { width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 14px; }
.confirm-icon.info { background: var(--accent-soft); color: var(--accent); }
.confirm-icon.warn { background: rgba(255,179,64,0.18); color: var(--warn); }
.confirm-icon.danger { background: rgba(255,69,58,0.15); color: var(--danger); }
.confirm-text { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 4px; }
.confirm-title { text-align: center; font-weight: 800; font-size: 17px; margin-bottom: 4px; }

/* ---------------------------------------------------------------- alerts + toast */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; margin-bottom: 14px; }
.alert-error { background: rgba(255,69,58,0.12); color: var(--danger); }
.alert-info { background: var(--accent-soft); color: var(--accent); }

.toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); box-shadow: var(--shadow); border-radius: var(--radius-sm); padding: 13px 18px; font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 10px; animation: slideUp .2s ease; max-width: 320px; }
.toast.success { border-left: 4px solid var(--ok); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent); }

/* ---------------------------------------------------------------- stepper (importar) */
.steps { display: flex; gap: 8px; margin-bottom: 20px; }
.step-dot { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.step-dot.active { background: var(--accent); }
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius-md); padding: 34px 16px;
  text-align: center; color: var(--text-muted); font-size: 14px; cursor: pointer;
}
.dropzone.dragging { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.mapping-table { font-size: 13px; }
.mapping-table th, .mapping-table td { padding: 6px 10px; }

/* ---------------------------------------------------------------- login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 10px; padding: 32px 26px; box-shadow: var(--shadow); margin: 16px; }
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo-circle { width: 56px; height: 56px; border-radius: var(--radius-md); background: var(--accent); color: #fff; font-weight: 800; font-size: 24px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.login-logo h1 { font-size: 19px; margin: 0 0 4px; }
.login-logo p { font-size: 13px; color: var(--text-muted); margin: 0; }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
