/* app.css — internal Command Center shell. Reuses public design tokens. */
@import url("/website/css/main.css");

:root { --sidebar-w: 248px; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--deep); border-right: 1px solid var(--border);
  padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 1.5rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo { font-family: var(--font-display); font-size: 1.2rem; padding: .3rem .5rem; }
.sidebar-logo b { color: var(--gold); }
.side-nav { display: flex; flex-direction: column; gap: .2rem; }
.side-nav a {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem;
  border-radius: var(--radius); color: var(--dim); font-size: var(--fs-sm);
}
.side-nav a:hover { background: rgba(201,168,76,0.06); color: var(--cream); }
.side-nav a.active { background: rgba(201,168,76,0.1); color: var(--gold-2); border-left: 2px solid var(--gold); }
.side-nav .ico { width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; font-size: var(--fs-xs); color: var(--muted); }

/* ---------- Main ---------- */
/* overflow-x: clip (not hidden) — clips horizontal overflow WITHOUT creating a
   scroll container, so position:sticky children (e.g. the Home Copy section nav)
   keep working. `hidden` would force overflow-y:auto and break their sticking. */
/* min-width:0 is critical: without it the grid 1fr column takes its children's
   min-content width, so a wide child (e.g. the ticker preview at width:max-content)
   forces the whole page wider than the viewport and pushes right-aligned buttons
   off-screen. min-width:0 lets the column shrink; overflow-x:clip hides the excess. */
.app-main { padding: clamp(1.2rem, 3vw, 2.2rem); overflow-x: clip; min-width: 0; }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; flex-wrap: wrap; }
.app-actions { display: flex; align-items: center; gap: .5rem; }
.app-title { display: flex; flex-direction: column; gap: .2rem; }
.app-title h1 { font-size: 1.9rem; }

