/* ShiftFlow — designsystem v2 (Fas 7 UX/UI-omdesign).
   Filosofi: stora tydliga tal, mjuka kort, statusfärg istället för text där
   det går, gott om luft, en enda uppenbar primäraktion per skärm. */

:root {
  --bg: #f7f7fb;
  --surface: #ffffff;
  --surface-2: #f2f2f7;
  --border: #e8e8ef;
  --border-soft: #f0f0f5;
  --text: #15161a;
  --text-muted: #6b6d78;
  --text-faint: #9799a3;

  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef0ff;

  --status-working: #16a34a;
  --status-working-soft: #e8f8ee;
  --status-break: #d97706;
  --status-break-soft: #fef3e2;
  --status-late: #dc2626;
  --status-late-soft: #fdeaea;
  --status-scheduled: #2563eb;
  --status-scheduled-soft: #eaf1fe;
  --status-idle: #9799a3;
  --status-idle-soft: #f0f0f5;

  --danger: #dc2626;
  --success: #16a34a;

  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.04), 0 1px 1px rgba(20, 20, 30, 0.03);
  --shadow-md: 0 4px 16px rgba(20, 20, 30, 0.06), 0 1px 2px rgba(20, 20, 30, 0.04);
  --shadow-lg: 0 12px 32px rgba(20, 20, 30, 0.12), 0 2px 8px rgba(20, 20, 30, 0.06);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

@media (prefers-reduced-motion: no-preference) {
  .card, .stat-card, .panel-backdrop, .panel, .quick-menu, button, .btn { transition: box-shadow 0.15s ease, transform 0.15s ease, background-color 0.15s ease, opacity 0.15s ease; }
}

/* ---------- App shell ---------- */

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

/* ---------- Startskärm (bara vid appstart, se app.js splashSeen) ---------- */

.app-splash {
  position: fixed;
  inset: 0;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease;
}
.app-splash.hide { opacity: 0; pointer-events: none; }
.app-splash-logo { color: #fff; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; animation: app-splash-pulse 1.4s ease-in-out infinite; }
@keyframes app-splash-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.96); }
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand { font-weight: 800; font-size: 19px; margin-bottom: 28px; display: block; letter-spacing: -0.02em; padding: 0 10px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 600;
}
.sidebar nav a .icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--primary-soft); color: var(--primary); text-decoration: none; }

.sidebar .nav-more { position: relative; margin-top: 2px; }
.more-panel {
  display: none;
  margin-top: 2px;
  margin-left: 30px;
  padding-left: 10px;
  border-left: 2px solid var(--border-soft);
  flex-direction: column;
  gap: 2px;
}
.more-panel.open { display: flex; }
.more-panel a { font-size: 13.5px; font-weight: 500; padding: 7px 10px; }

.sidebar-footer { margin-top: auto; padding-top: 12px; }

.main { flex: 1; padding: 30px 36px 60px; max-width: 1180px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 28px; }
.topbar .company-name { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.search-box { position: relative; }
.search-box input {
  width: 220px;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13.5px;
  background: var(--surface-2);
}
.search-box .search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: 0.6; pointer-events: none; }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 40;
  display: none;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 10px 14px; font-size: 14px; color: var(--text); }
.search-results a:hover { background: var(--surface-2); text-decoration: none; }
.search-results .empty { padding: 12px 14px; margin: 0; }

/* ---------- Typography ---------- */

h1 { font-size: 26px; font-weight: 800; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 14px; }
.lead { color: var(--text-muted); margin: 0 0 22px; font-size: 14.5px; }
.eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); margin: 0 0 6px; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 20px;
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.stat-card .value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* ---------- Status dots & badges ---------- */

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.working { background: var(--status-working); }
.dot.break { background: var(--status-break); }
.dot.late { background: var(--status-late); }
.dot.scheduled { background: var(--status-scheduled); }
.dot.idle { background: var(--status-idle); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--radius-full); font-size: 12px; font-weight: 700; background: var(--status-working-soft); color: var(--status-working); }
.badge.grey { background: var(--status-idle-soft); color: var(--text-muted); }
.badge.danger { background: var(--status-late-soft); color: var(--status-late); }
.badge.warn { background: var(--status-break-soft); color: var(--status-break); }
.badge.info { background: var(--status-scheduled-soft); color: var(--status-scheduled); }

/* ---------- Live list (Home "TODAY") ---------- */

.live-list { display: flex; flex-direction: column; }
.live-list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.live-list-row:last-child { border-bottom: none; }
.live-list-row:hover { background: var(--surface-2); }
.live-list-row .name { font-weight: 700; font-size: 14.5px; flex: 1; }
.live-list-row .status-text { font-size: 13.5px; color: var(--text-muted); }

