/* ═══════════════════════════════════════════════════════════════════
   LTV Audit CRM — Shared Shell Styles
   Imported by every page. Sets theme, layout, sidebar, topbar.
═══════════════════════════════════════════════════════════════════ */

/* SMOOTH THEME TRANSITION */
:root.theme-transition, :root.theme-transition *, :root.theme-transition *::before, :root.theme-transition *::after {
  transition: background-color 0.3s ease, color 0.2s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

/* ── THEME TOKENS ─────────────────────────────────────────────────── */
:root {
  --bg:      #0d0f14;
  --surface: #13161d;
  --surface2:#191c25;
  --surface3:#1e2230;
  --border:  rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.10);
  --text:    #e4e8f0;
  --muted:   #6b7280;
  --muted2:  #4b5363;
  --accent:       #c2714a;
  --accent-soft:  rgba(194,113,74,0.12);
  --accent-glow:  rgba(194,113,74,0.20);
  --green:        #3a8f6f;
  --green-soft:   rgba(58,143,111,0.12);
  --blue:         #3a6f8f;
  --blue-soft:    rgba(58,111,143,0.12);
  --yellow:       #c29a4a;
  --yellow-soft:  rgba(194,154,74,0.12);
  --red:          #8f3a3a;
  --red-soft:     rgba(143,58,58,0.12);
  --purple:       #6f3a8f;
  --purple-soft:  rgba(111,58,143,0.12);
  --mono: 'DM Mono', monospace;
  --sans: 'Instrument Sans', sans-serif;
}

/* LIGHT THEME */
:root.light {
  --bg:      #f4f2ee;
  --surface: #ffffff;
  --surface2:#f0ede8;
  --surface3:#e8e4de;
  --border:  rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.13);
  --text:    #1a1a18;
  --muted:   #6b6760;
  --muted2:  #9a9690;
  --accent:       #c2714a;
  --accent-soft:  rgba(194,113,74,0.10);
  --accent-glow:  rgba(194,113,74,0.18);
  --green:        #2a7a58;
  --green-soft:   rgba(42,122,88,0.10);
  --blue:         #2a5f8a;
  --blue-soft:    rgba(42,95,138,0.10);
  --yellow:       #a07a28;
  --yellow-soft:  rgba(160,122,40,0.10);
  --red:          #8a2a2a;
  --red-soft:     rgba(138,42,42,0.10);
  --purple:       #5a2a8a;
  --purple-soft:  rgba(90,42,138,0.10);
}

/* ── RESET ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: var(--sans); background: var(--bg); color: var(--text); font-size: 15px; }

/* ── APP SHELL ────────────────────────────────────────────────────── */
.app-shell  { display: flex; height: 100vh; overflow: hidden; }
.app-main   { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }
.main-scroll{ flex: 1; overflow-y: auto; overflow-x: auto; display: flex; flex-direction: column; min-height: 0; }

/* ── SIDEBAR ──────────────────────────────────────────────────────── */
.sidebar {
  width: 62px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  z-index: 200;
  transition: width 0.22s ease;
  overflow: hidden;
  min-height: 0;
}
.sidebar:hover { width: 220px; }

.sidebar-logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: -0.03em; color: #fff;
  flex-shrink: 0; margin-bottom: 20px;
  text-decoration: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 0 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.snav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  overflow: hidden; min-width: 0;
}
.snav-item svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; }
.snav-item .snav-label { opacity: 0; transition: opacity 0.12s 0.06s, max-width 0.12s ease; white-space: nowrap; max-width: 0; overflow: hidden; }
.sidebar:hover .snav-label { opacity: 1; max-width: 160px; }
.snav-item:hover  { background: var(--surface2); color: var(--text); }
.snav-item.active { background: var(--accent-soft); color: var(--accent); border-color: rgba(194,113,74,0.2); }

.snav-section {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted2); padding: 0 14px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.12s 0.06s, max-width 0.12s ease, padding 0.12s ease; white-space: nowrap; overflow: hidden;
  height: 0; margin: 0;
  max-width: 0;
}
.sidebar:hover .snav-section { opacity: 1; height: auto; padding: 14px 14px 5px; max-width: 180px; }
.snav-section:first-child { padding-top: 6px; }
.sidebar:hover .snav-section:first-child { padding-top: 6px; }

.snav-divider { height: 1px; background: var(--border); margin: 6px 8px; flex-shrink: 0; }

/* SIDEBAR FOOTER */
.sidebar-footer { width: 100%; padding: 0 8px; display: flex; flex-direction: column; gap: 3px; }

.snav-user { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; overflow: hidden; cursor: default; }
.snav-avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.snav-user-info { display: none; flex-direction: column; min-width: 0; }
.sidebar:hover .snav-user-info { display: flex; }
.snav-user-info strong { font-size: 12px; color: var(--text); font-weight: 600; white-space: nowrap; }
.snav-user-info span   { font-size: 11px; color: var(--muted); white-space: nowrap; }