/* Shared toast stack (bottom-right, non-blocking) */
.bbg-toasts { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 500; display: flex; flex-direction: column; gap: .5rem; max-width: min(360px, 90vw); }
.bbg-toast { background: var(--card); border: 1px solid var(--border-2); border-left-width: 4px; border-radius: 9px; padding: .7rem 1rem; color: var(--cream); font-size: var(--fs-sm); box-shadow: var(--shadow); cursor: pointer; opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.bbg-toast.in { opacity: 1; transform: translateY(0); }
.bbg-toast.success { border-left-color: var(--green, #25D366); }
.bbg-toast.error { border-left-color: var(--red, #e05555); }
.bbg-toast.info { border-left-color: var(--gold-2, #E5C96A); }
@media (prefers-reduced-motion: reduce) { .bbg-toast { transition: none; } }

/* Global notifications bell + unread badge (every admin page) */
.bell-link { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--border-2); border-radius: 8px; font-size: 1.15rem; text-decoration: none; color: inherit; flex: none; }
.bell-link:hover { border-color: var(--gold-2); background: rgba(201,168,76,0.06); }
.bell-badge { position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 999px; background: var(--red); color: #fff; font-size: .62rem; font-weight: 700; line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--deep); }
.bell-link.has-unread .bell-ico { transform-origin: 50% 15%; animation: bellRing 1.4s ease 1; }
@keyframes bellRing { 0%,100% { transform: rotate(0); } 15% { transform: rotate(14deg); } 30% { transform: rotate(-11deg); } 45% { transform: rotate(7deg); } 60% { transform: rotate(-4deg); } 75% { transform: rotate(2deg); } }
/* In the sidebar-head fallback, keep it compact */
.sidebar-head .bell-link { width: 34px; height: 34px; font-size: 1rem; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.2rem; }
.stat .n { font-family: var(--font-display); font-size: 2.2rem; color: var(--gold-2); line-height: 1; }
.stat .l { font-size: var(--fs-xs); color: var(--dim); text-transform: uppercase; letter-spacing: .1em; margin-top: .5rem; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); min-width: 560px; }
table.data th, table.data td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
table.data th { color: var(--gold); font-weight: 500; text-transform: uppercase; font-size: var(--fs-xs); letter-spacing: .08em; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: rgba(201,168,76,0.03); }

/* ---------- Pill / status ---------- */
.pill { display: inline-flex; padding: .2rem .6rem; border-radius: 999px; font-size: var(--fs-xs); border: 1px solid var(--border-2); }
.pill.ok { color: var(--green); border-color: rgba(37,211,102,.35); }
.pill.warn { color: var(--gold-2); }
.pill.off { color: var(--dim); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.kcol { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1rem; }
.kcol h3 { font-size: 1rem; margin-bottom: .8rem; color: var(--gold); }
.kdrop { min-height: 40px; }
.kdrop.over { outline: 1px dashed var(--border-2); outline-offset: 3px; border-radius: var(--radius); }
.kcard { background: var(--deep); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; margin-bottom: .6rem; font-size: var(--fs-sm); cursor: grab; transition: border-color var(--transition); }
.kcard:hover { border-color: var(--border-2); }
.kcard.dragging { opacity: .5; cursor: grabbing; }
.kcard .kclient { display: block; font-size: var(--fs-xs); color: var(--gold); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .3rem; }
.kcard .ktitle { color: var(--cream); font-weight: 500; }
.kcard .kdesc { color: var(--dim); font-size: var(--fs-xs); margin-top: .3rem; }
.kcard .kdue { display: inline-block; color: var(--dim); font-size: var(--fs-xs); margin-top: .5rem; }
.kcard-actions { display: flex; justify-content: space-between; gap: .5rem; margin-top: .7rem; padding-top: .6rem; border-top: 1px solid var(--border); }
.kcard-actions button { font-size: var(--fs-xs); color: var(--dim); }
.kcard-actions .ktasks:hover { color: var(--gold-2); }
.kcard-actions .kdel:hover { color: var(--red); }

/* Tasks */
.task-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.task-check { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-size: var(--fs-sm); }
.task-check input { width: 16px; height: 16px; accent-color: var(--gold); }
.task-check .done { text-decoration: line-through; color: var(--dim); }
.new-task { display: flex; gap: .5rem; margin-top: 1rem; }
.new-task input { flex: 1; padding: .6rem; background: var(--deep); border: 1px solid var(--border); border-radius: var(--radius); color: var(--cream); }

/* ---------- Login gate ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.gate-card { width: 100%; max-width: 380px; }
.gate-card input { width: 100%; padding: .8rem; margin-top: .5rem; background: var(--deep); border: 1px solid var(--border); border-radius: var(--radius); color: var(--cream); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 200; width: var(--sidebar-w); transform: translateX(-105%); transition: transform var(--transition); }
  .sidebar.open { transform: translateX(0); }
  .app-menu-btn { display: inline-flex; }
}
.app-menu-btn { display: none; font-size: 1.5rem; color: var(--gold); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(9,9,9,0.7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 1.5rem; overflow-y: auto; }
/* Cap the modal to the viewport and scroll internally so tall forms (e.g. the
   contract editor) never run off-screen with the Save button unreachable. */
.modal { width: 100%; max-width: 460px; background: var(--card); border: 1px solid var(--border-2); border-radius: var(--radius-lg); padding: 1.6rem; box-shadow: var(--shadow); max-height: calc(100dvh - 3rem); overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; }
.modal-head h2 { font-size: 1.4rem; }
.modal-close { font-size: 1.4rem; color: var(--dim); }
.modal-close:hover { color: var(--gold-2); }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.field label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .1em; color: var(--gold); }
.field input, .field select, .field textarea {
  padding: .7rem; background: var(--deep); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--cream); font-size: var(--fs-sm);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--gold); }
.modal-actions { display: flex; gap: .8rem; justify-content: flex-end; margin-top: 1.2rem; }

/* ---------- Bar charts ---------- */
.bar-row { display: grid; grid-template-columns: 90px 1fr 32px; align-items: center; gap: .8rem; margin-bottom: .6rem; }
.bar-label { font-size: var(--fs-xs); color: var(--dim); text-align: right; }
.bar-track { height: 10px; background: var(--deep); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 999px; transition: width .5s ease; }
.bar-val { font-size: var(--fs-sm); color: var(--gold-2); text-align: right; }

/* ============================================================
   Sidebar: emoji rail, collapse, theme switch (2026-09 upgrade)
   ============================================================ */
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.sb-toggle { background: none; border: 1px solid var(--border); color: var(--dim); border-radius: 6px;
  cursor: pointer; width: 26px; height: 26px; line-height: 1; flex: none; font-size: .9rem; }
.sb-toggle:hover { color: var(--gold-2); border-color: var(--gold-2); }
.logo-mini { display: none; }
.side-group { margin-top: 1rem; padding: 0 .8rem .35rem; font-size: .62rem; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); }
/* Collapsible category headers (dropdown to save vertical space) */
.side-group-toggle { display: flex; align-items: center; justify-content: space-between; gap: .4rem; width: 100%; background: none; border: 0; cursor: pointer; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); }
.side-group-toggle:hover { color: var(--cream); }
.side-caret { font-size: .6rem; opacity: .7; transition: transform .18s ease; }
.side-grp.collapsed .side-caret { transform: rotate(-90deg); }
.side-items { display: flex; flex-direction: column; gap: .2rem; }
.side-grp.collapsed .side-items { display: none; }
/* Theme switch relocated into the Website group */
.side-theme { padding: .55rem .8rem .1rem; }
.side-theme-lbl { display: block; font-size: .62rem; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); margin-bottom: .35rem; }
.side-nav a .ico { width: 22px; text-align: center; font-size: 1rem; flex: none; }
.side-label { white-space: nowrap; overflow: hidden; }
.theme-switch { display: flex; gap: .3rem; margin-bottom: .7rem; }
.theme-switch button { flex: 1; background: var(--card); border: 1px solid var(--border); border-radius: 6px; padding: .3rem; cursor: pointer; font-size: .9rem; line-height: 1; }
.theme-switch button.on { border-color: var(--gold); background: rgba(201,168,76,0.12); }
.foot-email { margin-bottom: .5rem; }

/* collapsed rail — desktop only (mobile keeps the off-canvas drawer) */
@media (min-width: 861px) {
  .app-shell.sb-collapsed { grid-template-columns: 64px 1fr; }
  .sb-collapsed .sidebar { padding: 1.4rem .5rem; }
  .sb-collapsed .side-label,
  .sb-collapsed .side-group,
  .sb-collapsed .logo-full,
  .sb-collapsed .foot-email,
  .sb-collapsed .sidebar-foot > a,
  .sb-collapsed .side-theme,
  .sb-collapsed .theme-switch { display: none; }
  /* In rail mode ignore per-category collapse — always show the icons */
  .sb-collapsed .side-items { display: flex !important; }
  .sb-collapsed .logo-mini { display: inline; }
  .sb-collapsed .sidebar-logo { text-align: center; font-size: 1.05rem; }
  .sb-collapsed .sidebar-head { flex-direction: column-reverse; gap: .7rem; }
  .sb-collapsed .side-nav a { justify-content: center; padding: .6rem 0; }
  .sb-collapsed .side-nav a.active { border-left: 0; border-radius: 8px; }
}

/* ============================================================
   Sidebar always-fixed head + foot (toggle + theme always reachable)
   ============================================================ */
.sidebar { gap: .7rem; }
.sidebar-head {
  position: sticky; top: 0; z-index: 4; background: var(--deep);
  padding: .1rem .2rem .6rem; margin: 0 -.2rem;
}
.sidebar-foot {
  position: sticky; bottom: 0; z-index: 4; background: var(--deep);
  margin-top: auto; padding-top: .7rem; border-top: 1px solid var(--border);
}
.side-nav { padding-bottom: .4rem; }

/* ---------- Central Copilot (docked panel) ---------- */
.copilot {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(420px, 92vw);
  background: var(--deep); border-left: 1px solid var(--border);
  box-shadow: -18px 0 50px rgba(0,0,0,.45); z-index: 60;
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
}
.copilot.open { transform: translateX(0); }
.cp-head { display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
  font-family: var(--font-display); color: var(--gold-2); font-size: 1.1rem; }
.cp-x { background: none; border: none; color: var(--dim); font-size: 1.5rem; cursor: pointer; line-height: 1; }
.cp-x:hover { color: var(--cream); }
.cp-thread { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: .8rem; }
.cp-empty { color: var(--dim); font-size: var(--fs-sm); line-height: 1.6; }
.cp-msg { font-size: var(--fs-sm); line-height: 1.55; border-radius: 12px; padding: .7rem .9rem; max-width: 92%; }
.cp-user { background: rgba(201,168,76,.12); color: var(--cream); align-self: flex-end; border-bottom-right-radius: 3px; }
.cp-ai { background: var(--card); border: 1px solid var(--border); color: var(--cream); align-self: flex-start; border-bottom-left-radius: 3px; }
.cp-ai .who { display: block; font-size: var(--fs-xs); color: var(--gold); margin-bottom: .3rem; }
.cp-msg.typing { opacity: .6; }
.cp-action { align-self: flex-start; max-width: 92%; background: rgba(201,168,76,.07);
  border: 1px solid rgba(201,168,76,.35); border-radius: 12px; padding: .7rem .9rem; }
.cp-action-label { font-size: var(--fs-sm); color: var(--gold-2); margin-bottom: .5rem; }
.cp-action-btns { display: flex; gap: .4rem; }
.cp-input-row { display: flex; gap: .5rem; padding: .8rem 1rem; border-top: 1px solid var(--border); align-items: flex-end; }
.cp-input-row textarea { flex: 1; resize: none; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; color: var(--cream); padding: .6rem .7rem; font: inherit; font-size: var(--fs-sm); max-height: 120px; }
.cp-input-row .btn { padding: .55rem .9rem; }
@media (max-width: 640px) { .copilot { width: 100vw; } }

/* External portal links in the sidebar */
.side-ext{opacity:.5;font-size:.82em;margin-left:.15em}
