/* Caesar AI Incident Atlas — Functional MVP Styles (T013) */

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

:root {
  --bg:       #0f1117;
  --surface:  #181c25;
  --border:   #252a38;
  --border-hi:#353c52;
  --text:     #e2e5ef;
  --muted:    #7a82a0;
  --accent:   #4f7cff;
  --accent-hi:#7096ff;
  --crit:     #e05c5c;
  --high:     #e08c3a;
  --med:      #d4b240;
  --low:      #50a87a;
  --conf-hi:  #50a87a;
  --conf-med: #d4b240;
  --conf-low: #e05c5c;
  --draft:    #8b5cf6;
  --radius:   8px;
  --radius-sm:4px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Cascadia Code", "Consolas", monospace;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ── */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header .logo {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text);
  text-decoration: none;
}

.app-header .logo span { color: var(--accent); }

.header-meta {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  line-height: 1.4;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 56px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
}

.main {
  padding: 1.75rem 2rem;
  max-width: 1100px;
}

/* ── Sidebar filters ── */
.filter-section { margin-bottom: 1.5rem; }

.filter-section h3 {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.filter-group { display: flex; flex-direction: column; gap: 0.3rem; }

.filter-chip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text);
  user-select: none;
  transition: background 0.1s;
}

.filter-chip:hover { background: var(--border); }
.filter-chip.active { background: rgba(79,124,255,0.15); color: var(--accent-hi); }

.filter-chip input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.chip-count {
  margin-left: auto;
  font-size: 0.68rem;
  color: var(--muted);
  background: var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  min-width: 18px;
  text-align: center;
}

