/*
 * sd-notes-reader.css — visual parity with the production CI2 notes reader
 * (notes.shuledirect.co.tz notes_view.php + study-guide-style.css).
 *
 * The ported public CSS (main.css / study-guide-style.css) styles most of the
 * reader, but a few CI2 rules live in the legacy theme's cascade and don't
 * survive the port cleanly. This scoped sheet restores them, matching the exact
 * colors/typography measured against production:
 *
 *   - subtopic accordion header: blue when collapsed, orange when open
 *   - concept DisplayName title: the tan "study-guide" bar
 *   - topic heading: uppercase proxima-nova-style, not the site heading font
 *
 * Scoped under #student-notes so nothing here leaks into other pages.
 */

/* ── Topic heading (CI2: proxima-nova, uppercase, #333, ~28px) ───────────── */
#student-notes .topic-title-div h4 {
    /* school.css forces `h4 { font-family: Chalkboard !important }`, so this
       needs !important too to restore the CI2 proxima-nova topic heading. */
    font-family: "proxima-nova", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    font-size: 28px;
    /* 300 — the OLD site's computed weight for the `.topic` heading (measured
       live on CI2 notes/list_notes). !important for the same reason as the
       font-family line: CI2 rendered this heading as a DIV, this port uses an
       h4, and school.css carries `h4 { font-weight: normal !important }`. */
    font-weight: 300 !important;
    text-transform: uppercase;
    color: #333;
    margin: 18px 0 10px;
}

/* ── Subtopic accordion header (CI2 colors) ─────────────────────────────── */
/* Collapsed = ShuleDirect blue on the light-gray bar. */
#student-notes .subtopic-div .subtopic-title-text,
#student-notes .subtopic-div .subtopic {
    color: #29B1E9;
    /* 400 — the OLD site's accordion header weight (500 was a drift). */
    font-weight: 400;
}
/* Open/active = ShuleDirect orange on white (jQuery-UI adds ui-state-active). */
#student-notes .subtopic-div.ui-state-active .subtopic-title-text,
#student-notes .subtopic-div.ui-state-active .subtopic {
    color: #EB8F00;
}
#student-notes .subtopic-div:hover .subtopic-title-text,
#student-notes .subtopic-div:hover .subtopic {
    color: #CC814A;
}

/* ── Concept DisplayName title (CI2: the tan study-guide bar, class .concept) ─ */
#student-notes .concept-name-header {
    background: #ECDFBD;
    border: 1px solid #ECDFBD;
    padding: 10px !important;
    margin-top: 10px !important;
    line-height: 22px;
    font-size: 20px;
    color: #333;
}

/* ── Concept OWN content shown under the heading (CI2 main.css:987 .concept-full):
   the italic gray, right-aligned objective note with a right rule. ───────────── */
#student-notes .concept-full {
    font-style: italic;
    font-size: 0.8em;
    color: gray;
    text-align: right;
    margin: 15px 0;
    border-right: 5px solid #ccc;
    line-height: 15px;
    padding-right: 5px;
}

/* ══════════════════════════════════════════════════════════════════════════
   LSEN accessibility toolbar + "Listen" TTS + language toggle — ported from
   CI2 lsen_accessibility.js (injected styles) and notes_view.php:633-714
   (Listen bar / floating button). Behaviour lives in sd-notes-reader.js.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── LSEN toolbar (inline above the notes content) ──────────────────────── */
/* Accessibility (LSEN) tools — a fixed VERTICAL dock on the LEFT edge, mid-height
   (the Listen control sits bottom-right, so the two never collide). Collapses back
   to an in-flow horizontal bar on narrow screens so it never covers the notes. */
#lsen-bar {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 9997;
    background: #2c3e50;
    padding: 8px 6px;
    border-radius: 0 8px 8px 0;
    margin: 0;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.25);
}
.lsen-bar-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
}
.lsen-bar-label {
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    margin: 0 0 4px;
    line-height: 1.2;
}
/* Vertical dock: the "|" separators become thin divider rules. */
.lsen-bar-sep {
    color: transparent;
    font-size: 0;
    border-top: 1px solid #5a6c7d;
    margin: 3px 4px;
    align-self: stretch;
}
#lsen-bar button {
    background: #3d566e;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 6px 8px;
    min-width: 36px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}
