/* ──────────────────────────────────────────────────────────────────
   Ellevar Clockin — sistema de design
   ────────────────────────────────────────────────────────────────── */

:root {
  /* Paleta */
  --c-primary-900: #06291e;
  --c-primary-800: #0b3d2e;
  --c-primary-700: #1c5d3c;
  --c-primary-600: #2d7a52;
  --c-primary-100: #d8efdf;
  --c-primary-50:  #f0f7f2;

  --c-accent-700: #8a5a00;
  --c-accent-500: #d4a548;
  --c-accent-100: #fff4d6;

  --c-danger-700: #8a1c0c;
  --c-danger-500: #d4624c;
  --c-danger-100: #fde0dd;

  --c-warm-0:   #ffffff;
  --c-warm-50:  #faf9f3;
  --c-warm-100: #f4f1e6;
  --c-warm-200: #e5e2d4;
  --c-warm-300: #cfcabc;
  --c-warm-400: #a8a59b;
  --c-warm-600: #6b6960;
  --c-warm-800: #2a2925;
  --c-warm-900: #16221e;

  /* Semantica */
  --bg:         var(--c-warm-50);
  --bg-card:    var(--c-warm-0);
  --bg-subtle:  var(--c-warm-100);
  --fg:         var(--c-warm-900);
  --fg-muted:   var(--c-warm-600);
  --fg-subtle:  var(--c-warm-400);
  --primary:    var(--c-primary-800);
  --primary-fg: var(--c-warm-0);
  --border:     var(--c-warm-200);
  --border-strong: var(--c-warm-300);

  /* Elevação */
  --shadow-sm:  0 1px 2px rgba(16,21,18,.04), 0 1px 1px rgba(16,21,18,.03);
  --shadow-md:  0 6px 16px rgba(16,21,18,.06), 0 2px 4px rgba(16,21,18,.03);
  --shadow-lg:  0 16px 36px rgba(16,21,18,.10), 0 4px 12px rgba(16,21,18,.04);

  /* Raios */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 9999px;

  /* Tipografia */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

[hidden] { display: none !important; }

/* Tema escuro OLED — preto puro (#000), cartões quase-pretos, contraste alto */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #000000;
    --bg-card:    #0c0f0e;
    --bg-subtle:  #14181a;
    --fg:         #ececec;
    --fg-muted:   #9a9a94;
    --fg-subtle:  #62625c;
    --primary:    #56b07d;
    --primary-fg: #04130c;
    --border:     #20262a;
    --border-strong: #313a3e;
    --c-warm-0:   #0c0f0e;
    --c-warm-50:  #000000;
    --c-warm-100: #14181a;
    --c-warm-200: #20262a;
    --c-warm-300: #313a3e;
    --c-warm-400: #62625c;
    --c-warm-600: #9a9a94;
    --c-warm-800: #ececec;
    --c-warm-900: #f7f7f4;
    --c-primary-50: #0d1a13;
    --c-primary-100: #133024;
    --c-primary-600: #56b07d;
    --c-primary-700: #74c597;
    --c-primary-800: #cdeada;
    --c-primary-900: #e3f4e9;
    --c-accent-100: #2e2509;
    --c-accent-500: #d4a548;
    --c-accent-700: #f3cd7e;
    --c-danger-100: #2e1109;
    --c-danger-500: #e07058;
    --c-danger-700: #f5a796;
    --shadow-sm:  0 1px 2px rgba(0,0,0,.5);
    --shadow-md:  0 6px 16px rgba(0,0,0,.6);
    --shadow-lg:  0 16px 36px rgba(0,0,0,.7);
  }
}
:root[data-theme="dark"] {
  --bg:         #000000;
  --bg-card:    #0c0f0e;
  --bg-subtle:  #14181a;
  --fg:         #ececec;
  --fg-muted:   #9a9a94;
  --fg-subtle:  #62625c;
  --primary:    #56b07d;
  --primary-fg: #04130c;
  --border:     #20262a;
  --border-strong: #313a3e;
  --c-warm-0:   #0c0f0e;
  --c-warm-50:  #000000;
  --c-warm-100: #14181a;
  --c-warm-200: #20262a;
  --c-warm-300: #313a3e;
  --c-warm-400: #62625c;
  --c-warm-600: #9a9a94;
  --c-warm-800: #ececec;
  --c-warm-900: #f7f7f4;
  --c-primary-50: #0d1a13;
  --c-primary-100: #133024;
  --c-primary-600: #56b07d;
  --c-primary-700: #74c597;
  --c-primary-800: #cdeada;
  --c-primary-900: #e3f4e9;
  --c-accent-100: #2e2509;
  --c-accent-500: #d4a548;
  --c-accent-700: #f3cd7e;
  --c-danger-100: #2e1109;
  --c-danger-500: #e07058;
  --c-danger-700: #f5a796;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.5);
  --shadow-md:  0 6px 16px rgba(0,0,0,.6);
  --shadow-lg:  0 16px 36px rgba(0,0,0,.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background:
    radial-gradient(circle at top right, rgba(216, 239, 223, 0.35), transparent 55%),
    radial-gradient(circle at -20% 30%, rgba(244, 241, 230, 0.6), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}

/* OLED: fundo preto puro, sem brilhos */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body { background: #000; }
}
:root[data-theme="dark"] body { background: #000; }

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg);
}
h1 { font-size: 19px; }
h2 { font-size: 16px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); font-weight: 600; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); font-weight: 600; }

