/* =====================================================================
   RIA — REDESIGN LAYER
   Loaded after critical.css + style.css. Overrides tokens, layout,
   and cosmetic details. All existing JS continues to work unchanged.
   ===================================================================== */

/* ── Token overrides ─────────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --background-color: #09090b;
  --surface-color:    #111117;
  --surface-hover:    #18181f;
  --surface-elevated: #1f1f28;
  --bg-secondary:     #111117;

  --text-primary:   #ededef;
  --text-secondary: #a1a1aa;
  --text-muted:     #52525b;

  --border-color:  rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.11);

  --primary-color: #8b5cf6;
  --primary-hover: #7c3aed;
  --accent-color:  #22d3ee;

  --success-color: #34d399;
  --warning-color: #fbbf24;
  --danger-color:  #f87171;

  color-scheme: dark;
}

[data-theme="light"] {
  --background-color: #f8f8fa;
  --surface-color:    #ffffff;
  --surface-hover:    #f2f2f6;
  --surface-elevated: #eaeaf0;
  --bg-secondary:     #f2f2f6;

  --text-primary:   #09090b;
  --text-secondary: #52525b;
  --text-muted:     #a1a1aa;

  --border-color:  rgba(0,0,0,0.07);
  --border-strong: rgba(0,0,0,0.12);

  color-scheme: light;
}

/* ── Full-viewport layout ────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  display: flex !important;
  flex-direction: row !important;
  min-height: 100vh;
  overflow: hidden;
  /* Remove the dramatic ambient gradients */
  background-image: none !important;
  background-color: var(--background-color) !important;
}

/* Auth pages (login / register) — no sidebar, centered card */
body[data-layout="auth"] {
  display: block !important;
  overflow: auto;
}

/* Hide legacy chrome */
.navbar        { display: none !important; }
.bottom-nav    { display: none !important; }
.fab           { display: none !important; }
.skip-to-content { display: none !important; }

/* ── Sidebar shell ───────────────────────────────────────────────────── */
.ria-sidebar {
  width: 224px;
  flex-shrink: 0;
  background: var(--surface-color);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden;
  z-index: 40;
}

.ria-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.25rem 1rem 1.5rem;
  flex-shrink: 0;
}

.ria-sidebar-logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  flex-shrink: 0;
}

.ria-sidebar-wordmark { display: flex; flex-direction: column; gap: 1px; }
.ria-sidebar-logo-text {
  font-weight: 700;
  font-size: 0.925rem;
  letter-spacing: -0.025em;
  color: var(--text-primary);
  line-height: 1;
}
.ria-sidebar-logo-sub {
  font-size: 0.66rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* Nav links */
.ria-nav {
  flex: 1;
  padding: 0 0.5rem;
  overflow-y: auto;
}

.ria-nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.525rem 0.75rem;
  border-radius: 7px;
  margin-bottom: 2px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  font-size: 0.838rem;
  font-weight: 400;
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
  font-family: var(--font-sans);
  white-space: nowrap;
}

.ria-nav-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.ria-nav-item.active {
  background: var(--surface-elevated);
  color: var(--text-primary);
  font-weight: 600;
}

.ria-nav-item .ria-nav-icon { opacity: 0.55; flex-shrink: 0; }
.ria-nav-item.active .ria-nav-icon { opacity: 1; }

.ria-nav-badge {
  margin-left: auto;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 9999px;
  background: rgba(251,191,36,0.15);
  color: var(--warning-color);
  letter-spacing: 0.02em;
}

/* Bottom section */
.ria-sidebar-bottom {
  flex-shrink: 0;
  padding: 0.6rem 0.5rem 0.75rem;
  border-top: 1px solid var(--border-color);
}

.ria-theme-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.14s, background 0.14s;
  margin-bottom: 2px;
}
.ria-theme-btn:hover { color: var(--text-secondary); background: var(--surface-hover); }

