/**
 * Intelleqt Platform v2 — Board refit (a0.39.0)
 *
 * Visual alignment of the board page with the v2 work screen: system
 * font stack, slate/indigo light palette, segmented tab pills, ghost
 * toolbar buttons, lighter sidebar cards. Loaded AFTER platform-style
 * so these rules win the cascade without !important wars (used only
 * where a parent theme is known to interfere).
 *
 * Scope: the board page renders standalone AND inside the work screen's
 * Board-mode iframe (embed=1 → body.ip-chrome-modal). Both get the
 * refit — the board should look v2 everywhere it appears.
 */

/* ─── Typography ──────────────────────────────────────────────── */

body.ip-page .ip-wrap,
body.ip-page .ip-board-layout,
body.ip-page .ip-board-tabs {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
}
body.ip-page .ip-board-layout input,
body.ip-page .ip-board-layout textarea,
body.ip-page .ip-board-layout select,
body.ip-page .ip-board-layout button,
body.ip-page .ip-board-tabs button {
    font-family: inherit !important;
}

/* ─── Tab bar → segmented pill group (match the band control) ──── */

body.ip-page .ip-board-tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 10px 16px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #fdfdfe 0%, #f6f7fa 100%);
}
body.ip-page .ip-board-tab {
    background: transparent;
    border: 0;
    color: #475569;
    padding: 5px 14px;
    border-radius: 7px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, box-shadow 120ms ease;
    box-shadow: none;
}
body.ip-page .ip-board-tab:hover { color: #0f172a; background: rgba(15, 23, 42, 0.04); }
body.ip-page .ip-board-tab.ip-board-tab-active,
body.ip-page .ip-board-tab.is-active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
    border: 1px solid rgba(15, 23, 42, 0.06);
}
body.ip-page .ip-board-tab-spacer { flex: 1; }
body.ip-page .ip-board-tab-hint { display: none; }

/* ─── Toolbar → ghost buttons ──────────────────────────────────── */

body.ip-page .ip-board-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
}
body.ip-page .ip-board-tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #475569;
    padding: 5px 10px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
body.ip-page .ip-board-tool-btn:hover:not([disabled]) {
    background: rgba(15, 23, 42, 0.05);
    border-color: rgba(15, 23, 42, 0.08);
    color: #0f172a;
}
body.ip-page .ip-board-tool-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
body.ip-page .ip-board-tool-btn.active,
body.ip-page .ip-board-tool-btn.is-active {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.32);
    color: #6366f1;
}
body.ip-page .ip-board-tool-sep {
    width: 1px;
    height: 18px;
    background: #e2e8f0;
    margin: 0 4px;
}

/* ─── Sidebar (entity palette) ─────────────────────────────────── */

body.ip-page .ip-board-sidebar {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
}
body.ip-page .ip-board-sidebar-search { padding: 10px 10px 6px; }
body.ip-page .ip-board-sidebar-search .ip-text-input {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #0f172a;
    padding: 7px 11px;
    font-size: 13px;
    box-sizing: border-box;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
body.ip-page .ip-board-sidebar-search .ip-text-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}
body.ip-page .ip-board-sidebar-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 10px 8px;
    border-bottom: 1px solid #e2e8f0;
}
body.ip-page .ip-board-sidebar-tab {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #475569;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 100ms ease, color 100ms ease, border-color 100ms ease;
}
body.ip-page .ip-board-sidebar-tab:hover { border-color: #cbd5e1; color: #0f172a; }
body.ip-page .ip-board-sidebar-tab.active {
    background: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.36);
    color: #6366f1;
}
body.ip-page .ip-board-sidebar-list { padding: 8px; }

/* Sidebar entity cards — match the work rail's card language. */
body.ip-page .ip-board-sidebar-list > div,
body.ip-page .ip-board-sidebar-card {
    border: 1px solid #e2e8f0 !important;
    border-radius: 9px !important;
    background: #fff !important;
    box-shadow: none !important;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
body.ip-page .ip-board-sidebar-list > div:hover,
body.ip-page .ip-board-sidebar-card:hover {
    border-color: rgba(99, 102, 241, 0.4) !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07) !important;
}

/* ─── a0.56.0 — Riddle Loop sidebar treatments ─────────────────────
   Gap cards read as OPEN questions (dashed slate border, faint tint);
   dead theories grey out; weakened ones get an amber edge. Status is a
   word, never a number (no fake precision). */
body.ip-page .ip-board-sidebar-card.is-gap {
    border-style: dashed !important;
    border-color: #cbd5e1 !important;
    background: #f8fafc !important;
}
body.ip-page .ip-board-sidebar-card.is-gap:hover {
    border-color: #94a3b8 !important;
}
body.ip-page .ip-board-sidebar-card.is-weakened {
    border-left: 3px solid #f59e0b !important;
}
body.ip-page .ip-board-sidebar-card.is-dead {
    opacity: 0.62;
    background: #f8fafc !important;
}
body.ip-page .ip-board-sidebar-card.is-dead .ip-board-sidebar-card-name {
    text-decoration: line-through;
    color: #94a3b8 !important;
}

