/* Telin GRC Suite — shared design tokens + global layout
   Loaded by every page as <link rel="stylesheet" href="theme.css">.

   What lives here:
   - Color, typography, radius, shadow tokens (single source)
   - Reset + base typography
   - Fixed left sidebar layout (.app-sidebar, .app-main)
   - Mobile breakpoint: hide sidebar under 900px

   What does NOT live here:
   - Page-specific component styles (still in each page's <style>)
   - Module-specific layouts
*/

/* ── Design tokens ────────────────────────────────────────────────── */
:root {
  /* Brand */
  --red: #E2001A;
  --red-light: #FFF1F2;
  --red-mid: #FECDCD;
  --navy: #0D1B2A;

  /* Neutrals */
  --gray-50:  #f7f7f5;
  --gray-100: #f1f1f0;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-400: #ced4da;
  --gray-500: #868685;
  --gray-600: #6C757D;
  --gray-700: #37352f;
  --gray-800: #212529;
  --gray-900: #050505;

  /* Status */
  --green: #16A34A;
  --green-light: #DCFCE7;
  --amber: #D97706;
  --amber-light: #FEF3C7;
  --blue: #2563EB;
  --blue-light: #EFF6FF;

  /* Type */
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;

  /* Layout */
  --sidebar-w: 240px;

  /* Surfaces */
  --shadow-sm: 0 1px 2px rgba(15, 15, 15, 0.08);
  --shadow:    0 1px 3px rgba(15, 15, 15, 0.10);
  --shadow-md: 0 4px 6px -1px rgba(15, 15, 15, 0.10), 0 2px 4px -1px rgba(15, 15, 15, 0.06);

  /* Radii */
  --radius: 6px;
  --radius-pill: 9999px;
  --radius-lg: 10px;

  /* Glass */
  --glass-bg: #fff;
  --glass-border: var(--gray-200);
}

/* ── Reset (idempotent — pages may include their own resets) ──────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ── Shared layout for module pages ───────────────────────────────── */
/* Pages opt in by adding `<aside id="app-sidebar">` + wrapping content in `<main class="app-main">`.
   Sidebar is position: fixed so existing page layouts don't need to change. */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  z-index: 100;
  font-family: var(--font);
}
.app-sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.app-sidebar__logo {
  width: 34px; height: 34px;
  background: var(--red);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -0.5px;
}
.app-sidebar__title    { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.2; }
.app-sidebar__subtitle { color: rgba(255, 255, 255, 0.45); font-size: 11px; line-height: 1.3; margin-top: 2px; }

.app-sidebar__section-title {
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  padding: 14px 18px 6px;
}
.app-sidebar__nav { padding: 8px 10px; flex: 1; overflow-y: auto; }
.app-sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 1px;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
}
.app-sidebar__link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.9);
}
.app-sidebar__link[aria-current="page"] {
  background: rgba(226, 0, 26, 0.18);
  color: #FF6B7A;
  font-weight: 600;
}
.app-sidebar__icon { font-size: 15px; width: 18px; text-align: center; flex-shrink: 0; }

.app-sidebar__footer {
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: rgba(255, 255, 255, 0.25);
}

/* Main content next to the fixed sidebar */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
}

/* ── Mobile: sidebar becomes slide-in drawer + hamburger ─────────── */
.app-sidebar { transition: transform 0.22s ease; }
.app-sidebar-hamburger {
  display: none;
  position: fixed;
  top: 12px; left: 12px;
  width: 40px; height: 40px;
  background: var(--navy);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  z-index: 102;
  font-size: 18px;
  align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.app-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, 0.55);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.app-sidebar.is-open + .app-sidebar-backdrop { display: block; opacity: 1; }

@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  .app-sidebar.is-open { transform: translateX(0); }
  .app-main { margin-left: 0; padding-top: 60px; /* clear hamburger */ }
  .app-sidebar-hamburger { display: inline-flex; }
}

/* ── Cmd+K hint chip in sidebar footer ───────────────────────────── */
.app-cmdk-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.app-cmdk-hint:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}
.app-cmdk-hint kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  color: rgba(255, 255, 255, 0.85);
}

/* ── Cmd+K palette modal ─────────────────────────────────────────── */
.app-cmdk-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 20px 20px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.app-cmdk-backdrop.is-open { display: flex; opacity: 1; }

.app-cmdk-modal {
  width: 100%;
  max-width: 620px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 20px 50px -10px rgba(15, 15, 15, 0.30), 0 8px 16px -4px rgba(15, 15, 15, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  font-family: var(--font);
}

.app-cmdk-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}
.app-cmdk-prompt {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.4px;
}
.app-cmdk-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  color: var(--gray-900);
  font-family: var(--font);
  padding: 4px 0;
}
.app-cmdk-input::placeholder { color: var(--gray-500); }
.app-cmdk-hint-key {
  font-family: var(--mono);
  font-size: 10px;
  padding: 3px 6px;
  background: var(--gray-100);
  color: var(--gray-600);
  border-radius: 4px;
  letter-spacing: 0.3px;
}