/* Logout variant: shares the theme-btn layout but picks up a red tint on
   hover so users read it as a destructive action without it screaming
   from the sidebar at rest. */
.ria-logout-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.ria-logout-btn:focus-visible {
  outline: 2px solid rgba(239, 68, 68, 0.5);
  outline-offset: 2px;
}

.ria-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.75rem;
}
.ria-user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  flex-shrink: 0;
}
.ria-user-name  { font-size: 0.78rem; font-weight: 500; color: var(--text-primary); line-height: 1.2; }
.ria-user-role  { font-size: 0.67rem; color: var(--text-muted); }

/* ── Main content area ───────────────────────────────────────────────── */
.ria-main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  background: var(--background-color);
  /* Subtle ambient glow */
  background-image: radial-gradient(ellipse 60% 40% at 70% 0%, rgba(139,92,246,0.055), transparent 55%);
}

.ria-main .container { max-width: 1080px; }

/* ── Card overrides ──────────────────────────────────────────────────── */
.card {
  background: var(--surface-color) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  /* Kill left-border accent pattern */
  border-left: 1px solid var(--border-color) !important;
}

.feature-card {
  border-left: 1px solid var(--border-color) !important;
}

/* KPI stat cards */
.stat-card {
  border-radius: 10px !important;
}

/* ── KPI grid spacing ────────────────────────────────────────────────── */
.kpi-grid { gap: 0.75rem !important; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--text-primary) !important;
  color: var(--background-color) !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.btn-primary:hover {
  opacity: 0.9 !important;
  transform: translateY(-1px) !important;
}
[data-theme="light"] .btn-primary {
  background: #09090b !important;
  color: #fff !important;
}

.btn-gradient {
  background: var(--primary-color) !important;
  box-shadow: none !important;
}
.btn-gradient:hover {
  opacity: 0.9 !important;
  filter: none !important;
  box-shadow: 0 0 20px rgba(139,92,246,0.35) !important;
}

/* ── Upload zone ─────────────────────────────────────────────────────── */
.upload-zone {
  background: var(--surface-hover) !important;
  border: 1.5px dashed var(--border-strong) !important;
  border-radius: 10px !important;
}
.upload-zone:hover {
  border-color: var(--primary-color) !important;
  background: rgba(139,92,246,0.04) !important;
}

/* ── Tabs ────────────────────────────────────────────────────────────── */
.tab-group {
  border-bottom: 1px solid var(--border-color);
  gap: 0 !important;
  padding: 0 !important;
  background: transparent !important;
}
.tab-btn {
  border-radius: 0 !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  background: transparent !important;
  color: var(--text-muted) !important;
  padding: 0.75rem 1rem 0.65rem !important;
  font-size: 0.82rem !important;
  margin-right: 0.25rem;
}
.tab-btn.active {
  border-bottom-color: var(--primary-color) !important;
  color: var(--text-primary) !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* ── Risk badges ─────────────────────────────────────────────────────── */
.badge-high   { background: rgba(248,113,113,0.12) !important; color: #f87171 !important; border: 1px solid rgba(248,113,113,0.2) !important; }
.badge-medium { background: rgba(251,191,36,0.12)  !important; color: #fbbf24 !important; border: 1px solid rgba(251,191,36,0.2)  !important; }
.badge-low    { background: rgba(52,211,153,0.12)  !important; color: #34d399 !important; border: 1px solid rgba(52,211,153,0.2)  !important; }

/* ── Progress bar ────────────────────────────────────────────────────── */
.progress-bar-fill {
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color)) !important;
}

/* ── History table ───────────────────────────────────────────────────── */
.history-table th {
  font-size: 0.72rem !important;
  letter-spacing: 0.06em !important;
  color: var(--text-muted) !important;
  border-bottom: 1px solid var(--border-color) !important;
  text-transform: uppercase !important;
  background: transparent !important;
  padding: 0.65rem 1rem !important;
}
.history-table td { padding: 0.85rem 1rem !important; }
.history-table tbody tr:hover { background: var(--surface-hover) !important; }

/* ── Form inputs ─────────────────────────────────────────────────────── */
.form-input, input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="date"], input[type="number"], select, textarea {
  background: var(--surface-hover) !important;
  border: 1px solid var(--border-color) !important;
  color: var(--text-primary) !important;
  border-radius: 8px !important;
}
.form-input:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--primary-color) !important;
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(139,92,246,0.18) !important;
}

