/* ── Vilotider — Driver View (Dark TAK Theme) ─────────────────────────────── */
:root {
  --bg:         #1a1a1a;
  --bg2:        #242424;
  --bg3:        #2e2e2e;
  --border:     #3a3a3a;
  --text:       #e8e8e8;
  --text-dim:   #888;
  --accent:     #ff6600;
  --green:      #3cb870;
  --green-dim:  #2a6640;
  --red:        #e04040;
  --red-dim:    #6b2020;
  --yellow:     #f0b030;
  --blue:       #4a90d9;
  --blue-dim:   #2a4a7a;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Login Screen ────────────────────────────────────────────────────────── */
#login-screen {
  padding: 32px 20px;
}

.login-logo {
  text-align: center;
  margin-bottom: 8px;
}
.login-logo img {
  height: 52px;
  filter: brightness(0.9);
}

.login-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 28px;
}

.driver-list {
  list-style: none;
}

.driver-list-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  transition: background 0.1s, border-color 0.1s;
}
.driver-list-item:active { background: var(--bg3); }
.driver-list-item.selected { border-color: var(--accent); }

.driver-list-name {
  font-size: 16px;
  font-weight: 600;
}
.driver-list-grad {
  font-size: 12px;
  color: var(--text-dim);
}

/* PIN entry (inside login flow) */
.pin-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 12px;
}

.pin-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 12px;
  text-align: center;
}

.pin-input-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.pin-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 8px;
  text-align: center;
  padding: 12px 16px;
  -webkit-text-security: disc;
}
.pin-input:focus { outline: none; border-color: var(--accent); }

/* ── Top Header ──────────────────────────────────────────────────────────── */
.driver-header {
  background: #111;
  border-bottom: 2px solid var(--accent);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
}

.header-driver {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.header-driver-name {
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
}
.header-driver-name:active { opacity: 0.7; }

.header-driver-sub {
  font-size: 11px;
  color: var(--text-dim);
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 22px;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: 0.2s;
}
input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
input:checked + .toggle-slider::before {
  transform: translateX(18px);
  background: #fff;
}

/* ── Tab panels + bottom nav ─────────────────────────────────────────────── */

#main-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.tab-panels {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  position: absolute;
  inset: 0;
}
.tab-panel.active { display: flex; flex-direction: column; }

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 16px;
}

/* Bottom nav */
.bottom-nav {
  display: flex;
  background: #111;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  min-height: 56px;
  transition: color 0.15s;
}
.nav-btn svg {
  width: 22px;
  height: 22px;
}
.nav-btn.active { color: var(--accent); }

