/* ============================================================
   PLATFORM — FundQ extensions over the Anchor foundation.

   Layering contract:
     1. css/anchor.css   — VERBATIM copy of Anchor's globals.css.
                           Never hand-edit; re-copy from
                           Anchor-main/next-app/app/globals.css.
     2. css/platform.css — everything FundQ adds on top (this file).
   New UI must use Anchor's class vocabulary first; only classes
   with no Anchor equivalent belong here. Dark theme only.
   ============================================================ */

/* ---------- meter segment variants (fundraise progress) ---------- */
.meter-seg.committed {
  background: linear-gradient(90deg, #34d399, #10b981);
  box-shadow: 0 0 8px rgba(52, 211, 153, .4);
}

.meter-seg.legals {
  background: linear-gradient(90deg, #38cfe8, #0cb2d1);
  box-shadow: 0 0 8px rgba(56, 207, 232, .3);
}

.meter-seg.dd {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  box-shadow: 0 0 6px rgba(251, 191, 36, .3);
}

.meter-label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 6px;
  font-size: 11px;
}

.meter-label .val {
  font-weight: 700;
  font-family: var(--display);
}

.meter-label .dim {
  color: var(--mut);
}

/* ---------- compact stats grid (workspace overview) ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 20px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-tile .label {
  font-size: 11px;
  color: var(--mut);
  font-weight: 500;
}

.stat-tile .value {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

/* ---------- approval list items (dashboard widget) ---------- */
.approval-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .025);
  transition: all .15s;
  cursor: pointer;
}

.approval-item:hover {
  background: rgba(255, 255, 255, .04);
  border-color: var(--line2);
}

.approval-item .icon-wrap {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 92, 246, .14);
  color: var(--violet2);
}

.approval-item .content {
  flex: 1;
  min-width: 0;
}

.approval-item .title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.approval-item .meta {
  font-size: 11px;
  color: var(--mut);
  margin-top: 2px;
}

/* ---------- approval cards (For Your Approval modal) ---------- */
.approval-card {
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(139, 92, 246, .28);
  border-radius: 10px;
  background: rgba(139, 92, 246, .06);
  display: flex;
  margin-bottom: 8px;
}

.approval-card .approval-content {
  flex: 1;
  min-width: 0;
}

.approval-card .approval-actions {
  display: flex;
  flex: none;
  gap: 6px;
}

/* ---------- digest modal: per-fund sections + compact tiles ----------
   Scoped to .digest-body so Anchor's dashboard .tile is untouched. */
.fundsec {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.fundsec:first-child {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
}

.digest-body .tile {
  padding: 8px 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
}

.digest-body .tile .lab {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--mut);
  font-weight: 600;
  margin-bottom: 4px;
}

.digest-body .tile .val {
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}

/* ---------- digest "needs attention" rows ---------- */
.attention-row {
  padding: 5px 8px;
  border-radius: 8px;
  gap: 10px;
  justify-content: space-between;
  background: rgba(255, 255, 255, .02);
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 3px;
}

.attention-row:hover {
  background: rgba(255, 255, 255, .05);
}

.attention-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink2);
  margin: 10px 0 4px;
}

.attention-group {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 9px;
  margin-top: 5px;
}

/* ---------- notification feed rows ---------- */
.notif-row {
  display: flex;
  gap: 9px;
  width: 100%;
  text-align: left;
  padding: 8px;
  border-radius: 9px;
  align-items: flex-start;
  border: 0;
  cursor: pointer;
  background: transparent;
  transition: background .15s;
  color: inherit;
  font-family: inherit;
}

.notif-row:hover {
  background: rgba(255, 255, 255, .03);
}

.notif-row.unread {
  background: rgba(56, 207, 232, .08);
}

.notif-row.unread:hover {
  background: rgba(56, 207, 232, .12);
}

.notif-dot {
  margin-top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: transparent;
}

.notif-row.unread .notif-dot {
  background: var(--cyan);
}

.notif-content {
  min-width: 0;
  flex: 1;
}

.notif-title {
  font-weight: 400;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-row.unread .notif-title {
  font-weight: 600;
}

/* ---------- dashboard-specific grid ---------- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 18px;
  align-items: start;
}

@media (max-width: 1100px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MOBILE — FundQ's responsive layer (hard requirement).
   Overrides/extends Anchor's own #mobilenav rules; safe-area
   aware. Keep in sync when porting new Anchor screens.
   ============================================================ */
#mobilenav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: none;
  justify-content: space-around;
  background: linear-gradient(180deg, rgba(12, 14, 22, .9), rgba(8, 9, 15, .97));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--line2);
  padding: 7px 4px calc(7px + env(safe-area-inset-bottom));
}

#mobilenav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  color: var(--mut);
  padding: 5px 7px;
  border-radius: 11px;
  white-space: nowrap;
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