/* Loop status / author chips — small outlined pills in the card footer. */
body.ip-page .ip-loop-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
    padding: 2px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #fff;
    white-space: nowrap;
}
body.ip-page .ip-loop-chip-author {
    color: #64748b;
    border-color: #e2e8f0;
}
body.ip-page .ip-board-sidebar-card-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
}
/* Keep the +Add / On-Board control pinned right (the base style used
   justify-content:space-between; flex-wrap drops that, so push via margin
   instead — wraps gracefully on narrow cards while staying right-aligned). */
body.ip-page .ip-board-sidebar-card-footer .ip-board-sidebar-card-status {
    margin-left: auto;
}

/* ─── a0.57.0 — Riddle Loop on-demand bar + proposed-theory controls ── */
body.ip-page .ip-riddle-bar { padding: 0 2px 8px; }
body.ip-page .ip-riddle-btn {
    width: 100%;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 10px;
    font-size: 12px; font-weight: 600;
    color: #4338ca;
    background: linear-gradient(180deg, #eef2ff, #e0e7ff);
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}
body.ip-page .ip-riddle-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #e0e7ff, #c7d2fe);
    border-color: #a5b4fc;
}
body.ip-page .ip-riddle-btn:disabled { opacity: 0.65; cursor: default; }

body.ip-page .ip-board-sidebar-card.is-proposed {
    border-style: dashed !important;
    border-color: #a5b4fc !important;
    background: #fbfbff !important;
}
body.ip-page .ip-riddle-accept,
body.ip-page .ip-riddle-dismiss {
    font-size: 10px; font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid;
    background: #fff;
    cursor: pointer;
}
body.ip-page .ip-riddle-accept { color: #15803d; border-color: #86efac; }
body.ip-page .ip-riddle-accept:hover { background: #f0fdf4; }
body.ip-page .ip-riddle-dismiss { color: #b91c1c; border-color: #fecaca; margin-left: 4px; }
body.ip-page .ip-riddle-dismiss:hover { background: #fef2f2; }

/* ─── a0.58.0 — Gap fill button + modal ────────────────────────────── */
body.ip-page .ip-gap-fill-btn {
    font-size: 10px; font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid #c7d2fe;
    color: #4338ca;
    background: #eef2ff;
    cursor: pointer;
    margin-right: 4px;
}
body.ip-page .ip-gap-fill-btn:hover { background: #e0e7ff; border-color: #a5b4fc; }

.ip-gap-fill-modal {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(15, 23, 42, 0.45);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.ip-gap-fill-card {
    background: #fff;
    border-radius: 14px;
    width: min(520px, 94vw);
    max-height: 88vh; overflow: auto;
    padding: 20px 20px 16px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.32);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}
.ip-gap-fill-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ip-gap-fill-title { font-size: 15px; font-weight: 700; color: #0f172a; }
.ip-gap-fill-close {
    border: 0; background: transparent; font-size: 20px; line-height: 1;
    color: #94a3b8; cursor: pointer; padding: 0 4px;
}
.ip-gap-fill-close:hover { color: #0f172a; }
.ip-gap-fill-q {
    background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 9px;
    padding: 10px 12px; margin-bottom: 14px;
    font-size: 13px; color: #334155; line-height: 1.45;
}
.ip-gap-fill-label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin: 0 0 5px; }
.ip-gap-fill-card textarea {
    width: 100%; box-sizing: border-box;
    border: 1px solid #e2e8f0; border-radius: 9px;
    padding: 10px 12px; font-size: 13px; font-family: inherit; color: #0f172a;
    resize: vertical; margin-bottom: 14px;
}
.ip-gap-fill-card textarea:focus { outline: none; border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99,102,241,0.12); }
.ip-gap-fill-card input[type="file"] { display: block; font-size: 12px; color: #475569; margin-bottom: 16px; }
.ip-gap-fill-actions { display: flex; justify-content: flex-end; gap: 8px; }
.ip-gap-fill-hint { font-size: 12px; color: #b91c1c; margin-top: 10px; min-height: 16px; }

/* ─── Canvas chrome ────────────────────────────────────────────── */

body.ip-page .ip-board-canvas-wrap {
    background: #fbfcfe;
    border: 0;
}

/* ─── Empty state ──────────────────────────────────────────────── */

body.ip-page .ip-board-empty h3 { color: #0f172a; }
body.ip-page .ip-board-empty p  { color: #64748b; }

/* ─── Timeline + Scratchpad panes — light pass for consistency ─── */

body.ip-page .ip-board-tl-header h3 { color: #0f172a; }
body.ip-page .ip-scratchpad-toolbar {
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
}
body.ip-page .ip-scratchpad-tool {
    background: transparent;
    border: 1px solid transparent;
    color: #475569;
    border-radius: 6px;
    cursor: pointer;
}
body.ip-page .ip-scratchpad-tool:hover {
    background: rgba(15, 23, 42, 0.05);
    color: #0f172a;
}

/* ─── Embedded mode (work screen iframe) ───────────────────────── */
/* Tuck everything tighter when iframed — the work screen's band
   already provides identity, so the board page's own header rows
   are redundant chrome (most are already stripped by embed CSS). */
body.ip-chrome-modal .ip-board-tabs { padding-top: 8px; }
body.ip-chrome-modal .ip-wrap { padding: 0 !important; margin: 0 !important; max-width: none !important; }
body.ip-chrome-modal .ip-main-card {
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
}