/* ── Section headings ────────────────────────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

/* ── Status pills ────────────────────────────────────────────────────────── */
.status-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.status-pill.green  { background: var(--green-dim); color: var(--green); border: 1px solid var(--green); }
.status-pill.red    { background: var(--red-dim);   color: var(--red);   border: 1px solid var(--red); }
.status-pill.yellow { background: #4a3800;          color: var(--yellow); border: 1px solid var(--yellow); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-warnings {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.status-warning {
  font-size: 13px;
  color: var(--yellow);
  padding: 4px 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.status-warning::before { content: '⚠'; font-size: 12px; }

.status-info {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ── 24h Timeline ────────────────────────────────────────────────────────── */
.timeline-wrap {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 8px 10px;
}
.timeline-wrap::-webkit-scrollbar { display: none; }

.timeline-inner {
  width: 700%; /* 7 days */
  min-width: 700%;
}

.timeline-bar {
  position: relative;
  height: 28px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: visible;
  margin-bottom: 18px;
}

.timeline-block {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 3px;
  opacity: 0.9;
}
.timeline-block.vila    { background: var(--green); }
.timeline-block.rast    { background: var(--blue); }
.timeline-block.korning { background: var(--accent); }

.tl-tick {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 1px;
  background: rgba(255,255,255,0.15);
  z-index: 1;
  pointer-events: none;
}
.tl-tick.tl-tick-midnight { background: rgba(255,255,255,0.40); }
.tl-tick.tl-tick-noon     { background: rgba(255,255,255,0.25); }

.tl-tick-label {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: var(--text-dim);
  opacity: 0.85;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tl-tick.tl-tick-midnight .tl-tick-label,
.tl-tick.tl-tick-noon     .tl-tick-label { opacity: 1; color: var(--text); }

.timeline-now {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: #fff;
  border-radius: 1px;
  z-index: 5;
}

.timeline-labels {
  position: relative;
  height: 16px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.timeline-labels span {
  position: absolute;
  transform: translateX(-50%);
}

.timeline-legend {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.legend-dot.vila    { background: var(--green); }
.legend-dot.rast    { background: var(--blue); }
.legend-dot.korning { background: var(--accent); }

/* ── Entry Form ──────────────────────────────────────────────────────────── */
.entry-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.type-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.type-tab {
  flex: 1;
  padding: 10px 4px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
}
.type-tab.active.vila    { background: var(--green-dim);  color: var(--green);  border-color: var(--green); }
.type-tab.active.rast    { background: var(--blue-dim);   color: var(--blue);   border-color: var(--blue); }
.type-tab.active.korning { background: #3d2800;           color: var(--accent); border-color: var(--accent); }

/* Time pickers layout */
.time-pickers-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.time-picker-group {
  flex: 1;
}

.time-picker-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 6px;
}

/* Drum roller picker */
.picker-outer {
  position: relative;
  height: 132px; /* 3 items × 44px */
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg3);
  border: 1px solid var(--border);
}

/* Gradient fade top/bottom */
.picker-outer::before,
.picker-outer::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 44px;
  z-index: 2;
  pointer-events: none;
}
.picker-outer::before {
  top: 0;
  background: linear-gradient(to bottom, var(--bg3), transparent);
}
.picker-outer::after {
  bottom: 0;
  background: linear-gradient(to top, var(--bg3), transparent);
}

/* Highlight band */
.picker-highlight {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 0; right: 0;
  height: 44px;
  border-top: 1.5px solid var(--accent);
  border-bottom: 1.5px solid var(--accent);
  background: rgba(255, 102, 0, 0.08);
  z-index: 1;
  pointer-events: none;
}

.picker-cols {
  display: flex;
  height: 100%;
  position: relative;
  z-index: 0;
}

.picker-col {
  flex: 1;
  height: 132px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.picker-col::-webkit-scrollbar { display: none; }

.picker-pad {
  height: 44px; /* one item above/below for centering */
}

.picker-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  scroll-snap-align: center;
  color: var(--text);
  user-select: none;
}

.picker-sep {
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-dim);
  flex-shrink: 0;
  padding-top: 0;
}

.now-btn {
  width: 100%;
  margin-top: 6px;
  padding: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}
.now-btn:active { background: var(--bg2); }

/* Duration display */
.duration-display {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 14px;
  padding: 8px;
  background: var(--bg3);
  border-radius: 6px;
}

.duration-display strong {
  color: var(--text);
  font-size: 15px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  min-height: 48px;
  transition: opacity 0.1s, transform 0.1s;
  width: 100%;
}
.btn:active { opacity: 0.8; transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-secondary {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 100;
  align-items: flex-end;
  padding: 0;
}
.modal-overlay.open {
  display: flex;
}

.modal-sheet {
  background: var(--bg2);
  border-radius: 16px 16px 0 0;
  border-top: 2px solid var(--border);
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 6px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 20px;
}

.modal-result {
  text-align: center;
  padding: 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: none;
}
.modal-result.success {
  background: var(--green-dim);
  color: var(--green);
  display: block;
}
.modal-result.error {
  background: var(--red-dim);
  color: var(--red);
  display: block;
}

/* ── Status panel — no scroll ────────────────────────────────────────────── */
#panel-status > .panel-scroll {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 8px;
}
#panel-status .status-top { flex-shrink: 0; }
#panel-status .status-top .status-card {
  padding: 10px 14px;
  margin-bottom: 8px;
}
#panel-status .status-top .timeline-wrap {
  margin-bottom: 8px;
}
#panel-status .timeline-legend { display: none; }
#panel-status .entry-form {
  flex: 1;
  min-height: 0;
  padding: 12px 14px;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
}
#panel-status .type-tabs    { margin-bottom: 10px; }
#panel-status .time-pickers-row { margin-bottom: 10px; flex: 0 0 auto; }
#panel-status .duration-display { margin-bottom: 10px; }
#panel-status .type-tab     { padding: 8px 4px; }
#panel-status .now-btn      { padding: 6px; }
#panel-status #submit-btn   { margin-top: auto; }

/* ── History accordion ───────────────────────────────────────────────────── */
.history-group {
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.history-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  background: var(--bg2);
  gap: 8px;
  user-select: none;
}
.history-group-header:active { background: var(--bg3); }

.history-date-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.history-chevron {
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s;
  display: inline-block;
  width: 10px;
}
.history-group.open .history-chevron { transform: rotate(90deg); }

.history-date {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text);
}

.history-group-entries {
  display: none;
  padding: 6px 10px 10px;
  background: var(--bg);
}
.history-group.open .history-group-entries { display: block; }

/* Compact signature indicator in header */
.sig-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}
.sig-dot.signed   { background: var(--green-dim); color: var(--green);  border: 1.5px solid var(--green); }
.sig-dot.unsigned { background: #3a3000;          color: var(--yellow); border: 1.5px solid var(--yellow); cursor: pointer; }

/* Full signee row at bottom of expanded group */
.sig-detail-row {
  display: flex;
  justify-content: flex-end;
  padding: 8px 0 2px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Legacy flat row (kept for compat, unused by accordion) */
.history-date-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 16px 0 6px;
  gap: 8px;
}

.entry-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.entry-type-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.entry-type-dot.vila    { background: var(--green); }
.entry-type-dot.rast    { background: var(--blue); }
.entry-type-dot.korning { background: var(--accent); }

.entry-card-body {
  flex: 1;
  min-width: 0;
}

.entry-card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.entry-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.entry-del-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  flex-shrink: 0;
  opacity: 0.5;
}
.entry-del-btn:active { opacity: 1; color: var(--red); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge.approved  { background: var(--green-dim); color: var(--green); }
.badge.pending   { background: #3a3000;          color: var(--yellow); }

/* ── Error toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  z-index: 200;
  max-width: 90vw;
  text-align: center;
  display: none;
}
.toast.show { display: block; }

/* ── Timeline tooltip ────────────────────────────────────────────────────── */
#tl-tip {
  display: none;
  position: absolute;
  background: #111;
  color: #e8e8e8;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
#tl-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.spacer { height: 12px; }

input[type="number"] {
  appearance: textfield;
}