.app-cmdk-list {
  overflow-y: auto;
  padding: 6px;
  flex: 1;
}
.app-cmdk-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.08s;
}
.app-cmdk-item.is-active { background: var(--blue-light); }
.app-cmdk-item-icon {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gray-100);
  border-radius: 6px;
  color: var(--gray-700);
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.app-cmdk-item--page      .app-cmdk-item-icon { background: #FEE2E2; color: var(--red); }
.app-cmdk-item--clause    .app-cmdk-item-icon { background: #DBEAFE; color: var(--blue); }
.app-cmdk-item--standard  .app-cmdk-item-icon { background: var(--green-light); color: var(--green); }
.app-cmdk-item--extension .app-cmdk-item-icon { background: var(--amber-light); color: var(--amber); }
.app-cmdk-item-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.app-cmdk-item-title {
  font-size: 13.5px; font-weight: 600; color: var(--gray-900);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-cmdk-item-sub {
  font-size: 11.5px; color: var(--gray-600); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-cmdk-item-kind {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.app-cmdk-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--gray-500);
  font-size: 13px;
}

.app-cmdk-foot {
  display: flex;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 11px;
  color: var(--gray-500);
}
.app-cmdk-foot kbd {
  font-family: var(--mono);
  font-size: 10px;
  padding: 2px 5px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 3px;
  margin-right: 4px;
  color: var(--gray-700);
}

/* Cmd+K match highlight */
.app-cmdk-item-title mark,
.app-cmdk-item-sub mark {
  background: rgba(245, 158, 11, 0.20);
  color: inherit;
  padding: 0 1px;
  border-radius: 2px;
  font-weight: 700;
}

/* ── Toast notifications ─────────────────────────────────────────── */
.app-toast-container {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 16px));
  right: 20px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 360px;
}
.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px 12px 12px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-left: 3px solid var(--gray-400);
  border-radius: 8px;
  box-shadow: 0 8px 20px -4px rgba(15, 15, 15, 0.18), 0 2px 6px -1px rgba(15, 15, 15, 0.08);
  font: 500 13px/1.4 var(--font);
  color: var(--gray-900);
  text-align: left;
  cursor: pointer;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  min-width: 220px;
}
.app-toast.is-shown { transform: translateX(0); opacity: 1; }
.app-toast.is-leaving { transform: translateX(120%); opacity: 0; }
.app-toast__icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
  color: #fff;
}
.app-toast__msg { flex: 1; }
.app-toast--success { border-left-color: var(--green); }
.app-toast--success .app-toast__icon { background: var(--green); }
.app-toast--error   { border-left-color: var(--red); }
.app-toast--error   .app-toast__icon { background: var(--red); }
.app-toast--info    { border-left-color: var(--blue); }
.app-toast--info    .app-toast__icon { background: var(--blue); }
.app-toast--warn    { border-left-color: var(--amber); }
.app-toast--warn    .app-toast__icon { background: var(--amber); }

/* ── Skeleton loaders (inside #root before React boots) ───────────── */
.app-skeleton {
  padding: 28px;
  animation-delay: 200ms;
  animation-name: app-skeleton-fade-in;
  animation-duration: 240ms;
  animation-fill-mode: both;
}
@keyframes app-skeleton-fade-in { from { opacity: 0; } to { opacity: 1; } }
.app-skeleton__row {
  height: 14px;
  background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-200) 50%, var(--gray-100) 100%);
  background-size: 400% 100%;
  border-radius: 4px;
  margin-bottom: 10px;
  animation: app-skeleton-shimmer 1.4s ease-in-out infinite;
}
.app-skeleton__row--lg  { height: 22px; width: 50%; }
.app-skeleton__row--md  { height: 16px; width: 75%; }
.app-skeleton__row--sm  { height: 12px; width: 40%; }
@keyframes app-skeleton-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Empty states for module pages ────────────────────────────────── */
.app-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  background: #fff;
  border: 1px dashed var(--gray-300);
  border-radius: 12px;
  margin: 16px auto;
  max-width: 520px;
}
.app-empty__icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-500);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.app-empty__title {
  font-size: 16px; font-weight: 700; color: var(--gray-900);
  margin: 0 0 6px;
}
.app-empty__sub {
  font-size: 13px; color: var(--gray-600); line-height: 1.5;
  max-width: 360px;
  margin: 0 0 18px;
}
.app-empty__cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--navy);
  color: #fff;
  font-size: 13px; font-weight: 600;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  transition: background 0.12s;
}
.app-empty__cta:hover { background: #1B2C44; }

/* ── Hash deep-link pulse-highlight ────────────────────────────────── */
@keyframes app-cmdk-flash {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.55); background: rgba(37, 99, 235, 0.10); }
  60%  { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); background: rgba(37, 99, 235, 0.10); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); background: transparent; }
}
.is-cmdk-flash {
  animation: app-cmdk-flash 1.6s ease-out 1;
  border-radius: 4px;
}

/* ── Scrollbar polish ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
.app-sidebar ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); }
.app-sidebar ::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