p { margin: 0; }

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

.screen {
  min-height: 100vh;
  padding: 14px 14px calc(74px + env(safe-area-inset-bottom));
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Abas + barra inferior ──────────────────────────────────────── */
.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  background: var(--c-primary-50);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 6px;
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  position: relative;
  transition: color .15s;
}
.tab-btn .tab-ico { font-size: 20px; line-height: 1; }
.tab-btn .tab-lbl { font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.tab-btn.active { color: var(--primary); }
.tab-btn.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--primary);
}
.tab-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 22px);
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--c-danger-500, #d9534f);
  border: 1.5px solid var(--c-primary-50);
}

/* ── Header ─────────────────────────────────────────────────────── */

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: env(safe-area-inset-top);
  margin-bottom: 4px;
}
.brand h1 {
  font-size: 21px;
  color: var(--primary);
  letter-spacing: -0.02em;
}
.brand .muted { margin: 0; }

/* ── Cards ──────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card h2 { font-size: 15px; }

/* ── Textos auxiliares ──────────────────────────────────────────── */

.muted { color: var(--fg-muted); }
.small { font-size: 13px; }
.error {
  color: var(--c-danger-700);
  font-size: 13px;
  background: var(--c-danger-100);
  padding: 8px 12px;
  border-radius: var(--r-sm);
}

footer.muted {
  text-align: center;
  margin-top: auto;
  padding-top: 12px;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}

/* ── Inputs / labels ───────────────────────────────────────────── */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--fg-muted);
}

input, select, textarea {
  font: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-card);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(28, 93, 60, 0.15);
}
input[type="time"], input[type="date"], input[type="number"] {
  letter-spacing: 0;
  text-align: left;
  font-variant-numeric: tabular-nums;
}
input[type="password"] { letter-spacing: 6px; text-align: center; font-size: 22px; }

/* ── Botões ─────────────────────────────────────────────────────── */

