/* ═══════════════════════════════════════════════════
   MyTCRPlus Enterprise Suite v7.0 — Stylesheet
   Apple-style light design system. Single source of truth.
   No !important carpet-bombing.
   Body prefix (0,1,1) beats Tailwind utilities (0,1,0).
═══════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────── */
:root {
  /* Brand (accent) — a fill color: pairs with --brand-on for buttons/badges.
     --brand-text is a darker shade of the same hue for foreground use
     (links, active nav text, icons) where the bright fill fails contrast
     on a light surface. */
  --brand-primary:  #99c432;
  --brand-hover:    #86ad2b;
  --brand-press:    #739625;
  --brand-subtle:   rgba(153, 196, 50, 0.12);
  --brand-on:       #1a1a1a;
  --brand-text:     #54701b;

  /* Backgrounds */
  --bg-main:    #ffffff;
  --bg-card:    #fafafa;
  --bg-sidebar: #fafafa;
  --bg-header:  rgba(255, 255, 255, 0.92);
  --bg-hover:   rgba(0, 0, 0, 0.035);
  --bg-active:  rgba(153, 196, 50, 0.12);

  /* Text */
  --text-primary:   #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted:     #6b6b70;

  /* Borders */
  --border:       rgba(0, 0, 0, 0.12);
  --border-light: rgba(0, 0, 0, 0.07);

  /* Status (light-mode semantic — distinct from the brand accent, which
     is reserved for actions; "compliant" no longer aliases brand green) */
  --status-error:    #c62828;
  --status-error-bg: rgba(198, 40, 40, 0.08);
  --status-warn:     #7a5300;
  --status-warn-bg:  rgba(217, 119, 6, 0.10);
  --status-ok:       #2e7d32;
  --status-ok-bg:    rgba(46, 125, 50, 0.08);

  /* Type */
  --font-sans: 'Geist Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Shadows — one soft card shadow, used sparingly on floating surfaces
     (dropdowns, modals); flat hairline borders do most of the separation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.10);

  /* Transitions */
  --transition-base: 0.15s ease;
}

/* ── App shell ──────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-primary);
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

code, pre, kbd, samp,
.font-mono, [class*="font-mono"] {
  font-family: var(--font-mono);
}

#app-body  { height: calc(100dvh - 64px); }
#app-content { scroll-behavior: smooth; position: relative; }

/* ── Animations ─────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}
@keyframes slideOut {
  from { transform: translateX(0);   opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* ── Header ─────────────────────────────────────── */
header.fixed,
body > header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Tool search */
#toolSearchWrap {
  display: none;
  align-items: center;
  width: 200px;
  height: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0 10px;
  gap: 8px;
}
@media (min-width: 768px) { #toolSearchWrap { display: flex; } }

#toolSearch {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font: 400 13px var(--font-sans);
  padding: 0;
}
#toolSearch:focus { outline: none; }
#toolSearch::placeholder { color: var(--text-muted); }

#toolSearchWrap .kbd,
kbd {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font: 500 10px var(--font-mono);
  color: var(--text-muted);
}

/* ── Sidebar ─────────────────────────────────────── */
#sidebar-menu {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
}

.sidebar-label {
  color: var(--text-muted);
  font-family: var(--font-sans);
}

/* Nav group labels */
.nav-group-label {
  padding: 12px 12px 3px;
  font: 700 9px var(--font-sans);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  user-select: none;
}

/* Nav items */
.nav-item {
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition-base);
}

.nav-item:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--bg-active);
  color: var(--brand-text);
  border-left-color: var(--brand-primary);
}

/* Nav "NEW" badge — class-based, no inline styles */
.nav-badge {
  display: inline-flex;
  align-items: center;
  font: 700 8px var(--font-sans);
  letter-spacing: 0.05em;
  padding: 1px 5px;
  border: 1px solid rgba(153, 196, 50, 0.5);
  border-radius: 4px;
  color: var(--brand-text);
  flex-shrink: 0;
  line-height: 1.5;
}

/* Sidebar collapse */
.sidebar-collapsed #sidebar-menu { width: 4rem; }
.sidebar-collapsed #sidebar-menu .sidebar-label,
.sidebar-collapsed #sidebar-menu .nav-text,
.sidebar-collapsed #sidebar-menu .nav-group-label { display: none; }
.sidebar-collapsed #sidebar-menu .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar-collapsed #sidebar-menu .nav-item i { margin-right: 0; font-size: 1.125rem; }
.sidebar-collapsed #app-content { margin-left: 4rem; }
.sidebar-collapsed #sidebar-menu::-webkit-scrollbar { width: 0; }

