/* ── GitHub Pages additions ─────────────────────────────────────────────── */

/* Welcome screen */
.welcome-card {
  max-width: 520px;
  text-align: center;
  padding: 40px 36px;
}
.welcome-logo {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.5px;
  margin-bottom: 8px;
}
.welcome-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 36px;
  line-height: 1.6;
}
.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  width: 100%;
}
.welcome-divider {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0;
}
.btn-lg {
  width: 100%;
  justify-content: center;
  padding: 12px 24px;
  font-size: 15px;
}
.btn-file-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.welcome-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 28px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  font-size: 12.5px;
  color: #78350f;
  line-height: 1.6;
}
.note-icon { font-size: 18px; flex-shrink: 0; }

/* Save button — pulsing yellow when unsaved changes */
.btn-save {
  background: var(--success);
  color: #fff;
  border-color: transparent;
  position: relative;
}
.btn-save:hover { background: #15803d; }
.btn-save.has-changes {
  background: var(--warning);
  animation: pulse-save 2s ease-in-out infinite;
}
@keyframes pulse-save {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217,119,6,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(217,119,6,0); }
}

/* Unsaved badge in header */
.unsaved-badge {
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: 99px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --primary:        #2563eb;
  --primary-h:      #1d4ed8;
  --success:        #16a34a;
  --warning:        #d97706;
  --danger:         #dc2626;
  --purple:         #7c3aed;
  --muted:          #94a3b8;

  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --text-2:         #64748b;

  --sidebar-bg:     #0f172a;
  --sidebar-hover:  #1e293b;
  --sidebar-active: #1d4ed8;
  --sidebar-text:   #94a3b8;
  --sidebar-text-h: #f1f5f9;

  --header-h:       56px;
  --sidebar-w:      268px;
  --radius:         8px;
  --radius-sm:      5px;
  --shadow:         0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:      0 10px 15px -3px rgba(0,0,0,.12);
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
textarea, input, select, button { font-family: inherit; font-size: inherit; }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Loading screen ─────────────────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: var(--text-2);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── App shell ──────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; }

/* ── Header ─────────────────────────────────────────────────────────────── */
#header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.hd-left  { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hd-center { flex: 1; display: flex; align-items: center; justify-content: center; }
.hd-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.logo {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  letter-spacing: -.3px;
}