/* theme toggle button */
.snav-theme {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 500;
  border: none; background: none; width: 100%;
  transition: all 0.15s; overflow: hidden; white-space: nowrap;
  font-family: var(--sans);
}
.snav-theme svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; }
.snav-theme .snav-label { opacity: 0; transition: opacity 0.12s 0.06s; }
.sidebar:hover .snav-theme .snav-label { opacity: 1; }
.snav-theme:hover { background: var(--surface2); color: var(--text); }

/* logout */
.snav-logout {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  cursor: pointer; color: var(--muted);
  font-size: 13px; font-weight: 500;
  border: none; background: none; width: 100%;
  transition: all 0.15s; overflow: hidden; white-space: nowrap;
  font-family: var(--sans);
}
.snav-logout svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; }
.snav-logout .snav-label { opacity: 0; transition: opacity 0.12s 0.06s; }
.sidebar:hover .snav-logout .snav-label { opacity: 1; }
.snav-logout:hover { background: var(--red-soft); color: var(--red); }

/* ── TOPBAR (shared base) ─────────────────────────────────────────── */
.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
  overflow: visible;
}
.topbar-brand {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600; letter-spacing: -.02em;
  white-space: nowrap; flex-shrink: 0;
}
.topbar-brand em { color: var(--muted); font-style: normal; font-weight: 400; }
.topbar-divider {
  width: 1px; height: 22px; flex-shrink: 0;
  background: var(--border);
}

.logo {
  font-weight: 700; font-size: 15px; letter-spacing: -0.03em;
  padding: 0 18px; height: 100%;
  display: flex; align-items: center;
  border-right: 1px solid var(--border);
  flex-shrink: 0; white-space: nowrap;
  text-decoration: none; color: var(--text);
}
.logo span { color: var(--accent); }
.logo em   { color: var(--muted); font-style: normal; font-weight: 400; font-size: 12px; margin-left: 6px; }

/* CLOCKS */
.topbar-clocks { display: flex; align-items: center; gap: 14px; flex-shrink: 1; min-width: 0; overflow: hidden; }
.topbar-clock { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.topbar-clock .flag { font-size: 15px; line-height: 1; }
.topbar-clock .time {
  font-size: 15px; font-weight: 600;
  font-family: var(--mono); color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.clock-item {
  display: flex; align-items: center; gap: 9px;
  padding: 0 18px; height: 100%;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.clock-item:last-child { border-right: none; }
.clock-flag   { font-size: 18px; line-height: 1; flex-shrink: 0; }
.clock-info   { display: flex; flex-direction: column; gap: 1px; }
.clock-city   { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.clock-time   { font-size: 17px; font-weight: 700; letter-spacing: -0.04em; font-family: var(--mono); color: var(--text); line-height: 1.1; }
.clock-status { font-size: 9px; padding: 2px 6px; border-radius: 999px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; display: inline-block; }
.clock-status.day     { background: var(--green-soft);  color: var(--green); }
.clock-status.evening { background: var(--yellow-soft); color: var(--yellow); }
.clock-status.night   { background: var(--blue-soft);   color: var(--blue); }

/* TOPBAR RIGHT AREA */
.topbar-right {
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px; height: 100%;
  border-left: 1px solid var(--border);
  margin-left: auto; flex-shrink: 0;
}

/* ── SHARED COMPONENTS ────────────────────────────────────────────── */
.btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 10px; padding: 10px 22px;
  font-size: 14px; font-family: var(--sans); font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.btn:hover { opacity: 0.88; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--surface2); color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 10px; padding: 10px 18px;
  font-size: 14px; font-family: var(--sans); cursor: pointer;
  transition: all 0.15s;
}
.btn-ghost:hover { background: var(--surface3); transform: translateY(-1px); }
.btn-ghost:active { transform: translateY(0) scale(0.98); }

.stats-pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 11px;
  font-size: 11px; color: var(--muted); font-family: var(--mono); white-space: nowrap;
}
.stats-pill strong { color: var(--text); font-weight: 600; }

/* SKELETON LOADING */
.skel{position:relative;overflow:hidden;background:var(--surface2);border-radius:6px}
.skel::after{content:'';position:absolute;inset:0;background:linear-gradient(90deg,transparent,rgba(255,255,255,.04),transparent);animation:skel-shimmer 1.4s infinite}
:root.light .skel::after{background:linear-gradient(90deg,transparent,rgba(0,0,0,.04),transparent)}
@keyframes skel-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}
.skel-line{height:14px;margin-bottom:8px;border-radius:4px}
.skel-line.w80{width:80%}.skel-line.w60{width:60%}.skel-line.w40{width:40%}.skel-line.w100{width:100%}
.skel-circle{border-radius:50%}
.skel-row{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--border)}
.skel-row .skel-av{width:32px;height:32px;border-radius:50%;flex-shrink:0}
.skel-row .skel-text{flex:1;display:flex;flex-direction:column;gap:6px}

/* PANEL FADE-IN */
.li-panel.active{animation:panelIn .2s ease}
@keyframes panelIn{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:translateY(0)}}

/* FOCUS & INTERACTION */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
button:active:not(:disabled) { transform: scale(0.97); }