/* ── Main content ───────────────────────────────── */
#app-content, main {
  background: var(--bg-main);
}

/* ── Tool sections ──────────────────────────────── */
.tool-section {
  display: none;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.tool-section.active { display: block; }

/* Tool section header — subtle lift from card body */
.tool-section > .border-b {
  background: rgba(0, 0, 0, 0.015);
  border-bottom: 1px solid var(--border-light);
}

/* ── Buttons ─────────────────────────────────────── */
button,
.btn,
[type="button"],
[type="submit"] {
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 14px;
}

/* Primary: brand green */
.btn-primary {
  background: var(--brand-primary);
  color: var(--brand-on);
  border: 1px solid var(--brand-primary);
  font-weight: 600;
}
.btn-primary:hover { background: var(--brand-hover); }

/* Secondary: outlined */
.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-secondary:hover { border-color: rgba(0, 0, 0, 0.3); }

/* Ghost: text only */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
}
.btn-ghost:hover { color: var(--text-primary); }

/* Legacy btn-brand */
.btn-brand {
  background: var(--brand-primary);
  color: var(--brand-on);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition-base);
}
.btn-brand:hover { background: var(--brand-hover); transform: translateY(-1px); }
.btn-brand:active { transform: scale(0.98); }

/* Interactive press state */
button:not(.no-press):active,
.nav-item:active,
.option-card:active,
.provider-card:active { transform: scale(0.97); }

/* ── Tailwind button overrides (body prefix = 0,1,1 > Tailwind 0,1,0) ── */
body button.bg-brand-600,
body button.bg-brand-700,
body button.bg-accent,
body a.bg-brand-600,
body button[class*="bg-brand"] {
  background: var(--brand-primary);
  color: var(--brand-on);
  border: 1px solid var(--brand-primary);
  font-weight: 600;
  font-size: 14px;
}

body button.bg-brand-600:hover,
body button.bg-brand-700:hover,
body button[class*="bg-brand"]:hover {
  background: var(--brand-hover);
}

body button.bg-white,
body button.border-slate-300 {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

body button.bg-slate-100,
body button.bg-slate-200 {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}

/* ── Inputs ──────────────────────────────────────── */
input, textarea, select {
  background: var(--bg-main);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: none;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--brand-primary);
  outline-offset: 0;
  border-color: var(--brand-primary);
  box-shadow: none;
}

/* ── Cards ───────────────────────────────────────── */
.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition-base);
}
.result-card:hover {
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.option-card {
  cursor: pointer;
  border: 1px solid var(--border);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  transition: var(--transition-base);
}
.option-card:hover {
  border-color: var(--brand-primary);
  background: var(--bg-main);
  transform: translateY(-1px);
}
.option-card.selected {
  border-color: var(--brand-primary);
  background: var(--brand-subtle);
}

.provider-card {
  cursor: pointer;
  border: 1px solid var(--border);
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  text-align: center;
  transition: var(--transition-base);
}
.provider-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.provider-card.selected {
  border-color: var(--brand-primary);
  background: var(--brand-subtle);
}

.radio-option {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text-primary);
}
.radio-option.selected {
  border-color: var(--brand-primary);
  background: var(--brand-subtle);
}

/* ── TCR violation cards ────────────────────────── */
.tcr-violation-card {
  background: var(--bg-card);
  border-left: 4px solid;
  border-radius: var(--radius-lg);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}
.tcr-violation-card.blocking {
  border-color: var(--status-error);
  background: var(--status-error-bg);
}
.tcr-violation-card.warning {
  border-color: var(--status-warn);
  background: var(--status-warn-bg);
}
.tcr-violation-card.compliant {
  border-color: var(--status-ok);
  background: var(--status-ok-bg);
}

/* ── Tier filters ───────────────────────────────── */
.tier-filter { cursor: pointer; }
.tier-filter.active {
  background: var(--brand-primary);
  color: var(--brand-on);
}

