/* =========================================================================
   PV-COPILOT — light-gray editorial / agent-chat layout
   Append this block to your existing assets/style.css

   Fonts: Arial (sans body/UI) and Times New Roman (serif accents).
   No web fonts loaded — both are system fonts on every OS.
   ========================================================================= */

/* All rules scoped under .pvcopilot-root so the rest of pvtools is unaffected */

.pvcopilot-root {
    font-family: Arial, sans-serif;
    color: #0f172a;
    background: #f8fafc;
    font-size: 15px;   /* base body size — bumped from default */
    line-height: 1.55;
}

.pvcopilot-root ::-webkit-scrollbar { width: 8px; height: 8px; }
.pvcopilot-root ::-webkit-scrollbar-track  { background: transparent; }
.pvcopilot-root ::-webkit-scrollbar-thumb  { background: #cbd5e1; border-radius: 4px; }
.pvcopilot-root ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Slide-in animation (separate keyframe so it doesn't collide with pvtools' existing slideInUp) */
@keyframes pvcopilot-slide-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pvcopilot-root .agent-msg {
    animation: pvcopilot-slide-in-up 0.5s ease-out both;
}

/* Buttons inside the copilot get a subtle hover lift */
.pvcopilot-root button {
    transition: all 0.15s ease;
}
.pvcopilot-root button:hover:not(:disabled) {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.pvcopilot-root button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

/* Stepper row hover — subtle hover so it's obvious they're clickable */
.pvcopilot-root div[id*='step-row'] {
    cursor: pointer;
}
.pvcopilot-root div[id*='step-row']:hover {
    background: #f1f5f9 !important;
}

/* Chat — typing animation */
@keyframes pvcopilot-blink {
    0%, 50%   { opacity: 1; }
    51%, 100% { opacity: 0; }
}
.pvcopilot-root .chat-typing-caret {
    display: inline-block;
    margin-left: 1px;
    color: #0064AB;
    animation: pvcopilot-blink 0.9s steps(2, end) infinite;
    font-weight: 400;
}
/* Once the bubble is done typing, kill the caret entirely:
   stop the keyframe animation AND hide the element. */
.pvcopilot-root .chat-bubble-done .chat-typing-caret {
    animation: none !important;
    display: none !important;
}

/* Chat — thinking dots (pre-first-character pulse) */
@keyframes pvcopilot-dots-pulse {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 1; }
}
.pvcopilot-root .chat-thinking-dots {
    animation: pvcopilot-dots-pulse 1.2s ease-in-out infinite;
}

/* Chat — bubble fade-in on mount */
@keyframes pvcopilot-bubble-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.pvcopilot-root #chat-history > div {
    animation: pvcopilot-bubble-in 0.25s ease-out both;
}

/* Chat — example chip hover */
.pvcopilot-root button[id*='chat-example']:hover {
    background: #f8fafc !important;
    border-color: #0064AB !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 100, 171, 0.12);
}

/* Example dataset buttons in Step 1: on hover, text + border shift to navy */
.pvcopilot-root button[id*='load-example-btn']:hover,
.pvcopilot-root button[id*='load-example-btn']:hover * {
    color: #0064AB !important;
    border-color: #0064AB !important;
}

/* Chat — composer input bold (both typed text and placeholder) */
.pvcopilot-root #chat-composer,
.pvcopilot-root #chat-composer::placeholder {
    font-weight: 700 !important;
}
/* Chat — composer is on a blue background; make text + placeholder + caret white */
.pvcopilot-root #chat-composer {
    color: #ffffff !important;
    caret-color: #ffffff !important;
    /* Override the global input[type="text"] 14px rule below -- the chat
       composer is the page's primary input and should read larger. */
    font-size: 17px !important;
}
.pvcopilot-root #chat-composer::placeholder {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 17px !important;
}

/* <details>/<summary>: replace the default flush-against-text disclosure
   triangle with a custom CSS triangle that has a real gap before the text. */
