/**
 * KOSCE dashboard shell — layout aligned with ABA Applied exam-dashboard;
 * palette: deep teal / slate (not ABA navy / blue).
 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

.kosce-dash-view {
  --kosce-shell: #0f2421;
  --kosce-shell-mid: #1a3330;
  --kosce-shell-elevated: #243d38;
  --kosce-accent: #14b8a6;
  --kosce-accent-deep: #0f766e;
  --kosce-gold: #c9a227;
  --kosce-text-on-dark: rgba(255, 255, 255, 0.94);
  --kosce-muted: rgba(255, 255, 255, 0.52);
  --kosce-border-light: rgba(255, 255, 255, 0.1);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--kosce-shell);
}

/* === Header (same bar feel as ABA .aba-header) === */
.kosce-dash-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 64px;
  padding: 0 24px 0 20px;
  background: var(--kosce-shell);
  color: #fff;
  border-bottom: 1px solid var(--kosce-border-light);
  position: relative;
  z-index: 50;
}

.kosce-dash-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.kosce-dash-logo-img {
  display: block;
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
}

.kosce-dash-brand-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--kosce-text-on-dark);
}

.kosce-dash-brand-sub {
  font-size: 12px;
  color: var(--kosce-muted);
  margin-top: 1px;
}

.kosce-dash-header-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Provflöde (runner): dörrnummer centrerat och tydligt — endast när titel börjar med "Dörr " */
#kosce-runner-header-arrival.kosce-dash-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

#kosce-runner-header-arrival .kosce-dash-brand {
  grid-column: 1;
  justify-self: start;
  min-width: 0;
}

#kosce-runner-header-arrival .kosce-dash-header-center {
  grid-column: 2;
  justify-self: center;
  text-align: center;
  min-width: 0;
  max-width: min(92vw, 520px);
}

#kosce-runner-header-arrival .kosce-dash-header-tools {
  grid-column: 3;
  justify-self: end;
}

#kosce-runner-header-arrival .kosce-dash-brand-sub:empty {
  display: none;
}

.kosce-header-door-num {
  display: block;
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Hamburger — hidden on desktop */
.kosce-sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-left: 4px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}

.kosce-sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.kosce-sidebar-overlay {
  display: none;
}

.kosce-sidebar-close {
  display: none;
}

/* === Layout: sidebar + main === */
.kosce-dash-layout {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* === Sidebar (ABA .aba-dashboard-sidebar) === */
.kosce-dash-sidebar {
  width: 280px;
  min-width: 260px;
  flex-shrink: 0;
  background: var(--kosce-shell-mid);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--kosce-border-light);
  position: relative;
  z-index: 40;
}

.kosce-sidebar-history {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px;
}

.kosce-sidebar-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--kosce-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
}

.kosce-dash-footnote {
  flex-shrink: 0;
  padding: 0 14px 12px;
  font-size: 11px !important;
  line-height: 1.4 !important;
  color: var(--kosce-muted) !important;
  margin: 0 !important;
}

.kosce-sidebar-user-wrap {
  flex-shrink: 0;
  border-top: 1px solid var(--kosce-border-light);
}

.kosce-sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.kosce-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--kosce-shell-elevated);
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kosce-user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kosce-user-name {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.95);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kosce-user-tier {
  font-size: 11px;
  color: var(--kosce-muted);
}

.kosce-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  line-height: 1.35;
  padding-right: 4px;
}

.kosce-history-row {
  padding: 10px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.88);
}

.kosce-history-row + .kosce-history-row {
  margin-top: 0;
  border-top: 0;
}

/* === Main column === */
.kosce-dash-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #0a1815;
}

.kosce-dash-main-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #0f1f1c;
}

.kosce-dash-main-bg .kosce-dash-hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.kosce-dash-main-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.kosce-dash-main-scanlines {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.kosce-dash-content {
  position: relative;
  z-index: 3;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* Dikey orta; taşmada üstten kaydır (safe, där det stöds) */
  justify-content: center;
  justify-content: safe center;
  padding: 16px 16px 20px;
}

.kosce-dash-section {
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0;
}

.kosce-dash-heading {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0 0 2px;
  text-align: center;
  flex-shrink: 0;
}

.kosce-dash-subheading {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  margin: 0 auto 8px;
  line-height: 1.4;
  text-align: center;
  flex-shrink: 0;
  max-width: 520px;
}

.kosce-dash-subheading--tight {
  margin-top: -8px;
  margin-bottom: 10px;
  font-size: 11px;
  opacity: 0.9;
}

.kosce-dash-section-kicker {
  width: 100%;
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.55);
  text-align: center;
}