/* TOAST */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 7px; }
.toast  {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 9px; padding: 10px 14px;
  font-size: 13px; color: var(--text);
  display: flex; align-items: center; gap: 7px;
  min-width: 180px; box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  animation: tIn 0.2s ease;
}
@keyframes tIn { from { transform: translateY(6px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.toast.err { border-left-color: var(--red); }

/* ── Floating chat widget (rendered by /js/chat-widget.js) ─────────────────── */
.chat-w-fab {
  position: fixed; right: 24px; bottom: 24px;
  width: 48px; height: 48px; border-radius: 50%;
  background: #C4704A; color: #ffffff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
  z-index: 400;
  transition: transform .12s, background .12s, opacity .15s;
}
.chat-w-fab:hover { background: #B6643F; transform: translateY(-1px); }
.chat-w-fab:active { transform: translateY(0); }
.chat-w-fab.hidden { opacity: 0; pointer-events: none; transform: scale(0.8); }

.chat-w-panel {
  position: fixed; right: 20px; bottom: 20px;
  width: 360px; height: 520px;
  max-height: calc(100vh - 40px);
  background: var(--surface, #161616);
  border: 1px solid var(--border, #2a2a2a);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.04);
  display: none; flex-direction: column;
  z-index: 401;
  overflow: hidden;
  transform: translateY(8px); opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.chat-w-panel.open { display: flex; transform: translateY(0); opacity: 1; }
:root.light .chat-w-panel { background: #ffffff; border-color: #E8E4E0; }

.chat-w-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border, #2a2a2a);
  background: var(--surface, #161616); flex-shrink: 0;
}
:root.light .chat-w-head { background: #ffffff; border-bottom-color: #E8E4E0; }
.chat-w-title {
  font-size: 12px; font-weight: 800; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted, #888);
}
.chat-w-head-actions { display: flex; gap: 4px; }
.chat-w-iconbtn {
  width: 26px; height: 26px; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted, #888); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
}
.chat-w-iconbtn:hover {
  background: rgba(255,255,255,0.06); color: var(--text, #f0f0f0);
  border-color: var(--border, #2a2a2a);
}

.chat-w-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 14px; display: flex; flex-direction: column; gap: 9px;
  font-size: 13px; line-height: 1.5;
}
.chat-w-empty {
  color: var(--muted, #888); font-size: 12px; line-height: 1.55;
  padding: 18px 6px; text-align: center;
}
.chat-w-msg {
  max-width: 90%; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border, #2a2a2a);
  background: var(--surface2, #1c1c1c);
  color: var(--text, #f0f0f0);
  white-space: pre-wrap; word-break: break-word;
}
.chat-w-msg.user {
  align-self: flex-end;
  background: rgba(78,186,148,0.10);
  border-color: rgba(78,186,148,0.28);
}
.chat-w-msg.bot { align-self: flex-start; }
.chat-w-msg.loading { opacity: 0.7; font-style: italic; }
.chat-w-meta {
  font-size: 10px; font-family: 'DM Mono', ui-monospace, monospace;
  color: var(--muted, #888); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: .05em;
}

.chat-w-suggestions {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--border, #2a2a2a);
  background: var(--surface, #161616); flex-shrink: 0;
}
:root.light .chat-w-suggestions { background: #ffffff; border-top-color: #E8E4E0; }
.chat-w-chip {
  border: 1px solid var(--border, #2a2a2a);
  background: var(--surface2, #1c1c1c);
  color: var(--muted, #888);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px; font-weight: 700;
  cursor: pointer; font-family: inherit;
  transition: background .12s, color .12s;
}
.chat-w-chip:hover {
  background: var(--surface3, #232323); color: var(--text, #f0f0f0);
}

.chat-w-form {
  display: grid; grid-template-columns: minmax(0,1fr) auto;
  gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border, #2a2a2a);
  background: var(--surface, #161616); flex-shrink: 0;
}
:root.light .chat-w-form { background: #ffffff; border-top-color: #E8E4E0; }
.chat-w-input {
  width: 100%;
  border: 1px solid var(--border, #2a2a2a);
  background: var(--surface2, #1c1c1c);
  color: var(--text, #f0f0f0);
  border-radius: 9px;
  padding: 8px 11px;
  font: 500 13px/1.45 'Instrument Sans', system-ui, sans-serif;
  outline: none; resize: none;
  min-height: 36px; max-height: 120px;
  overflow-y: auto;
}
.chat-w-input:focus { border-color: var(--border2, #444); }
:root.light .chat-w-input { background: #FAFAF8; color: #1A1A1A; }
.chat-w-send {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: rgba(78,186,148,0.16);
  color: #4eba94;
  border: 1px solid rgba(78,186,148,0.35);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.chat-w-send:hover { background: rgba(78,186,148,0.26); }
.chat-w-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Mobile: bottom sheet */
@media (max-width: 640px) {
  .chat-w-panel {
    right: 8px; left: 8px; bottom: 8px;
    width: auto; height: 72vh;
  }
  .chat-w-fab { right: 16px; bottom: 16px; }
}