.pvcopilot-root summary {
    list-style: none;
    cursor: pointer;
    position: relative;
    padding-left: 18px;
}
/* Remove the native marker in WebKit / Firefox / others */
.pvcopilot-root summary::-webkit-details-marker { display: none; }
.pvcopilot-root summary::marker { content: ""; }

/* Custom triangle (closed = ▸, open = ▾) — positioned absolutely so the
   text-left padding controls the actual gap. */
.pvcopilot-root summary::before {
    content: "▸";
    position: absolute;
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9em;
    transition: transform 0.15s ease;
}
.pvcopilot-root details[open] > summary::before {
    content: "▾";
}

/* Radio labels — keep inherited color (avoid Bootstrap link-blue / purple
   :visited bleed).  The parent app's style.css has this rule scoped to the
   single id #metric-selected-visible.  Now that we split the metric chooser
   into two visible RadioItems (stat vs PVPRO) plus a hidden master, the
   parent rule no longer covers the visible ones -- so without the addition
   below they fall through to Bootstrap's default link color (often rendered
   purple due to the browser's :visited state on the underlying anchor). */
.pvcopilot-root .metric-radio-label,
.pvcopilot-root .metric-radio-label:hover,
.pvcopilot-root .metric-radio-label:focus,
.pvcopilot-root .metric-radio-label:active,
.pvcopilot-root .metric-radio-label:visited,
.pvcopilot-root .metric-radio-label *,
.pvcopilot-root #metric-stat-radio .form-check-label,
.pvcopilot-root #metric-stat-radio .form-check-label:hover,
.pvcopilot-root #metric-stat-radio .form-check-label:focus,
.pvcopilot-root #metric-stat-radio .form-check-label:active,
.pvcopilot-root #metric-stat-radio .form-check-label:visited,
.pvcopilot-root #metric-stat-radio .form-check-label *,
.pvcopilot-root #metric-pvpro-radio .form-check-label,
.pvcopilot-root #metric-pvpro-radio .form-check-label:hover,
.pvcopilot-root #metric-pvpro-radio .form-check-label:focus,
.pvcopilot-root #metric-pvpro-radio .form-check-label:active,
.pvcopilot-root #metric-pvpro-radio .form-check-label:visited,
.pvcopilot-root #metric-pvpro-radio .form-check-label * {
    color: inherit !important;
    text-decoration: none !important;
}

/* dcc.RadioItems renders each option as a <label> (no class).  The above
   rule only covers labels with className="metric-radio-label" OR labels
   inside the metric radios with the Bootstrap class.  Also catch plain
   <label> children inside the two metric radios as a belt-and-braces
   measure. */
.pvcopilot-root #metric-stat-radio label,
.pvcopilot-root #metric-stat-radio label:hover,
.pvcopilot-root #metric-stat-radio label:visited,
.pvcopilot-root #metric-stat-radio label *,
.pvcopilot-root #metric-pvpro-radio label,
.pvcopilot-root #metric-pvpro-radio label:hover,
.pvcopilot-root #metric-pvpro-radio label:visited,
.pvcopilot-root #metric-pvpro-radio label * {
    color: #0f172a !important;        /* INK */
    text-decoration: none !important;
}

/* PVPRO radio option: lay out so the input + label content sit side-by-
   side, and the label-content span fills the remaining row width.
   Dash's dcc.RadioItems renders each option as:
       <label class="dash-options-list-option">
         <span class="dash-options-list-option-wrapper"><input ...></span>
         <span class="dash-options-list-option-text">{our content}</span>
       </label>
   We flex the label so the two inner spans become flex siblings, then
   give the text span flex:1 so it stretches.  This is what finally lets
   the inner title-row Div (with the logo pinned right) get the full row
   width to push the logo to the right edge. */
.pvcopilot-root #metric-pvpro-radio .dash-options-list-option {
    display: flex !important;
    align-items: flex-start !important;
    width: 100% !important;
}
.pvcopilot-root #metric-pvpro-radio .dash-options-list-option-wrapper {
    flex-shrink: 0;
    /* No margin-top -- alignment is handled by line-height:1 on the
       title row so the radio dot center lines up with PVPRO's cap-height. */
}
.pvcopilot-root #metric-pvpro-radio .dash-options-list-option-text {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: block !important;
}
/* Top-align the radio input with the "PVPRO" text.  The default 1.55
   body line-height adds vertical space above the glyph; tightening just
   the title row to line-height:1 brings the text up to where the radio
   dot is sitting. */
