/* ──────────────────────────────────────────────────────────────────────
 * CPP Sharing is Caring
 * Visual language deliberately mirrors cpplinkwiz: indigo (#485fc7)
 * header, white card body, Bulma-ish input/button accents. This keeps
 * the "feels native" experience when users open multiple cpp* modals.
 * ────────────────────────────────────────────────────────────────────── */

/* ---- Navbar trigger ------------------------------------------------- */

/* Icon-only — the .cpp-nav-icon class (added in script.js) gives us the
 * same padding/hover treatment as the other template-rendered icons.
 * No extra styling needed for sizing; the inline SVG carries its own
 * 20×20 attribute. */
.cppsic-trigger {
    cursor: pointer;
}
.cppsic-trigger svg { display: block; }

/* ---- Modal shell ---------------------------------------------------- */

#cppsic {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}
#cppsic[hidden] { display: none; }

#cppsic-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

/* Stack: shared-width column that holds the modal card + the hanging
 * warning banner. Width lives here so the warn lines up exactly with
 * the box edges. The drop shadow also lives here so the box + warn
 * share one shadow envelope (rather than each having their own, which
 * would look detached). */
#cppsic-stack {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 520px;
    max-width: 95vw;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.22));
}

#cppsic-box {
    background: #fff;
    border-radius: 8px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* When the warning is showing, flatten the modal-box's bottom corners
 * so the banner hangs off the bottom as a continuous extension rather
 * than a separate card. */
#cppsic-stack.cppsic-has-warn #cppsic-box {
    border-radius: 8px 8px 0 0;
}

/* ---- Header --------------------------------------------------------- */

#cppsic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #485fc7;
    color: #fff;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    flex-shrink: 0;
}
#cppsic-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
    opacity: 0.8;
}
#cppsic-close:hover { opacity: 1; }

/* ---- Body ----------------------------------------------------------- */

#cppsic-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* Pane-level layout */
.cppsic-pane[hidden] { display: none; }

/* ---- Restricted-page warning (flag off modal bottom) --------------- */
/* Sits flush against the modal-box's bottom edge as a same-width strip
 * that extends downward. The modal-box loses its bottom-rounded corners
 * when this banner is visible (see .cppsic-has-warn above) so the two
 * elements visually merge into one continuous shape. The shared shadow
 * comes from #cppsic-stack so the banner doesn't look detached. */

.cppsic-warn {
    margin: 0;
    padding: 0.7rem 1rem 0.8rem;
    background: #fffbeb;
    border: 1px solid #ffe58f;
    border-top: 0;                  /* seamless with modal-box bottom */
    border-left-width: 4px;
    border-left-color: #f5a623;
    border-radius: 0 0 8px 8px;     /* round only the hanging end */
    font-size: 0.88rem;
    color: #5a4500;
    box-sizing: border-box;
}
.cppsic-warn[hidden] { display: none; }

.cppsic-warn strong {
    display: block;
    margin-bottom: 0.25rem;
    color: #4a3700;
}
.cppsic-warn p { margin: 0; }
.cppsic-warn-msg { margin-top: 0.15rem !important; }
.cppsic-warn-note {
    margin-top: 0.4rem !important;
    font-size: 0.82rem;
    color: #7a6300;
}

/* ---- Pane 1 — main share ------------------------------------------- */

.cppsic-row { margin-bottom: 1rem; }
.cppsic-row:last-child { margin-bottom: 0; }

.cppsic-row > label {
    display: block;
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 0.4rem;
    color: #363636;
}

.cppsic-url-row {
    display: flex;
    gap: 0.5rem;
}
.cppsic-url-row input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dbdbdb;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fafafa;
    color: #363636;
    box-sizing: border-box;
    /* Readonly fields are still selectable; cursor hint reflects that. */
    cursor: text;
}
.cppsic-url-row input:focus {
    outline: none;
    border-color: #485fc7;
    box-shadow: 0 0 0 2px rgba(72, 95, 199, 0.15);
    background: #fff;
}

/* Primary "Copy" button — Link Wizard's indigo. */
.cppsic-copy {
    background: #485fc7;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background-color 0.12s ease;
}
.cppsic-copy:hover  { background: #3a4fa3; }
.cppsic-copy:active { background: #2d3f86; }
.cppsic-copy.cppsic-copied {
    background: #48c774;            /* Bulma success green */
}
.cppsic-copy.cppsic-copied:hover { background: #3ec46c; }

/* Ghost-style "Share a specific section →" button. */
.cppsic-go-sections {
    width: 100%;
    background: #fff;
    color: #485fc7;
    border: 1px solid #485fc7;
    border-radius: 4px;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
    transition: background-color 0.12s ease;
}
.cppsic-go-sections:hover {
    background: #ebefff;
}

/* ---- Pane 2 — section picker --------------------------------------- */

.cppsic-back-row {
    margin-bottom: 0.6rem;
}
.cppsic-back {
    background: none;
    border: none;
    color: #485fc7;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.2rem 0;
    font-family: inherit;
}
.cppsic-back:hover { text-decoration: underline; }

.cppsic-section-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #efefef;
    border-radius: 4px;
    max-height: 55vh;
    overflow-y: auto;
}
.cppsic-section-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #f5f5f5;
    font-size: 0.9rem;
}
.cppsic-section-item:last-child { border-bottom: none; }
.cppsic-section-item:hover     { background: #f0f4ff; }

.cppsic-section-title {
    flex: 1;
    color: #363636;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Compact Copy button inside the list — matches Link Wizard's anchor
 * row density. */
.cppsic-section-list .cppsic-copy {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
}

/* Indent rows by heading level — same scheme as cpplinkwiz anchors. */
.cppsic-h1 .cppsic-section-title { padding-left: 0;       font-weight: 600; }
.cppsic-h2 .cppsic-section-title { padding-left: 0.75rem; }
.cppsic-h3 .cppsic-section-title { padding-left: 1.5rem;  }
.cppsic-h4 .cppsic-section-title { padding-left: 2.25rem; }

.cppsic-empty {
    color: #aaa;
    font-size: 0.88rem;
    padding: 0.6rem;
    text-align: center;
    margin: 0;
}

/* ---- Phones --------------------------------------------------------- */

@media (max-width: 540px) {
    #cppsic-stack {
        width: 100vw;
        max-width: 100vw;
    }
    #cppsic-box {
        max-height: 100vh;
        border-radius: 0;
    }
    .cppsic-warn { border-radius: 0; }
}