/* ── Tier badges ────────────────────────────────── */
.tier-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font: 700 11px var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tier-badge.high {
  background: rgba(46, 125, 50, 0.10);
  color: #2e7d32;
  border: 1px solid rgba(46, 125, 50, 0.3);
}
.tier-badge.medium {
  background: rgba(217, 119, 6, 0.10);
  color: #7a5300;
  border: 1px solid rgba(217, 119, 6, 0.3);
}
.tier-badge.low,
.tier-badge.very-low {
  background: rgba(198, 40, 40, 0.09);
  color: #c62828;
  border: 1px solid rgba(198, 40, 40, 0.25);
}

/* ── Progress bars ──────────────────────────────── */
.progress-bg {
  background: var(--border-light);
  border-radius: 999px;
  height: 0.5rem;
  overflow: hidden;
}
.progress-fill {
  background: var(--brand-primary);
  height: 100%;
  transition: width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Checklist grid ─────────────────────────────── */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

/* ── Sample message blocks ──────────────────────── */
.sample-message {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-primary);
  padding: 1rem;
  border-radius: var(--radius-md);
  font: 400 0.875rem/1.6 var(--font-mono);
  color: var(--text-secondary);
}

/* ── Alternative uses section ───────────────────── */
.alternative-uses {
  background: rgba(217, 119, 6, 0.07);
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-top: 1.5rem;
}
.alternative-uses h4 { color: #7a5300; font-weight: bold; margin-bottom: 0.75rem; }
.alternative-uses ul { list-style: disc; padding-left: 1.5rem; color: var(--text-secondary); }
.alternative-uses li { margin-bottom: 0.5rem; }

/* ── Question containers (wizard) ───────────────── */
.question-container { display: none; }
.question-container.active {
  display: block;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Auth gate ──────────────────────────────────── */
#authGate { display: none; }
html.auth-required #authGate { display: flex; }
html.auth-required body > *:not(#authGate):not(script):not(style) { display: none !important; }
html.auth-required, html.auth-required body { overflow: hidden; }

#authGate { background: var(--bg-main); }

#authGate > div {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ── Tables ─────────────────────────────────────── */
table { border-color: var(--border); }
th {
  background: var(--bg-card);
  color: var(--text-secondary);
  font: 700 11px var(--font-sans);
  letter-spacing: 0.04em;
  border-color: var(--border);
}
td { color: var(--text-primary); border-color: var(--border-light); }
tr:hover td { background: var(--bg-hover); }

/* ── Avatar dropdown ────────────────────────────── */
#avatarDropdown {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ── Quill editor ───────────────────────────────── */
.ql-toolbar, .ql-container {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
}
.ql-toolbar { border-bottom: 1px solid var(--border-light); }
.ql-editor { color: var(--text-primary); }
.ql-stroke { stroke: var(--text-secondary); }
.ql-fill { fill: var(--text-secondary); }

/* ── Toast notifications ────────────────────────── */
.notyf__toast {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ── Keyboard shortcut overlay ──────────────────── */
#kb-help-overlay > div {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
}

/* ── Tailwind utility overrides ─────────────────── */
/* body prefix (0,1,1) beats Tailwind CDN (0,1,0)    */
body .bg-white { background: var(--bg-card); }
body .bg-slate-50\/50 { background: rgba(0, 0, 0, 0.015); }

body .hover\:bg-slate-50:hover,
body .hover\:bg-slate-100:hover { background: var(--bg-hover); }

body .hover\:border-brand-500:hover,
body .hover\:border-brand-300:hover { border-color: var(--brand-primary); }

body .bg-brand-50,
body .bg-brand-100 { background: var(--brand-subtle); }

body .bg-red-50 { background: var(--status-error-bg); }
body .bg-green-50 { background: var(--status-ok-bg); }
body .bg-amber-50,
body .bg-yellow-50 { background: var(--status-warn-bg); }

body .text-red-700, body .text-red-500 { color: var(--status-error); }
body .text-green-700, body .text-green-600 { color: var(--status-ok); }

body .border-red-200 { border-color: rgba(198, 40, 40, 0.25); }
body .border-green-200 { border-color: rgba(46, 125, 50, 0.25); }
body .border-amber-200 { border-color: rgba(217, 119, 6, 0.25); }

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-main); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand-primary); }

/* ── Mobile ─────────────────────────────────────── */
@media (max-width: 640px) {
  .tool-section .p-6 { padding: 1rem; }
  .tool-section .border-b.p-6 { padding: 1rem; }
  .result-card { padding: 0.75rem; }
  table { font-size: 0.75rem; }
}