.pvcopilot-root #metric-pvpro-radio .dash-options-list-option-text
       > div:first-child {
    line-height: 1.1 !important;
}

/* Exception: the IMPORTANT badge needs to keep its white text against the
   navy pill background -- otherwise the rules above force it to inherit
   the ink-dark label color and the badge becomes unreadable.  The selector
   has to match or exceed the specificity of the #metric-*-radio rules
   that force INK, so we list every radio-scoped form explicitly. */
.pvcopilot-root .important-badge,
.pvcopilot-root .important-badge *,
.pvcopilot-root #metric-stat-radio  .important-badge,
.pvcopilot-root #metric-stat-radio  .important-badge *,
.pvcopilot-root #metric-pvpro-radio .important-badge,
.pvcopilot-root #metric-pvpro-radio .important-badge *,
.pvcopilot-root #metric-stat-radio  label .important-badge,
.pvcopilot-root #metric-stat-radio  label .important-badge *,
.pvcopilot-root #metric-pvpro-radio label .important-badge,
.pvcopilot-root #metric-pvpro-radio label .important-badge * {
    color: #ffffff !important;
}

/* <details>/<summary> caret styling */
.pvcopilot-root details > summary {
    list-style: none;
    font-size: 14px;
}
.pvcopilot-root details > summary::-webkit-details-marker {
    display: none;
}
.pvcopilot-root details > summary::before {
    content: "▸ ";
    transition: transform 0.2s;
    display: inline-block;
    color: #64748b;
}
.pvcopilot-root details[open] > summary::before {
    content: "▾ ";
}

/* Recolor dash-bootstrap checkboxes to NAVY (matches the rest of the app's
   accents).  This is what wins over the inline `accentColor: NAVY` set on
   the Python side, because Bootstrap's .form-check-input rule is also
   !important.  Keep both in sync. */
.pvcopilot-root .form-check-input:checked {
    background-color: #0064AB !important;
    border-color:     #0064AB !important;
}
.pvcopilot-root .form-check-input:focus {
    border-color:     #0064AB !important;
    box-shadow: 0 0 0 0.15rem rgba(0, 100, 171, 0.18) !important;
}

/* Hide the legacy page-title only inside the copilot */
.pvcopilot-root .page-title {
    display: none;
}

/* Inputs and number fields — readable size */
.pvcopilot-root input[type="text"],
.pvcopilot-root input[type="number"] {
    font-size: 14px !important;
    font-family: Arial, sans-serif;
}

/* Plotly default override */
.pvcopilot-root .js-plotly-plot {
    font-size: 13px;
}

/* Responsive: on narrow screens, stack the two panels vertically.
   At wider breakpoints (>= 900px) they sit side-by-side. */
@media (max-width: 900px) {
    .pvcopilot-root .pvcopilot-shell {
        flex-direction: column !important;
        gap: 16px !important;
    }
    /* Both sidebar-render wrapper and chat panel take the full width */
    .pvcopilot-root .pvcopilot-shell > div {
        width: 100% !important;
        max-width: 100% !important;
    }
    /* Drop fixed heights so each panel grows to its natural content height. */
    .pvcopilot-root .pvcopilot-shell > div > div,
    .pvcopilot-root .pvcopilot-shell > div:nth-child(2),
    .pvcopilot-root #sidebar-render > div {
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: visible !important;
    }
    /* The sidebar uses a flex:1 spacer to push About + Sign in to the bottom
       on wide screens. On mobile that creates a giant blank gap — collapse it. */
    .pvcopilot-root #sidebar-render > div > div[style*="flex: 1"],
    .pvcopilot-root #sidebar-render > div > div[style*="flex:1"] {
        flex: 0 0 auto !important;
        height: 0 !important;
    }
}