/* ── Steps grid (analysis progress) ─────────────────────────────────── */
.step-item.active .step-icon {
  background: var(--primary-color) !important;
  border-color: var(--primary-color) !important;
}

/* ── Report: gauge + dimension cards ────────────────────────────────── */
.risk-score-card, .dimensions-chart-card, .chart-card { border-radius: 10px !important; }

/* ── CSS gauge ring color fix ────────────────────────────────────────── */
.css-gauge-inner .gauge-value { letter-spacing: -0.04em; }

/* ── Section / exec summary cards ───────────────────────────────────── */
.report-section-card { border-radius: 10px !important; border-left: none !important; }
.exec-summary-card   { border-radius: 10px !important; border-left: none !important; }

/* ── Dimension accordion (report) ───────────────────────────────────── */
.dimension-card { border-radius: 10px !important; border-left: none !important; }

/* ── Settings: danger zone ───────────────────────────────────────────── */
.danger-zone { border-radius: 10px !important; }

/* ── Auth pages (login / register) ──────────────────────────────────── */
body[data-layout="auth"] {
  background: var(--background-color) !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

body[data-layout="auth"] .container {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

body[data-layout="auth"] .card {
  background: var(--surface-color) !important;
}

/* ── Skeleton refreshed ──────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-color) 0%,
    var(--surface-hover) 40%,
    var(--surface-elevated) 50%,
    var(--surface-hover) 60%,
    var(--surface-color) 100%
  ) !important;
  background-size: 300% 100% !important;
  animation: shimmer 1.8s ease-in-out infinite !important;
}

/* ── Notification items ──────────────────────────────────────────────── */
.notification-item, .recent-item {
  border-radius: 8px !important;
  border-left: none !important;
}

/* ── Spotlight overlay (disable glow effect that conflicts) ──────────── */
[data-spotlight]::before { display: none !important; }

/* ── Mobile: collapse sidebar to bottom nav ──────────────────────────── */
@media (max-width: 768px) {
  .ria-sidebar {
    display: none;
  }
  body {
    flex-direction: column !important;
    overflow: auto;
  }
  .ria-main { height: auto; overflow: visible; }
  .ria-mobile-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    z-index: 50;
  }
}

.ria-mobile-nav { display: none; }

.ria-mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.68rem;
  gap: 0.3rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.14s;
}
.ria-mobile-nav-item.active { color: var(--primary-color); }
.ria-mobile-nav-item:hover { color: var(--text-primary); }

/* ── Notification bell ───────────────────────────────────────────────── */
.ria-bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.4rem 0.75rem;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.14s, background 0.14s;
  margin-bottom: 2px;
}
.ria-bell-btn:hover { background: var(--surface-elevated); color: var(--text-primary); }
.ria-bell-btn:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }

.ria-bell-count {
  position: absolute;
  top: 2px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--c-danger-400, #ef4444);
  color: white;
  border-radius: 8px;
  font-size: 0.65rem;
  font-weight: 600;
  line-height: 16px;
  text-align: center;
  pointer-events: none;
}

.ria-bell-dropdown {
  position: fixed;
  width: 340px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 999;
  animation: bellDropIn 0.14s ease-out;
}
@keyframes bellDropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ria-bell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  color: var(--text-primary);
}
.ria-bell-readall {
  background: transparent;
  border: none;
  color: var(--primary-color);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
}
.ria-bell-readall:hover { background: var(--surface-elevated); }