/* Rutnät + startknapp som ett kompakt block */
.kosce-dash-modes-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

/* Controls stack */
.kosce-dash-controls-stack {
  width: 100%;
  margin-bottom: 14px;
}

.kosce-dash-course-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.kosce-dash-field-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(255, 255, 255, 0.55);
}

.kosce-dash-field-label--case {
  margin-top: 4px;
}

.kosce-dash-select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: inherit;
  font-size: 14px;
}

.kosce-dash-select option {
  background: #1a2e2a;
  color: #fff;
}

.kosce-dash-topic-panel {
  margin-top: 0;
}

.kosce-dash-topic-hint {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
}

.kosce-dash-topic-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: clamp(80px, 16vh, 160px);
  overflow-y: auto;
  padding-right: 4px;
}

.kosce-dash-topic-pill {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
}

.kosce-dash-topic-list label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.kosce-dash-topic-list label:hover {
  border-color: rgba(20, 184, 166, 0.45);
  background: rgba(20, 184, 166, 0.08);
}

.kosce-dash-topic-list input[type="radio"] {
  margin-top: 3px;
}

.kosce-dash-topic-hint--inline {
  margin: 4px 0 4px;
  font-size: 11px;
}

/* Träning: fall-lista växer nedåt när lektion valts; scroll vid många fall */
.kosce-training-case-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
  overflow: visible;
}

.kosce-dash-topic-list--training-cases {
  min-height: 0;
  flex: 0 1 auto;
  max-height: min(42vh, 280px);
  overflow-y: auto;
  padding-right: 4px;
}

/* Card grid — kompakt; extra utrymme fyller inte raderna */
.kosce-dash-cards-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 6px 8px;
  align-content: start;
  align-items: start;
  flex: 0 0 auto;
  min-height: 0;
}

.kosce-dash-mode-card {
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  color: inherit;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  min-height: 0;
}

.kosce-dash-mode-card--exam {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 8px 10px 10px;
  gap: 6px;
  cursor: default;
  font-family: inherit;
}

.kosce-exam-card-select-hit {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-radius: 8px;
  margin: -2px -4px 0;
  padding: 2px 4px;
  outline: none;
  flex-shrink: 0;
}

/* Rubrikrad: titel vänster, Starta prov höger */
.kosce-dash-card-head-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 10px;
  width: 100%;
  min-width: 0;
}

.kosce-dash-card-head-main {
  flex: 1 1 auto;
  min-width: 0;
}

.kosce-dash-card-head-main .kosce-exam-card-select-hit,
.kosce-dash-card-head-main .kosce-training-card-head {
  width: 100%;
}

.kosce-dash-card-head-row .kosce-dash-card-start-btn {
  flex: 0 0 auto;
  align-self: center;
  min-width: 0;
  max-width: min(160px, 46%);
  padding: 7px 12px;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
  position: relative;
  z-index: 2;
  pointer-events: auto;
}

.kosce-exam-card-select-hit:hover,
.kosce-exam-card-select-hit:focus-visible {
  background: rgba(255, 255, 255, 0.06);
}

.kosce-dash-mode-card--exam:hover,
.kosce-dash-mode-card--exam:focus-within {
  border-color: rgba(255, 255, 255, 0.14);
}

.kosce-dash-mode-card--exam.kosce-dash-mode-card--selected {
  transform: none;
}

.kosce-dash-mode-card--selected {
  border-color: rgba(20, 184, 166, 0.55);
  box-shadow: 0 0 0 1px rgba(20, 184, 166, 0.35), 0 8px 28px rgba(0, 0, 0, 0.35);
  background: rgba(0, 0, 0, 0.42);
}

.kosce-dash-mode-card--training {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  gap: 8px;
  cursor: default;
  align-self: start;
  width: 100%;
  min-height: 0;
}

.kosce-dash-mode-card--training.kosce-dash-mode-card--selected {
  cursor: default;
}

.kosce-training-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  cursor: pointer;
}

.kosce-dash-mode-card--training .kosce-training-card-head:hover {
  opacity: 0.95;
}

.kosce-training-card-fields {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kosce-training-card-fields .kosce-dash-field-label {
  margin-top: 2px;
}

/* Kompakt provfilter inuti provkort (år / ort / månad) */
.kosce-exam-filter-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: flex-end;
  width: 100%;
  min-width: 0;
}