#lsen-bar button:hover { background: #4a6a85; }
#lsen-bar button.lsen-active { background: #29B1E9; }

/* Make room for the fixed left dock so it never overlaps the notes text — scoped
   to the reader page only (the container that actually holds #lsen-bar), and ONLY
   on the student/production view: during an edit session (#editing-mode rendered —
   Begin Edits / Begin Admin Editing) the dock is hidden and the padding removed so
   the dual-pane editor keeps its full original layout. */
@media (min-width: 901px) {
    .content:has(#lsen-bar):not(:has(#editing-mode)) { padding-left: 104px; }
}
.content:has(#editing-mode) #lsen-bar { display: none; }

/* Narrow screens: no room for a side dock — return to an in-flow horizontal bar. */
@media (max-width: 900px) {
    #lsen-bar {
        position: static;
        transform: none;
        border-radius: 6px;
        margin: 10px 0;
        padding: 8px 12px;
        max-height: none;
        box-shadow: none;
    }
    .lsen-bar-row {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 4px;
    }
    .lsen-bar-label { font-size: 11px; text-align: left; margin: 0 6px 0 0; }
    .lsen-bar-sep {
        color: #5a6c7d;
        font-size: 12px;
        border-top: 0;
        margin: 0 2px;
        align-self: auto;
    }
    #lsen-bar button { padding: 4px 6px; font-size: 11px; min-width: 0; }
}

/* ── Text size / line spacing (CSS vars set by sd-notes-reader.js) ─────────
   The html.lsen-typography gate engages only once the learner sets a pref, so
   the default reader typography is untouched until then. */
html.lsen-typography #student-notes p,
html.lsen-typography #student-notes li,
html.lsen-typography #student-notes .paragraph,
html.lsen-typography #student-notes .header-notes {
    font-size: var(--lsen-font-size, 100%) !important;
    line-height: var(--lsen-line-height, 1.6) !important;
}

/* ── Contrast modes (body classes, as in CI2) ───────────────────────────── */
body.lsen-high-contrast #student-notes { background: #fff !important; }
body.lsen-high-contrast #student-notes * { color: #000 !important; }

body.lsen-dark-mode,
body.lsen-dark-mode .content { background: #1a1a2e !important; }
body.lsen-dark-mode #student-notes,
body.lsen-dark-mode #student-notes * {
    color: #e0e0e0 !important;
    background-color: transparent !important;
}
body.lsen-dark-mode #lsen-bar { background: #0d1b2a; }
body.lsen-dark-mode .lsen-tts-active { background: #2d2d44 !important; }

body.lsen-yellow-black,
body.lsen-yellow-black .content { background: #000 !important; }
body.lsen-yellow-black #student-notes,
body.lsen-yellow-black #student-notes * {
    color: #ffff00 !important;
    background-color: transparent !important;
}
body.lsen-yellow-black #lsen-bar { background: #1a1a00; }
body.lsen-yellow-black #lsen-bar button { background: #333300; color: #ffff00; }

/* ── TTS active-paragraph highlight ─────────────────────────────────────── */
.lsen-tts-active {
    background: #fff3cd !important;
    border-left: 3px solid #ffc107 !important;
    padding-left: 8px !important;
}

/* ── Listen control bar (fixed bottom) + floating button ────────────────── */
#listen-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a2e;
    color: #fff;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 9999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
#listen-bar.visible { transform: translateY(0); }
#listen-bar .listen-title {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
}
#listen-bar button {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}
#listen-bar button:hover { background: rgba(255, 255, 255, 0.15); }
#listen-bar #listen-close-btn {
    border-radius: 4px;
    width: auto;
    padding: 0 10px;
    font-size: 13px;
}
#listen-bar .listen-progress {
    font-size: 12px;
    opacity: 0.7;
    min-width: 60px;
    text-align: right;
}
/* Listen START button lives inside the accessibility dock (#lsen-bar) and inherits
   its button styling; sd-notes-reader.js still toggles .hidden while playing. */