#mobilenav button .mn-count {
  position: absolute;
  top: 1px;
  right: calc(50% - 20px);
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--cyan);
  color: #04222a;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mobilenav button.active {
  color: #c8f2fb;
  background: rgba(56, 207, 232, .08);
}

#mobilenav .icon {
  width: 19px;
  height: 19px;
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    display: none !important;
  }

  #mobilenav {
    display: flex;
  }

  .main {
    padding: 0 14px 96px !important;
  }

  .topbar {
    gap: 8px;
    /* Same full-bleed trick as the desktop rule below (repeated here
       because this block is !important and would otherwise win). The old
       values added a 14px gutter INSIDE .main's own 14px, so the bar's
       contents sat at 28px while every panel beneath started at 14px. */
    padding: 12px var(--main-gutter) 10px !important;
    margin: 0 calc(var(--main-gutter) * -1) 20px !important;
    flex-wrap: nowrap;
  }

  .screen-title {
    font-size: 17px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
  }

  .screen-sub {
    display: none;
  }

  .mp-lbl {
    display: none;
  }

  .userchip .nm,
  .userchip .rl {
    display: none;
  }

  .userchip {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
  }

  #toasts {
    left: 12px;
    right: 12px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }

  #chat {
    width: 100vw;
  }

  .chat-sugg {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 10px;
  }

  .chat-sugg button {
    white-space: nowrap;
  }

  .modal {
    width: 94vw !important;
    max-height: 88vh;
  }

  .digest-head {
    padding: 16px 18px 14px;
  }

  .digest-body {
    padding: 8px 18px 20px;
  }

  #notif {
    top: auto;
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
    width: auto;
  }

  .cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .cols-3,
  .cols-2 {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  .screen-title {
    font-size: 16px;
    max-width: 45vw;
  }

  .topbar {
    gap: 6px;
  }

  .cols-4 {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- mobile AI Team modal ---------- */
@media (max-width: 760px) {
  #aiTeamModal > div {
    width: 94vw !important;
  }

  #aiTeamModal [style*="padding: 24px 26px"] {
    padding: 16px 18px !important;
  }

  #aiTeamModal [style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .agent-node {
    padding: 10px 12px;
  }

  .agent-node .an-name {
    font-size: 12px;
  }

  .agent-node .an-role {
    font-size: 10px;
  }

  .agent-node .an-stat {
    margin-top: 6px;
  }

  .agent-node .an-stat .chip {
    font-size: 9px !important;
  }

  .agent-node .an-stat .dim {
    font-size: 9px !important;
  }
}

/* ------------------------------------------------------------------
   Chat: markdown inside agent bubbles.
   The agent answers in markdown — headings, bold, bullets, numbered
   steps — so shell.js renders those to real elements and tags the
   bubble .md. anchor.css keeps .msg on white-space: pre-wrap for plain
   text, which here would preserve every newline BETWEEN blocks and
   double the spacing, so .md turns it off and the elements carry the
   rhythm themselves. Tight margins: this is a 320px drawer, not an
   article column.
   ------------------------------------------------------------------ */
.msg.md {
  white-space: normal;
}
.msg.md > *:first-child { margin-top: 0; }
.msg.md > *:last-child { margin-bottom: 0; }
.msg.md p { margin: 0 0 8px; }
.msg.md h3, .msg.md h4, .msg.md h5, .msg.md h6 {
  margin: 12px 0 6px;
  font-family: 'Space Grotesk', Inter, system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
}
.msg.md h3 { font-size: 14px; }
.msg.md h4 { font-size: 13px; }
.msg.md h5, .msg.md h6 { font-size: 12px; color: var(--ink2); }
.msg.md ul, .msg.md ol { margin: 0 0 8px; padding-left: 18px; }
.msg.md li { margin: 0 0 4px; }
.msg.md li::marker { color: var(--mut); }
.msg.md strong { font-weight: 600; color: var(--ink); }
.msg.md em { font-style: italic; }
.msg.md code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--line);
}

/* ------------------------------------------------------------------
   Topbar: full-bleed background, inset contents.
   .topbar lives inside .main, which carries the page gutter, so the
   sticky bar's gradient stopped short of both edges and read as a
   floating strip rather than a bar. Pull the box out to .main's edges
   and put the gutter back as padding, so only the BACKGROUND widens —
   the logo, buttons and avatar stay exactly where they were.
   The gutter is a variable because anchor.css changes .main's padding
   at two breakpoints (and print); hard-coding one value here would
   leave the bleed mismatched at the others.
   ------------------------------------------------------------------ */
:root { --main-gutter: 34px; }
@media (max-width: 1100px) { :root { --main-gutter: 20px; } }
@media (max-width: 760px)  { :root { --main-gutter: 14px; } }
@media print               { :root { --main-gutter: 0px; } }

.topbar {
  margin-left: calc(var(--main-gutter) * -1);
  margin-right: calc(var(--main-gutter) * -1);
  padding-left: var(--main-gutter);
  padding-right: var(--main-gutter);
}