.filter-reset {
  margin-top: 1rem;
  width: 100%;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-reset:hover {
  border-color: var(--border-hi);
  color: var(--text);
}

/* ── Status bar ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.status-bar h2 {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
}

.status-bar .count {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Incident list ── */
#incident-list { display: flex; flex-direction: column; gap: 0.75rem; }

.incident-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.incident-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.incident-card.open {
  border-color: var(--accent);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.inc-id {
  font-family: var(--font-mono);
  font-size: 0.73rem;
  color: var(--muted);
  background: var(--border);
  padding: 2px 7px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
  flex: 1;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
}

.badge-sector   { background: rgba(79,124,255,0.12); color: #7096ff; border: 1px solid rgba(79,124,255,0.2); }
.badge-draft    { background: rgba(139,92,246,0.12); color: #a78bfa; border: 1px solid rgba(139,92,246,0.25); }
.badge-fm       { background: rgba(255,255,255,0.04); color: var(--muted); border: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.67rem; }
.badge-date     { background: transparent; color: var(--muted); border: none; font-size: 0.72rem; padding: 2px 0; }

.badge-sev-critical { background: rgba(224,92,92,0.15);  color: #ef8080; border: 1px solid rgba(224,92,92,0.25); }
.badge-sev-high     { background: rgba(224,140,58,0.15); color: #f0a64a; border: 1px solid rgba(224,140,58,0.25); }
.badge-sev-medium   { background: rgba(212,178,64,0.15); color: #e0c050; border: 1px solid rgba(212,178,64,0.25); }
.badge-sev-low      { background: rgba(80,168,122,0.15); color: #60c090; border: 1px solid rgba(80,168,122,0.25); }

.badge-conf-high    { background: rgba(80,168,122,0.12);  color: #60c090; border: 1px solid rgba(80,168,122,0.2); }
.badge-conf-medium  { background: rgba(212,178,64,0.12);  color: #e0c050; border: 1px solid rgba(212,178,64,0.2); }
.badge-conf-low     { background: rgba(224,92,92,0.12);   color: #ef8080; border: 1px solid rgba(224,92,92,0.2); }

.badge-caution { background: rgba(212,178,64,0.1); color: #c8a830; border: 1px solid rgba(212,178,64,0.25); font-size: 0.67rem; }

/* ── Card detail (expanded) ── */
.card-detail {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  display: none;
}

.card-detail.visible { display: block; }

.detail-section { margin-bottom: 1rem; }

.detail-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.detail-text {
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.65;
}

.detail-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.detail-list li {
  font-size: 0.81rem;
  color: var(--text);
  padding-left: 0.9rem;
  position: relative;
  line-height: 1.5;
}

.detail-list li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--muted);
}

.detail-list li.lesson::before { content: "→"; color: var(--accent); }

/* Controls row */
.controls-row { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.badge-ctl {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(79,124,255,0.08);
  color: var(--accent);
  border: 1px solid rgba(79,124,255,0.15);
  padding: 2px 7px;
  border-radius: 3px;
}

/* Sources */
.source-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.4rem;
}

.source-item a {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
}

.source-item a:hover { text-decoration: underline; color: var(--accent-hi); }

.source-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.source-type-badge {
  font-size: 0.67rem;
  background: var(--border);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 3px;
}

.source-accessed {
  font-size: 0.67rem;
  color: var(--muted);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.empty-state p { font-size: 0.88rem; }

/* ── Notice banner ── */
.notice-banner {
  background: rgba(212,178,64,0.08);
  border: 1px solid rgba(212,178,64,0.2);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.75rem;
  color: #c8a830;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

/* ── Loading ── */
#loading {
  text-align: center;
  padding: 4rem;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Screen-reader only ── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Header search ── */
.header-search {
  flex: 1;
  max-width: 380px;
  margin: 0 1rem;
}

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-family: var(--font);
  padding: 0.38rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--accent); }

/* ── Status panel ── */
.status-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  margin-bottom: 0.75rem;
  min-height: 32px;
}

.sp-label { font-weight: 600; color: var(--text); margin-right: 0.2rem; }
.sp-sep   { color: var(--border-hi); }
.sp-caution { color: #c8a830; }

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.sort-label {
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.sort-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.78rem;
  font-family: var(--font);
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.sort-select:focus { border-color: var(--accent); }

/* ── Active filter chips ── */
.active-chips-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.active-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(79,124,255,0.15);
  color: var(--accent-hi);
  border: 1px solid rgba(79,124,255,0.25);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s;
}

.active-chip:hover  { background: rgba(79,124,255,0.25); }
.active-chip:focus  { outline: 2px solid var(--accent); outline-offset: 1px; }
.active-chip span   { color: var(--muted); font-size: 0.85rem; line-height: 1; }

/* ── Card toggle hint ── */
.card-toggle-hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.45rem;
  user-select: none;
}

/* ── Copy link button ── */
.copy-link-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-size: 0.78rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.12s;
  line-height: 1.5;
  font-family: var(--font);
}

.copy-link-btn:hover  { border-color: var(--border-hi); color: var(--text); }
.copy-link-btn:focus  { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Detail enhancements ── */
.detail-muted { color: var(--muted); font-size: 0.78rem; }

.inline-draft {
  font-size: 0.72rem;
  color: #a78bfa;
  background: rgba(139,92,246,0.1);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 0.3rem;
}

.caveat-list li { color: #c8a830; }
.caveat-list li::before { color: #c8a830; content: "⚠"; }

/* Source enhancements */
.source-num {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.1rem;
}

.source-caution-note {
  font-size: 0.67rem;
  color: #c8a830;
  background: rgba(212,178,64,0.08);
  padding: 1px 6px;
  border-radius: 3px;
}

/* ── Error state ── */
.error-state {
  display: block;
  background: rgba(224,92,92,0.1);
  border: 1px solid rgba(224,92,92,0.25);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  color: #ef8080;
  font-size: 0.83rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Focus styles ── */
.incident-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .main { padding: 1.25rem; }
  .app-header { padding: 0 1.25rem; }
  .header-search { max-width: none; margin: 0; }
  .toolbar { flex-direction: column; align-items: flex-start; }
}