#listen-float-btn.hidden { display: none; }

/* ── English/Kiswahili toggle (CI2 notes-translation-toggle-language) ───── */
.notes-language-toggle {
    display: inline-flex;
    border: 1px solid #29B1E9;
    border-radius: 4px;
    overflow: hidden;
    margin: 6px 0 10px;
}
.notes-language-toggle a {
    padding: 5px 14px;
    font-size: 13px;
    color: #29B1E9;
    text-decoration: none;
}
.notes-language-toggle a.active {
    background: #29B1E9;
    color: #fff;
}

/* ── Sticky topic header + topic-switcher (NOTES parity, CI2 notes_view.php:972-1147) ──
   Pins the active topic's title + "X of Y Subtopics Complete" (mirrors the progress
   bar below it) to the top of the reader content column as the learner scrolls, and
   offers a <select> that reuses the sidebar's ?topic= navigation. */
.sd-sticky-topic-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    padding: 10px 12px;
    margin: 0 0 10px;
}
.sd-sticky-topic-header-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 14px;
    min-width: 0;
}
.sd-sticky-topic-title {
    font-family: "proxima-nova", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}
.sd-sticky-topic-progress {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
}
.sd-sticky-topic-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
}
.sd-sticky-topic-switcher-label {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}
.sd-sticky-topic-switcher select {
    padding: 5px 8px;
    font-size: 13px;
    color: #333;
    background: #fff;
    border: 1px solid #d5d7db;
    border-radius: 4px;
    max-width: 220px;
}
.sd-sticky-topic-switcher select:focus {
    outline: 2px solid #29B1E9;
    outline-offset: 1px;
}
@media (max-width: 600px) {
    .sd-sticky-topic-header { padding: 8px 10px; }
    .sd-sticky-topic-title { font-size: 15px; max-width: 100%; }
    .sd-sticky-topic-switcher select { max-width: 160px; }
}

/* ── Reader action toolbar (Share / Facebook / Print — CI2 notes_view.php:6302-6351) ── */
.notes-action-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 6px 0 10px;
}
.notes-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    font-size: 13px;
    line-height: 1.2;
    color: #444;
    background: #f3f4f6;
    border: 1px solid #d5d7db;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
}
.notes-action-btn:hover { background: #e7e9ec; color: #222; }
.notes-action-btn i { font-size: 14px; }
.notes-share-fb { color: #3b5998; }

/* ── Printer-friendly mode (CI2 printer-friendly.css) ──────────────────────
   Force every accordion panel visible (override jQuery-UI inline display:none),
   drop the chrome, and lay the notes out full-width for print. */
@media print {
    .header, .footer, nav, .breadcrumb,
    .notes-action-toolbar, #lsen-bar, #listen-bar, #listen-float-btn,
    .sidebar, #sidebar-navigation, .large-4.offset-1.columns.sidebar,
    .subjects-button-holder-dv, .attempt-questions-button-container,
    .question-attempts-summary-holder, .notes-language-toggle,
    .topic-progress-bar-container, .view-teacher-notes-button,
    .sd-sticky-topic-header {
        display: none !important;
    }

    /* jQuery-UI collapses non-active panels with an inline display:none — force
       every subtopic body open so the WHOLE subject prints, not one section. */
    .subtopic-children-div,
    .ui-accordion .ui-accordion-content {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }

    .large-8.columns.title,
    #student-mode, #student-notes, .row.notes {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        float: none !important;
    }

    body, .n-single-notes-holder, .concept-div {
        color: #000 !important;
        background: #fff !important;
    }

    .notes-video, .video-container, iframe { display: none !important; }

    a[href]::after { content: ''; } /* no ugly URL expansion */
}

/* Class hook set by sdPrintNotes() just before window.print() (JS-driven expand). */
body.sd-printing .subtopic-children-div { display: block !important; }

/* ── Subtopic accordion HEADER bar (design fix) ─────────────────────────────
   jQuery-UI's .ui-helper-reset (loaded after main.css, same specificity) zeroes
   the padding/margins main.css:951 gives .subtopic-div, leaving a shrunken bare
   strip. Restore the intended CI2 bar with higher specificity — values from the
   old palette only (#EAE8E8 bar, #f4f4f4 border from main.css). */
#student-notes .subtopic-div.ui-accordion-header {
    background-color: #EAE8E8 !important;
    border: 1px solid #f4f4f4;
    padding: 10px 12px 10px 2.2em; /* keep the jQuery-UI icon indent */
    margin: 14px 0 8px 0;
    min-height: 0;
    line-height: 1.4;
    border-radius: 3px;
}
#student-notes .subtopic-div .subtopic-title-text {
    /* 20px — the OLD site's `.subtopic` accordion-header size (17px was a drift). */
    font-size: 20px;
    vertical-align: middle;
}
/* Centre the expand/collapse triangle on the taller bar. */
#student-notes .subtopic-div .ui-accordion-header-icon {
    top: 50%;
    margin-top: -8px;
}
/* Viewed/read marker sits off the title, not glued to it. */
#student-notes .subtopic-div .read-state-marker {
    margin-left: 10px;
    font-size: 12px;
    vertical-align: middle;
}