.kosce-exam-filter-inline__item {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kosce-exam-filter-inline__lbl {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.2;
  white-space: nowrap;
}

.kosce-exam-filter-inline__sel {
  width: 100%;
  max-width: 100%;
  font-size: 11px;
  line-height: 1.3;
  padding: 4px 6px;
  min-height: 28px;
  box-sizing: border-box;
}

.kosce-exam-filter-inline__hint {
  margin: 0;
  min-height: 0;
  font-size: 10px;
  line-height: 1.25;
  color: rgba(248, 113, 113, 0.95);
}

.kosce-dash-mode-card--exam .kosce-exam-type-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  font-size: 13px;
  line-height: 32px;
}

.kosce-dash-mode-card--exam .kosce-exam-type-name {
  font-size: 12px;
}

.kosce-dash-mode-card--exam .kosce-exam-type-desc {
  font-size: 9px;
  line-height: 1.25;
}

.kosce-dash-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 0;
  flex-shrink: 0;
}

/*
 * Primär startknapp — minimalist: tunn typografi, liten radie, ingen skugga.
 */
.kosce-dash-start-btn {
  width: auto;
  min-width: 200px;
  max-width: 100%;
  padding: 10px 24px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.35;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
}

.kosce-dash-start-btn:not(:disabled) {
  background: #1c1e21;
  color: #f8fafc;
}

.kosce-dash-start-btn:hover:not(:disabled) {
  color: #fff;
  background: #2a2d32;
}

.kosce-dash-start-btn:active:not(:disabled) {
  color: #fff;
  background: #141517;
}

.kosce-dash-start-btn:focus-visible {
  color: #fff;
  outline: 1px solid rgba(255, 255, 255, 0.35);
  outline-offset: 2px;
}

.kosce-dash-start-btn:focus-visible:not(:disabled) {
  background: #1c1e21;
}

.kosce-dash-start-btn:disabled {
  cursor: not-allowed;
  background: rgba(51, 65, 85, 0.4);
  color: rgba(226, 232, 240, 0.4);
  border-color: transparent;
}

.kosce-exam-type-icon {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 36px;
  text-align: center;
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.kosce-exam-type-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kosce-exam-type-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.98);
}

.kosce-exam-type-desc {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.3;
}

.kosce-dash-fieldset {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
}

.kosce-practice-opts {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px dashed rgba(20, 184, 166, 0.45);
  border-radius: 10px;
  font-size: 13px;
  width: 100%;
  max-width: 720px;
  box-sizing: border-box;
}

.kosce-practice-opts legend {
  padding: 0 8px;
  color: var(--kosce-accent);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kosce-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
}

.kosce-hidden {
  display: none !important;
}

/* Mobile: slide-in sidebar */
@media (max-width: 900px) {
  .kosce-sidebar-toggle {
    display: flex;
  }

  .kosce-sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .kosce-dash-view.kosce-sidebar-open .kosce-sidebar-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .kosce-dash-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: none;
  }

  .kosce-dash-view.kosce-sidebar-open .kosce-dash-sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }

  .kosce-sidebar-close {
    display: flex;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    z-index: 2;
  }

  .kosce-sidebar-close:hover {
    background: rgba(255, 255, 255, 0.18);
  }

  .kosce-sidebar-history {
    padding-top: 52px;
  }

  .kosce-dash-header {
    padding: 8px 12px;
    height: auto;
    min-height: 56px;
  }

  .kosce-dash-brand-title {
    font-size: 14px;
  }

  .kosce-dash-cards-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    max-height: none;
  }

  .kosce-dash-content {
    overflow-y: auto;
    justify-content: center;
    justify-content: safe center;
    padding: 12px 14px 28px;
  }
}

/* Admin: snabbnavigation till simulatorvyer */
.kosce-dash-admin-preview {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kosce-dash-subheading--admin {
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 14px !important;
}

.kosce-admin-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kosce-admin-preview-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(201, 162, 39, 0.45);
  background: rgba(201, 162, 39, 0.12);
  color: rgba(255, 248, 220, 0.96);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.kosce-admin-preview-btn:hover,
.kosce-admin-preview-btn:focus-visible {
  background: rgba(201, 162, 39, 0.22);
  border-color: rgba(243, 212, 128, 0.55);
  outline: none;
}