.hd-session {
  font-size: 13px;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: 20px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Global progress bar in header */
.hd-progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-2);
}
.hd-bar-outer {
  width: 160px;
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.hd-bar-inner {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .3s ease;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-filters {
  padding: 12px 14px 8px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chk-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 0;
  user-select: none;
}
.chk-label:hover { color: var(--sidebar-text-h); }
.chk-label input[type="checkbox"] { cursor: pointer; accent-color: var(--primary); }

.process-list { padding: 8px 0; flex: 1; }

.process-item {
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
  border-left: 3px solid transparent;
}
.process-item:hover { background: var(--sidebar-hover); }
.process-item.active {
  background: #1e3a5f;
  border-left-color: var(--primary);
}

.process-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.process-code {
  font-size: 11px;
  font-weight: 700;
  background: #1e293b;
  color: #7dd3fc;
  padding: 1px 6px;
  border-radius: 3px;
  letter-spacing: .5px;
}
.process-item.active .process-code { background: #1d4ed8; color: #fff; }

.process-progress-text {
  font-size: 11px;
  color: var(--sidebar-text);
}

.process-name {
  font-size: 12px;
  color: var(--sidebar-text);
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.process-item.active .process-name,
.process-item:hover .process-name { color: var(--sidebar-text-h); }

.proc-bar-outer {
  height: 4px;
  background: #1e293b;
  border-radius: 99px;
  overflow: hidden;
}
.proc-bar-inner {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width .3s ease;
}

.proc-bar-inner.full  { background: var(--success); }
.proc-bar-inner.half  { background: var(--warning); }

.proc-dot-row {
  display: flex;
  gap: 2px;
  margin-top: 4px;
}
.proc-dot {
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: #1e293b;
}
.proc-dot.compliant     { background: var(--success); }
.proc-dot.partial       { background: var(--warning); }
.proc-dot.non-compliant { background: var(--danger); }
.proc-dot.na            { background: var(--purple); }

/* ALL processes item */
.process-item-all {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  font-size: 12px;
  font-weight: 600;
  transition: background .15s;
}
.process-item-all:hover { background: var(--sidebar-hover); color: var(--sidebar-text-h); }
.process-item-all.active { background: #1e3a5f; color: var(--sidebar-text-h); }

/* ── Main content ────────────────────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Question card ───────────────────────────────────────────────────────── */
.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.qcard-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.qcard-body   { padding: 20px; border-bottom: 1px solid var(--border); }
.qcard-answer { padding: 20px; }

.q-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 14px;
}

/* Collapsible sections */
.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.collapsible-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-align: left;
  transition: background .15s;
}
.collapsible-toggle:hover { background: #e8edf4; }
.collapsible-toggle .arrow { transition: transform .2s; font-style: normal; font-size: 10px; }
.collapsible-toggle.open .arrow { transform: rotate(180deg); }
.collapsible-content {
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-2);
  background: var(--surface);
  white-space: pre-wrap;
  line-height: 1.6;
  display: none;
}
.collapsible-content.open { display: block; }

/* Answer form */
.answer-section { display: flex; flex-direction: column; gap: 14px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: vertical;
  min-height: 90px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
}
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-row { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; }

/* Compliance radio buttons */
.compliance-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.comp-btn {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  transition: all .15s;
  white-space: nowrap;
}
.comp-btn:hover { border-color: var(--text-2); color: var(--text); }
.comp-btn.active[data-value="not_checked"]   { border-color: var(--muted);    background: #f1f5f9; color: var(--text); }
.comp-btn.active[data-value="compliant"]     { border-color: var(--success);  background: #f0fdf4; color: var(--success); }
.comp-btn.active[data-value="partial"]       { border-color: var(--warning);  background: #fffbeb; color: var(--warning); }
.comp-btn.active[data-value="non_compliant"] { border-color: var(--danger);   background: #fef2f2; color: var(--danger); }
.comp-btn.active[data-value="na"]            { border-color: var(--purple);   background: #f5f3ff; color: var(--purple); }

/* Score stars */
.score-group { display: flex; gap: 4px; }
.star-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #d1d5db;
  line-height: 1;
  padding: 0 2px;
  transition: color .1s, transform .1s;
}
.star-btn:hover,
.star-btn.active { color: #f59e0b; }
.star-btn:hover  { transform: scale(1.15); }

/* Review flag */
.review-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.review-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface);
  transition: all .15s;
  user-select: none;
}
.review-toggle:hover { border-color: var(--warning); color: var(--warning); }
.review-toggle.flagged { border-color: var(--warning); background: #fffbeb; color: var(--warning); }

.answer-timestamps {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  gap: 16px;
  padding-top: 4px;
}

/* Save indicator */
.save-indicator {
  font-size: 11px;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity .3s;
}
.save-indicator.visible { opacity: 1; }

/* ── Navigation bar ──────────────────────────────────────────────────────── */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-counter {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-process  { background: #dbeafe; color: #1d4ed8; }
.badge-mandatory { background: #fef2f2; color: #dc2626; }
.badge-optional  { background: #f1f5f9; color: #64748b; }
.badge-priority  { background: #fefce8; color: #a16207; }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge.not_checked   { background: #f1f5f9; color: #94a3b8; }
.status-badge.compliant     { background: #f0fdf4; color: #16a34a; }
.status-badge.partial       { background: #fffbeb; color: #d97706; }
.status-badge.non_compliant { background: #fef2f2; color: #dc2626; }
.status-badge.na            { background: #f5f3ff; color: #7c3aed; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-h); }

.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }

.btn-ghost  { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Table view ──────────────────────────────────────────────────────────── */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.table-toolbar h2 { font-size: 16px; font-weight: 600; }

.answers-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  font-size: 13px;
}
.answers-table th {
  padding: 10px 14px;
  text-align: left;
  background: var(--bg);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.answers-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.answers-table tr:last-child td { border-bottom: none; }
.answers-table tr:hover td { background: #f8fafc; }
.answers-table tr { cursor: pointer; }

.td-q-text {
  max-width: 340px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.td-meta { color: var(--text-2); font-size: 11px; }
.flag-icon { font-size: 14px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 96vw;
  max-height: 86vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
}

.session-list { padding: 12px 24px; display: flex; flex-direction: column; gap: 8px; }

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.session-item:hover { border-color: var(--primary); background: #eff6ff; }
.session-item.active { border-color: var(--primary); background: #eff6ff; }

.session-item-info { flex: 1; min-width: 0; }
.session-item-name { font-weight: 600; font-size: 14px; color: var(--text); }
.session-item-meta { font-size: 11px; color: var(--text-2); margin-top: 2px; }

.session-item-progress { text-align: right; flex-shrink: 0; margin-left: 12px; }
.session-prog-num  { font-size: 13px; font-weight: 700; color: var(--primary); }
.session-prog-pct  { font-size: 11px; color: var(--text-2); }

.new-session-form {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.new-session-form input,
.new-session-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--surface);
  resize: vertical;
}
.new-session-form input:focus,
.new-session-form textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-2);
  text-align: center;
  gap: 10px;
}
.empty-state .empty-icon { font-size: 40px; }
.empty-state p { font-size: 14px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast-area {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 500;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  max-width: 300px;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { background: #16a34a; }
.toast.error   { background: #dc2626; }
.toast.info    { background: #2563eb; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