/* ── Inline notes images (CI2 .notes-image parity) ───────────────────────── */
/* The reader emits bare <img class="notes-inline-image"> with no layout rule,
 * so they fall back to Foundation's base `img { display:inline-block;
 * vertical-align:middle; margin:0 }` — two adjacent images then touch/overlap
 * and misalign. Mirror the old main.css .notes-image: a responsive cap plus
 * breathing room so a demonstration pair sits side-by-side with a gap (and
 * wraps cleanly), and single large images fill the column. */
/* Unscoped on purpose: `notes-inline-image` is notes-specific, and the images
 * appear in THREE places — the reader (#student-notes), and the dual-pane editor
 * panes (#original-notes / #draft-notes) which live OUTSIDE #student-notes. A
 * #student-notes scope left the edit-side images on Foundation's inline-block
 * (horizontal/overlapping). Target the class directly so all three match. */
img.notes-inline-image {
    /* One image per line (vertical), each at its NATIVE size. max-width:100%
     * only shrinks an image that is wider than the notes column so it never
     * overflows; smaller images keep their own dimensions. 16px vertical
     * spacing so stacked images don't touch each other or the text. */
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px 0;
    padding: 4px;
    box-sizing: border-box;
    border-radius: 4px;
}

/* Image caption (media row `description`) shown under the image. */
.notes-figure {
    display: block;
    margin: 16px 0;
    padding: 0;
}
.notes-figure img.notes-inline-image {
    margin: 0 0 4px 0; /* the figure owns the outer spacing; caption hugs the image */
}
.notes-figcaption {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
    line-height: 1.3;
    padding: 0 4px;
}