button, .as-button {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  color: var(--fg);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.06s ease, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
button:active, .as-button:active { transform: scale(0.98); }
button:focus-visible, .as-button:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button.primary, .primary.as-button {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset, 0 4px 12px rgba(11, 61, 46, 0.18);
}
button.primary:hover { background: var(--c-primary-700); }
button.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.ghost, .ghost.as-button {
  background: transparent;
  color: var(--primary);
  border-color: var(--border-strong);
}
button.ghost:hover { background: var(--c-primary-50); border-color: var(--primary); }

button.big { font-size: 16px; padding: 15px 18px; }

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.row.between { justify-content: space-between; align-items: center; }
.row > .flex { flex: 1; }

/* ── Relógio ────────────────────────────────────────────────────── */

.now-date {
  text-align: center;
  text-transform: capitalize;
  margin: 0;
  font-size: 13px;
}
.now {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  margin: -2px 0 2px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.geo {
  text-align: center;
  padding: 6px 0;
}

.next-info {
  text-align: center;
  padding: 8px 12px;
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  font-size: 13px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.next-info .next-label {
  color: var(--fg-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.next-info strong {
  color: var(--primary);
  font-weight: 700;
  font-size: 20px;
}

.geo-toggle {
  align-self: center;
  font-size: 12px;
  padding: 6px 12px;
}
.geo-toggle.on { color: var(--c-danger-700); border-color: var(--c-danger-500); }

/* ── Banner de status do turno ─────────────────────────────────── */

.banner {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: var(--r-lg);
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}
.banner-icon {
  font-size: 22px;
  line-height: 1;
  width: 38px;
  height: 38px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.55);
  flex-shrink: 0;
}
.banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.banner-text strong { font-size: 14px; font-weight: 700; }
.banner-text .small { font-size: 12px; }

.banner-low {
  background: var(--c-primary-50);
  border-color: var(--c-primary-100);
  color: var(--c-primary-900);
}
.banner-medium {
  background: var(--c-accent-100);
  border-color: #f0d894;
  color: var(--c-accent-700);
}
.banner-high {
  background: var(--c-danger-100);
  border-color: #efb1a5;
  color: var(--c-danger-700);
  box-shadow: 0 0 0 6px rgba(212, 98, 76, 0.10);
  font-weight: 600;
}
.banner-info {
  background: #e6f0fb;
  border-color: #a6c6e6;
  color: #163b66;
}

/* OLED: backdrop do ícone discreto e banner-info escuro */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .banner-icon { background: rgba(255,255,255,0.07); }
  :root:not([data-theme="light"]) .banner-info {
    background: #0c1722; border-color: #1e3349; color: #9cc2e8;
  }
}
:root[data-theme="dark"] .banner-icon { background: rgba(255,255,255,0.07); }
:root[data-theme="dark"] .banner-info {
  background: #0c1722; border-color: #1e3349; color: #9cc2e8;
}

/* ── Hours / Stat boxes ────────────────────────────────────────── */

.hours-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.hours-grid > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 6px;
  background: var(--c-primary-50);
  border-radius: var(--r-md);
  text-align: center;
}
.hours-grid > div > .small {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-primary-700);
  font-weight: 600;
}
.hours-grid strong {
  font-size: 20px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.hours-grid .small:last-child { font-size: 11px; color: var(--c-primary-700); }

/* ── Badges ─────────────────────────────────────────────────────── */

.badge-ok, .badge-warn, .badge-err {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--r-full);
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-ok {
  background: var(--c-primary-100);
  color: var(--c-primary-800);
  border: 1px solid var(--c-primary-100);
}
.badge-warn {
  background: var(--c-accent-100);
  color: var(--c-accent-700);
  border: 1px solid #f0d894;
}
.badge-err {
  background: var(--c-danger-100);
  color: var(--c-danger-700);
  border: 1px solid #efb1a5;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}
.link:hover { text-decoration: underline; }

/* ── Timeline do dia ────────────────────────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.timeline-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--bg-subtle);
  border-left: 4px solid var(--border-strong);
  transition: background 0.15s;
}
.timeline-step.ok {
  background: var(--c-primary-50);
  border-left-color: var(--c-primary-600);
}
.timeline-step.warn {
  background: var(--c-accent-100);
  border-left-color: var(--c-accent-500);
}
.timeline-step.pending {
  background: var(--bg-card);
  border-left-color: var(--border);
}
.timeline-step.pending .step-title { color: var(--fg-muted); }

.step-icon {
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--bg-card);
  color: var(--fg-muted);
  font-weight: 700;
}
.timeline-step.ok .step-icon { background: var(--c-primary-600); color: white; }
.timeline-step.warn .step-icon { background: var(--c-accent-500); color: white; }

.step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.step-title { font-weight: 700; font-size: 14px; }
.step-time-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  flex-wrap: wrap;
  color: var(--fg);
}
.step-time-row strong { font-variant-numeric: tabular-nums; }
.step-time-row + .step-time-row { margin-top: 2px; padding-top: 4px; border-top: 1px dashed var(--border); }
.step-warnings {
  font-size: 11px;
  color: var(--c-accent-700);
  font-weight: 600;
}

/* ── Notificações (switch) ──────────────────────────────────────── */

.pending-card {
  background: var(--c-accent-100);
  border-color: #f0d894;
}
.pending-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: var(--c-accent-500);
  color: white;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.switch-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-weight: normal;
  font-size: 14px;
  color: var(--fg);
  padding: 8px 0;
}
.switch-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Modal próprio ──────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 30, 22, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}
.modal-dialog {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 22px;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow-lg);
  animation: popIn 0.15s ease-out;
}
.modal-dialog h3 {
  margin: 0;
  color: var(--primary);
  font-size: 16px;
  text-transform: none;
  letter-spacing: 0;
}
.modal-body {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-line;
  color: var(--fg);
}
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}
.modal-buttons button { padding: 10px 18px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

/* ── Seção recolhível ───────────────────────────────────────────── */
.collapse-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
}
.collapse-head:active { transform: none; }
.collapse-head h2 { margin: 0; }
.collapse-caret {
  font-size: 16px;
  color: var(--fg-muted);
  transition: transform 0.18s ease;
}
.collapse-head[aria-expanded="false"] .collapse-caret { transform: rotate(-90deg); }
#notif-body { display: flex; flex-direction: column; gap: 11px; }
#notif-body[hidden] { display: none; }

/* ── Banco de horas ─────────────────────────────────────────────── */
.hb-summary { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hb-summary .big-number { font-size: 24px; font-weight: 700; }
.hb-breakdown { display: flex; flex-direction: column; gap: 2px; margin-left: auto; text-align: right; }
.section-heading { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin: 14px 0 6px; }

/* ── Lista de batidas (legado, mantido) ────────────────────────── */

.punch-list { list-style: none; padding: 0; margin: 0; }
.punch-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.punch-list li:last-child { border-bottom: none; }

/* ── Reduce motion ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