/* ---------- Needs attention ---------- */

.attention-list { display: flex; flex-direction: column; gap: 2px; }
.attention-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 6px;
  border-radius: var(--radius-sm);
}
.attention-row:hover { background: var(--surface-2); }
.attention-row .msg { flex: 1; font-size: 14px; }
.attention-row .msg a { color: var(--text); font-weight: 600; }
.attention-row a.row-link { display: flex; align-items: center; gap: 12px; flex: 1; color: var(--text); }
.attention-row a.row-link:hover { text-decoration: none; }

/* ---------- Sub-page tabs (Pay hub etc.) ---------- */

.tab-bar { display: flex; gap: 4px; background: var(--surface-2); border-radius: var(--radius-md); padding: 4px; margin-bottom: 20px; width: fit-content; }
.tab-bar a { padding: 8px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600; color: var(--text-muted); }
.tab-bar a:hover { color: var(--text); text-decoration: none; }
.tab-bar a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Month schedule grid ---------- */

.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-grid-head { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--text-faint); padding-bottom: 4px; text-transform: uppercase; }
.month-day {
  aspect-ratio: 1;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  background: var(--surface);
}
.month-day:hover { background: var(--surface-2); }
.month-day.blank { visibility: hidden; cursor: default; }
.month-day-number { font-size: 13px; font-weight: 700; }
.month-day-dot { width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); background: transparent; }

/* ---------- Onboarding checklist ---------- */

.checklist { display: flex; flex-direction: column; gap: 2px; }
.checklist-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; }
.checklist-row .done-text { color: var(--text-faint); text-decoration: line-through; }

/* ---------- Tables (kept for dense data, styled lighter) ---------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--text-faint); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
.list-table { margin: 0; }
.list-table th:first-child, .list-table td:first-child { padding-left: 20px; }
.list-table th:last-child, .list-table td:last-child { padding-right: 20px; }
td.row-clickable { cursor: pointer; }
td.row-clickable:hover { background: var(--surface-2); }

/* ---------- Forms ---------- */

form label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; color: var(--text); }
form .field { margin-bottom: 16px; }
form .field-row { display: flex; gap: 16px; flex-wrap: wrap; }
form .field-row .field { flex: 1; min-width: 180px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field label { margin: 0; font-weight: 500; }
.checkbox-field input { width: auto; }
fieldset { border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 18px; margin: 0 0 20px; }
legend { font-weight: 700; font-size: 13.5px; padding: 0 8px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }

details.advanced { margin: 4px 0 20px; }
details.advanced > summary { cursor: pointer; font-size: 13.5px; font-weight: 700; color: var(--primary); padding: 8px 0; list-style: none; }
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before { content: "▸ "; }
details.advanced[open] > summary::before { content: "▾ "; }
details.advanced .card, details.advanced fieldset { margin-top: 10px; }

/* ---------- Buttons ---------- */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { background: var(--primary-hover); text-decoration: none; box-shadow: var(--shadow-md); }
.btn.secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-2); box-shadow: none; }
.btn.danger { background: var(--danger); }
.btn.ghost { background: transparent; color: var(--text-muted); box-shadow: none; padding: 8px 10px; }
.btn.ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Flash / alerts ---------- */

.flash { padding: 13px 16px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.flash.error { background: var(--status-late-soft); color: #7f1d1d; }
.flash.success { background: var(--status-working-soft); color: #14532d; }
.flash.info { background: #eef2ff; color: #3730a3; }
.flash.info a { color: inherit; text-decoration: underline; }

/* ---------- Empty states ---------- */

.empty { color: var(--text-muted); font-size: 14px; }
.empty-state { text-align: center; padding: 44px 20px; }
.empty-state .emoji { font-size: 34px; margin-bottom: 10px; }
.empty-state .title { font-weight: 700; font-size: 15.5px; margin-bottom: 4px; }
.empty-state .desc { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }

/* ---------- Global quick-action button ---------- */

.quick-action-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  border: none;
  cursor: pointer;
}
.quick-action-fab:hover { background: var(--primary-hover); }

.quick-menu {
  position: fixed;
  right: 28px;
  bottom: 94px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  width: 220px;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: 2px;
}
.quick-menu.open { display: flex; }
.quick-menu a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); font-size: 14px; font-weight: 600; }
.quick-menu a:hover { background: var(--surface-2); text-decoration: none; }
.quick-menu .qi { font-size: 16px; width: 20px; text-align: center; }

/* ---------- Side panel ---------- */

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.32);
  z-index: 60;
  display: none;
}
.panel-backdrop.open { display: block; }