/* ── Media loading states (sd-notes-reader.js media loaders) ─────────────── */
/* Image shimmer while loading. */
img.notes-inline-image.sd-media-loading {
    min-height: 120px;
    background: linear-gradient(100deg, #eee 30%, #f6f6f6 50%, #eee 70%);
    background-size: 200% 100%;
    animation: sdMediaShimmer 1.2s ease-in-out infinite;
    border-radius: 4px;
}
img.notes-inline-image.sd-media-ready { animation: sdMediaFadeIn .3s ease-out; }
@keyframes sdMediaShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@keyframes sdMediaFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Broken-image / failed-media fallback card. */
.sd-media-error {
    display: flex; align-items: center; justify-content: center;
    min-height: 90px; padding: 12px; margin: 8px 0;
    border: 1px dashed #d3a29a; border-radius: 6px;
    background: #FCF9EF; color: #871619; font-size: 13px; font-weight: bold;
}

/* Centered spinner overlay for PDF / HTML iframe embeds while they load. */
.sd-media-spin {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 10px;
    /* Light + click-through: it must never block or hide the media rendering
       underneath — it is only a brief "loading" hint. */
    background: rgba(255,255,255,.55); border-radius: 4px; z-index: 2;
    pointer-events: none;
}
.sd-media-spinner {
    width: 34px; height: 34px; border-radius: 50%;
    border: 4px solid #e2e2e2; border-top-color: #871619;
    animation: sdMediaSpin .8s linear infinite;
}
.sd-media-spin-label { font-size: 12px; color: #555; max-width: 80%; text-align: center; }
@keyframes sdMediaSpin { to { transform: rotate(360deg); } }

/* ── AI Content Studio panel ────────────────────────────────────────────────
   Styled to MATCH the notes editor dialog (notes_editor_styling.css): same
   fonts, the same #007cba primary / #28a745 success / #6c757d secondary
   buttons, 2px #dee2e6 inputs with the #007cba focus ring, #f8f9fa surfaces
   and 6-8px radii — so the AI form reads as part of the same editing suite. */
.sd-ai-overlay {
    position: fixed; inset: 0; z-index: 10050;
    background: rgba(0,0,0,0.35);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px; overflow: auto;
}
.sd-ai-panel {
    width: 100%; max-width: 640px; background: #fff; border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25); overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.sd-ai-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; background: #f8f9fa; color: #333;
    font-weight: 600; font-size: 15px; border-bottom: 1px solid #dee2e6;
}
.sd-ai-x {
    background: transparent; border: 0; color: #6c757d; font-size: 22px;
    line-height: 1; cursor: pointer; padding: 0 4px;
}
.sd-ai-x:hover { color: #333; }
.sd-ai-context {
    padding: 8px 20px; background: #fff; font-size: 12px; color: #6c757d;
    border-bottom: 1px solid #e9ecef; line-height: 1.4;
}
.sd-ai-hint {
    margin-top: 5px; font-size: 12px; color: #6c757d; font-style: italic; line-height: 1.4;
}
.sd-ai-body { padding: 20px; }
.sd-ai-label {
    display: block; font-weight: 600; margin: 14px 0 5px; color: #495057;
    font-size: 14px;
}
.sd-ai-label:first-child { margin-top: 0; }
.sd-ai-input {
    width: 100%; box-sizing: border-box; padding: 10px 15px;
    border: 2px solid #dee2e6; border-radius: 6px; font-size: 14px;
    background: #fff; font-family: inherit;
    transition: border-color 0.3s ease;
}
.sd-ai-input:focus {
    outline: none; border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}
.sd-ai-actions {
    margin-top: 16px; display: flex; gap: 10px; justify-content: flex-end;
}
/* Buttons mirror .ui-dialog-buttonset in notes_editor_styling.css. */
.sd-ai-btn {
    padding: 10px 20px; border-radius: 6px; font-weight: 600; font-size: 14px;
    cursor: pointer; border: 1px solid transparent; transition: all 0.3s ease;
}
.sd-ai-btn[disabled] { opacity: 0.65; cursor: default; }
.sd-ai-btn-primary { background: #007cba; color: #fff; border-color: #007cba; }
.sd-ai-btn-primary:hover:not([disabled]) { background: #0056b3; border-color: #0056b3; }
.sd-ai-btn-success { background: #28a745; color: #fff; border-color: #28a745; }
.sd-ai-btn-success:hover:not([disabled]) { background: #218838; border-color: #218838; }
.sd-ai-btn-secondary { background: #6c757d; color: #fff; border-color: #6c757d; }
.sd-ai-btn-secondary:hover:not([disabled]) { background: #545b62; border-color: #545b62; }
.sd-ai-error {
    margin-top: 12px; padding: 8px 12px; border-radius: 4px;
    background: #f8d7da; color: #dc3545; border: 1px solid #f5c6cb; font-size: 12px;
}
.sd-ai-preview-wrap {
    margin-top: 16px; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden;
}
.sd-ai-preview-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 15px; background: #f8f9fa; border-bottom: 1px solid #dee2e6;
    font-size: 12px; color: #495057; font-weight: 600;
}
.sd-ai-qa { font-size: 12px; padding: 1px 8px; border-radius: 10px; color: #fff; }
.sd-ai-qa-ok { background: #28a745; }
.sd-ai-qa-warn { background: #DAA520; }
.sd-ai-preview {
    padding: 15px; max-height: 320px; overflow: auto; font-size: 15px;
    line-height: 1.5; color: #222;
}
.sd-ai-preview p { margin: 0 0 10px; }
.sd-ai-preview ol, .sd-ai-preview ul { margin: 0 0 10px 22px; }
.sd-ai-flags {
    margin: 0; padding: 8px 15px 8px 30px; background: #fff3cd;
    border-top: 1px solid #ffeaa7; font-size: 12px; color: #856404;
}
.sd-ai-preview-note {
    padding: 8px 15px; font-size: 12px; color: #6c757d; font-style: italic;
    border-top: 1px solid #e9ecef; background: #f8f9fa;
}

/* AI panel — mode tabs + image preview */
.sd-ai-mode-tabs {
    display: flex; border-bottom: 1px solid #dee2e6; background: #f8f9fa;
}
.sd-ai-tab {
    flex: 1; padding: 11px 8px; background: transparent; border: 0; cursor: pointer;
    font-weight: 600; font-size: 13px; color: #6c757d; font-family: inherit;
    border-bottom: 3px solid transparent; transition: all 0.3s ease;
}
.sd-ai-tab:hover { color: #495057; background: #e9ecef; }
.sd-ai-tab.active { background: #fff; color: #007cba; border-bottom-color: #007cba; }
/* The ✨ AI editing-tools button: a plain WHITE button (like the others), with
   the "AI" label in yellow/gold and a WHITE star icon. A gold halo on the white
   star keeps it visible on the white button; a darker gold (#c9930c) on the
   label keeps "AI" readable (bright yellow on white is too low-contrast). */
.editing-tools.ai-button {
    background: #fff;
    border: 1px solid #cbb26a;
    font-weight: 700;
}
.editing-tools.ai-button:hover,
.editing-tools.ai-button:focus {
    background: #fffdf5;
    border-color: #d9a406;
}
.editing-tools.ai-button .ai-star {
    color: #fff;
    /* gold halo so the white star reads against the white button */
    text-shadow: 0 0 1.5px #c9930c, 0 0 2.5px #daa520;
}
.editing-tools.ai-button .ai-label {
    color: #d0a000;   /* readable yellow/gold */
}

/* ── Edit-flow processing veil ──────────────────────────────────────────────
   Shown (display:flex via wire:loading.flex) while a toolbar action —
   Submit For Review / Accept Edits / Discard / Cancel / Save — is in flight.
   Blocks EVERY click page-wide until Livewire applies the response, so a
   half-done submit can't be interrupted by another button. */
.sd-flow-veil {
    display: none; position: fixed; inset: 0; z-index: 11000;
    background: rgba(255,255,255,0.6);
    align-items: flex-start; justify-content: center; padding-top: 18vh;
    cursor: wait;
}
.sd-flow-veil-box {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1px solid #dee2e6; border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    padding: 16px 24px; font-size: 15px; font-weight: 600; color: #333;
}
.sd-flow-spinner {
    width: 22px; height: 22px; border-radius: 50%;
    border: 3px solid #dee2e6; border-top-color: #007cba;
    animation: sdFlowSpin 0.8s linear infinite; flex-shrink: 0;
}
@keyframes sdFlowSpin { to { transform: rotate(360deg); } }

/* AI panel — animated progress indicator while a request is processing */
.sd-ai-progress {
    display: none; flex-direction: column; gap: 6px;
    padding: 10px 20px; background: #f4f9fd; border-bottom: 1px solid #cfe5f5;
}
.sd-ai-progress-track {
    height: 6px; border-radius: 3px; background: #dbeaf5; overflow: hidden; position: relative;
}
.sd-ai-progress-bar {
    position: absolute; top: 0; left: -40%; height: 100%; width: 40%;
    border-radius: 3px; background: #007cba;
    animation: sdAiProgress 1.4s ease-in-out infinite;
}
@keyframes sdAiProgress {
    0%   { left: -40%; width: 40%; }
    50%  { left: 30%;  width: 50%; }
    100% { left: 100%; width: 40%; }
}
.sd-ai-progress-text { font-size: 12px; color: #2471a3; font-weight: 600; }

/* AI panel — "write it myself instead" alternative link */
.sd-ai-alt {
    padding: 8px 20px; font-size: 12px; color: #6c757d;
    background: #fff; border-bottom: 1px solid #e9ecef;
}
.sd-ai-alt-link {
    background: none; border: 0; padding: 0; margin-left: 4px; cursor: pointer;
    color: #007cba; font-weight: 600; font-size: 12px; font-family: inherit;
}
.sd-ai-alt-link:hover { text-decoration: underline; }

.sd-ai-img-preview { padding: 15px; text-align: center; background: #f8f9fa; }
.sd-ai-img-preview img {
    max-width: 100%; max-height: 340px; height: auto; border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

/* AI panel — research: raw search results (step 1) */
.sd-ai-results { list-style: none; margin: 6px 0 0; padding: 0; }
.sd-ai-result { padding: 8px 0; border-bottom: 1px solid #eef0f2; }
.sd-ai-result-head { display: flex; align-items: baseline; gap: 6px; cursor: pointer; flex-wrap: wrap; }
.sd-ai-result-head a { color: #007cba; text-decoration: none; font-weight: 600; font-size: 13px; }
.sd-ai-result-head a:hover { text-decoration: underline; }
.sd-ai-result-excerpt { margin: 4px 0 0 22px; font-size: 12px; color: #6c757d; line-height: 1.4; }
.sd-ai-relevance { margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 10px; color: #fff; white-space: nowrap; }
.sd-ai-relevance-ok { background: #28a745; }
.sd-ai-relevance-low { background: #adb5bd; }
.sd-ai-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.sd-ai-image {
    padding: 2px; border: 2px solid #dee2e6; border-radius: 6px; background: #fff;
    cursor: pointer; line-height: 0; transition: border-color 0.2s ease;
}
.sd-ai-image img { width: 88px; height: 88px; object-fit: cover; border-radius: 4px; }
.sd-ai-image:hover { border-color: #adb5bd; }
.sd-ai-image.picked { border-color: #007cba; box-shadow: 0 0 0 2px rgba(0,124,186,0.2); }

/* AI panel — research sources */
.sd-ai-sources { list-style: none; margin: 6px 0 0; padding: 0; }
.sd-ai-sources li { padding: 5px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px; }
.sd-ai-sources label { display: flex; align-items: baseline; gap: 6px; cursor: pointer; }
.sd-ai-src-site { color: #6c757d; font-size: 11px; white-space: nowrap; }
.sd-ai-sources a { color: #007cba; text-decoration: none; }
.sd-ai-sources a:hover { text-decoration: underline; }

/* Review-side AI provenance (Phase 5) */
.sd-ai-provenance {
    margin: 6px 0 10px; padding: 8px 12px; background: #f4f9fd;
    border: 1px solid #cfe5f5; border-radius: 4px; font-size: 13px;
}
.sd-ai-provenance summary { cursor: pointer; font-weight: bold; color: #2471a3; }
.sd-ai-provenance ul { margin: 8px 0 0; padding-left: 18px; }
.sd-ai-provenance li { margin-bottom: 6px; }
.sd-ai-prov-prompt { color: #666; font-style: italic; }
.sd-ai-prov-sources a { color: #3498db; margin-right: 2px; }