.ria-bell-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
}
.ria-bell-item {
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  transition: background 0.12s;
}
.ria-bell-item:last-child { border-bottom: none; }
.ria-bell-item:hover { background: var(--surface-elevated); }
.ria-bell-msg {
  color: var(--text-primary);
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
  line-height: 1.35;
}
.ria-bell-time {
  color: var(--text-muted);
  font-size: 0.7rem;
}
.ria-bell-empty, .ria-bell-loading {
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* ── Copy-section button (report page) ───────────────────────────────── */
.btn-copy-section {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  background: var(--surface-elevated, rgba(255, 255, 255, 0.03));
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color 0.14s, background 0.14s, border-color 0.14s;
}
.btn-copy-section:hover {
  color: var(--text-primary);
  background: var(--surface-color);
  border-color: var(--primary-color);
}
.btn-copy-section:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
.btn-copy-section svg { flex-shrink: 0; }

/* ── Tag chips (history filter + report page) ────────────────────────── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  background: var(--surface-elevated, rgba(255, 255, 255, 0.03));
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.74rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.tag-chip:hover {
  color: var(--text-primary);
  border-color: var(--primary-color);
}
.tag-chip.active {
  background: rgba(139, 92, 246, 0.14);
  color: var(--primary-color);
  border-color: var(--primary-color);
}
.tag-chip-count {
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--surface-color);
  padding: 0 0.35rem;
  border-radius: 999px;
  min-width: 14px;
  text-align: center;
}
.tag-chip.active .tag-chip-count {
  color: var(--primary-color);
  background: rgba(139, 92, 246, 0.2);
}
.tag-chip-remove {
  cursor: pointer;
  opacity: 0.6;
  margin-left: 0.15rem;
  font-size: 0.85rem;
}
.tag-chip-remove:hover { opacity: 1; color: var(--c-danger-400, #ef4444); }
.tag-chip-input {
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  outline: none;
  width: 110px;
}
.tag-chip-input:focus {
  border-color: var(--primary-color);
  border-style: solid;
  color: var(--text-primary);
}

/* ── Command palette (⌘K) ────────────────────────────────────────────── */
.ria-cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9998;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(18vh, 160px);
  animation: cmdkFade 0.12s ease-out;
}
@keyframes cmdkFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.ria-cmdk-panel {
  width: min(620px, 92vw);
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: cmdkSlide 0.16s ease-out;
}
@keyframes cmdkSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ria-cmdk-input {
  width: 100%;
  padding: 1rem 1.15rem;
  background: transparent;
  color: var(--text-primary);
  border: none;
  outline: none;
  font-size: 1rem;
  font-family: var(--font-sans);
  border-bottom: 1px solid var(--border-color);
}
.ria-cmdk-input::placeholder { color: var(--text-muted); }
.ria-cmdk-list {
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.35rem 0;
}
.ria-cmdk-section {
  padding: 0.5rem 1.15rem 0.25rem;
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ria-cmdk-item {
  padding: 0.5rem 1.15rem;
  cursor: pointer;
  transition: background 0.08s;
}
.ria-cmdk-item.selected,
.ria-cmdk-item:hover {
  background: var(--surface-elevated);
}
.ria-cmdk-item.selected {
  box-shadow: inset 3px 0 0 var(--primary-color);
}
.ria-cmdk-title {
  color: var(--text-primary);
  font-size: 0.88rem;
  margin-bottom: 0.15rem;
}
.ria-cmdk-sub {
  color: var(--text-muted);
  font-size: 0.72rem;
}
.ria-cmdk-empty {
  padding: 1.5rem 1.15rem;
  color: var(--text-muted);
  text-align: center;
  font-size: 0.85rem;
}
.ria-cmdk-footer {
  display: flex;
  gap: 1rem;
  padding: 0.55rem 1.15rem;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.7rem;
}
.ria-cmdk-footer kbd {
  background: var(--surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.68rem;
  margin-right: 0.15rem;
  color: var(--text-secondary);
}