.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 61;
  overflow-y: auto;
  padding: 24px;
  transform: translateX(100%);
}
.panel-backdrop.open .panel { transform: translateX(0); }
.panel .panel-close { position: absolute; top: 18px; right: 18px; font-size: 20px; color: var(--text-muted); background: none; box-shadow: none; padding: 6px; }
.panel .panel-close:hover { background: var(--surface-2); color: var(--text); }
.panel-section { padding: 16px 0; border-bottom: 1px solid var(--border-soft); }
.panel-section:last-child { border-bottom: none; }
.panel-section .eyebrow { margin-bottom: 8px; }

/* ---------- Code / mono ---------- */

.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* ---------- Auth pages ---------- */

.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.auth-box { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 36px; width: 380px; }
.auth-box h1 { text-align: center; margin-bottom: 22px; }

/* ---------- Employee mobile app ---------- */

.employee-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.employee-page { max-width: 460px; width: 100%; margin: 0 auto; padding: 24px 18px 100px; flex: 1; }
.employee-page .greeting { font-size: 23px; font-weight: 800; margin-bottom: 2px; letter-spacing: -0.01em; }
.employee-page .shift-info { color: var(--text-muted); font-size: 14.5px; margin-bottom: 24px; }

.install-banner {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 16px 36px 16px 16px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.install-banner.hidden { display: none; }
.install-banner .ib-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.install-banner .ib-title { font-weight: 700; font-size: 14.5px; margin: 0 0 2px; }
.install-banner .ib-desc { font-size: 13px; color: var(--text-muted); margin: 0; }
.install-banner .ib-btn { margin-top: 8px; }
.install-banner-close { position: absolute; top: 10px; right: 10px; background: none; box-shadow: none; padding: 4px 8px; color: var(--text-muted); font-size: 14px; }
.install-banner-close:hover { background: var(--surface-2); }

.clock-status { text-align: center; margin-bottom: 22px; }
.clock-status .status-label { font-size: 14px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 7px; }
.clock-status .timer { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.clock-button {
  display: block;
  width: 100%;
  padding: 24px;
  font-size: 21px;
  font-weight: 800;
  border-radius: var(--radius-lg);
  border: none;
  color: #fff;
  background: var(--status-working);
  margin-bottom: 12px;
  box-shadow: var(--shadow-md);
  letter-spacing: 0.01em;
}
.clock-button.stop { background: var(--status-late); }
.clock-button.break { background: var(--status-break); }
.clock-button:hover { opacity: 0.94; }

.employee-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.employee-stats .estat { background: var(--surface); border-radius: var(--radius-md); padding: 12px; text-align: center; border: 1px solid var(--border-soft); }
.employee-stats .estat .value { font-size: 17px; font-weight: 800; }
.employee-stats .estat .label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(20,20,30,0.05);
  z-index: 40;
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: var(--radius-sm);
}
.bottom-nav a .bn-icon { font-size: 20px; }
.bottom-nav a.active { color: var(--primary); }

/* Samma visuella språk som .bottom-nav, men bara synlig under mobil-brytpunkten
   — admin-skalets sidomeny används på desktop, den här ersätter den på mobil
   så man aldrig behöver dra sidled för att nå ett menyval. */
.admin-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border-soft);
  justify-content: space-around;
  padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(20,20,30,0.05);
  z-index: 40;
}
.admin-bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  flex: 1;
  min-width: 0;
}
.admin-bottom-nav a .icon { font-size: 19px; }
.admin-bottom-nav a.active { color: var(--primary); }

.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

.btn.help-btn { width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 1px solid var(--border); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.btn.help-btn:hover { background: var(--surface-2); }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-soft); padding: 10px 14px; display: flex; flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar nav { display: none; }
  .sidebar-footer { margin-top: 0; }
  .sidebar-footer form { width: auto; }
  .sidebar-footer .btn { width: auto !important; padding: 6px 14px !important; }
  .admin-bottom-nav { display: flex; }
  .main { padding: 20px 16px 90px; }
  .search-box input { width: 140px; }

  /* admin-bottom-nav har 5 lika breda flikar (space-around/flex:1) — "Mer" är
     den sista och tar upp de högra 20% av bredden. Knappen placeras precis
     utanför den zonen istället för att flyta ovanpå den, så den aldrig
     täcker en flik. */
  .quick-action-fab { right: 22%; bottom: 8px; width: 48px; height: 48px; font-size: 22px; }
  .quick-menu { right: 4%; bottom: 66px; }
}
