/* ==========================================================================
   S34T Admin guidance layer
   Page headers, "?" help drawer, Learn modal, Coach panel, hover tips,
   empty states, clickable KPI cards.

   Everything is namespaced .s34-* and sets its own type/box metrics, so it
   drops cleanly into both the legacy start_X_span_Y grid pages and the newer
   .sd dashboard pages without inheriting from either.
   ========================================================================== */

.s34-hd, .s34-coach, .s34-drawer, .s34-modal, .s34-empty {
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    box-sizing: border-box;
}

/* The legacy pages drop these straight into a 12-column .grid-container, where
   an unpositioned child would collapse into a single column. Declaring the span
   here means views need no wrapper div; on the newer .sd pages the parent isn't
   a grid, so grid-column is simply ignored. */
.s34-hd, .s34-coach, .s34-empty {
    grid-column: 1 / span 12;
}
.s34-hd *, .s34-coach *, .s34-drawer *, .s34-modal *, .s34-empty * {
    box-sizing: border-box;
}

/* ── Page header ─────────────────────────────────────────────────────── */
.s34-hd {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
    padding: 4px 0 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid #E2E8F0;
}
/* Variant for card pages: no <h1> (the card header carries the title), and it
   sits directly above the card so it drops the divider rule and tightens up. */
.s34-hd--bar {
    align-items: center;
    padding: 0 2px 12px;
    margin-bottom: 0;
    border-bottom: 0;
}
.s34-hd--bar .s34-hd-sub { margin-top: 0; }

.s34-hd-main { min-width: 0; }
.s34-hd-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    color: #0F172A;
    letter-spacing: -.01em;
}
.s34-hd-sub {
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: #475569;
    max-width: 68ch;
}
.s34-hd-note {
    margin: 3px 0 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: #94A3B8;
    max-width: 68ch;
}
.s34-hd-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.s34-hd-time {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #64748B;
    white-space: nowrap;
}

/* Buttons here deliberately re-declare everything: base_admin_v2.css styles
   bare <button> as a solid blue block, which is wrong for these. */
.s34-btn-help, .s34-btn-learn {
    font-family: inherit;
    cursor: pointer;
    border-radius: 6px;
    border: 1px solid #CBD5E1;
    background: #fff;
    color: #334155;
    transition: background-color .15s, border-color .15s, color .15s;
}
.s34-btn-help {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    color: #64748B;
}
.s34-btn-help:hover {
    background: #005CB9;
    border-color: #005CB9;
    color: #fff;
}
/* Inline variant, for sitting beside a small button rather than a page title. */
.s34-btn-help--sm {
    width: 21px;
    height: 21px;
    font-size: 12px;
    flex-shrink: 0;
}
.s34-btn-learn {
    height: 30px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.s34-btn-learn:hover {
    background: #F1F5F9;
    border-color: #94A3B8;
    color: #0F172A;
}
.s34-btn-help:focus-visible, .s34-btn-learn:focus-visible,
.s34-chip:focus-visible, .s34-close:focus-visible {
    outline: 2px solid #005CB9;
    outline-offset: 2px;
}

/* ── Coach panel ─────────────────────────────────────────────────────── */
.s34-coach {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 44px 16px 18px;
    margin: 0 0 22px;
    background: linear-gradient(180deg, #F0F7FF 0%, #F8FBFF 100%);
    border: 1px solid #CFE2F7;
    border-radius: 10px;
}
.s34-coach[hidden] { display: none; }
.s34-coach-wave { font-size: 20px; line-height: 1.3; flex-shrink: 0; }
.s34-coach-body { min-width: 0; }
.s34-coach-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #0F172A;
}
.s34-coach-copy {
    margin: 5px 0 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: #395068;
    max-width: 78ch;
}
.s34-coach-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.s34-chip {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 28px;
    padding: 0 11px;
    font-size: 12.5px;
    font-weight: 500;
    color: #1D4E7F;
    background: #fff;
    border: 1px solid #BBD6EE;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .15s, border-color .15s;
}
.s34-chip:hover { background: #E6F1FC; border-color: #8FBEE4; }
.s34-chip--ai { color: #6B3FA0; border-color: #D9C8EE; }
.s34-chip--ai:hover { background: #F4EDFC; border-color: #B794D6; }
.s34-coach-x {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 19px;
    line-height: 1;
    color: #8CA6BE;
    background: transparent;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
}
.s34-coach-x:hover { background: #DEEBF8; color: #395068; }

/* ── Scrim shared by drawer + modal ──────────────────────────────────── */
.s34-scrim {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(15, 23, 42, .45);
    display: flex;
    justify-content: flex-end;
    animation: s34-fade .18s ease-out;
}
.s34-scrim[hidden] { display: none; }
.s34-scrim--center { align-items: center; justify-content: center; padding: 24px; }
@keyframes s34-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes s34-slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes s34-pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Help drawer ─────────────────────────────────────────────────────── */
.s34-drawer {
    width: 100%;
    max-width: 420px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: -8px 0 32px rgba(15, 23, 42, .16);
    animation: s34-slide-in .22s ease-out;
}
.s34-drawer-hd, .s34-modal-hd {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 16px;
    border-bottom: 1px solid #E2E8F0;
    flex-shrink: 0;
}
.s34-drawer-hd h2, .s34-modal-hd h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: #0F172A;
}
.s34-close {
    font-family: inherit;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 21px;
    line-height: 1;
    color: #94A3B8;
    background: transparent;
    border: 0;
    border-radius: 5px;
    cursor: pointer;
}
.s34-close:hover { background: #F1F5F9; color: #0F172A; }
.s34-drawer-bd, .s34-modal-bd {
    padding: 20px 22px 28px;
    overflow-y: auto;
    flex: 1;
}

/* ── Learn modal ─────────────────────────────────────────────────────── */
.s34-modal {
    width: 100%;
    max-width: 520px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 24px 56px rgba(15, 23, 42, .24);
    animation: s34-pop .18s ease-out;
}
.s34-modal-eyebrow {
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #005CB9;
}

/* ── Shared body typography ──────────────────────────────────────────── */
.s34-lede {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.65;
    color: #334155;
}
.s34-h3 {
    margin: 20px 0 10px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .045em;
    text-transform: uppercase;
    color: #64748B;
}
.s34-h3:first-child { margin-top: 0; }
.s34-muted { margin: 0 0 8px; font-size: 13px; color: #64748B; }

.s34-checks, .s34-dots { margin: 0; padding: 0; list-style: none; }
.s34-checks li, .s34-dots li {
    position: relative;
    padding: 0 0 0 26px;
    margin-bottom: 9px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #1E2A3B;
}
.s34-checks li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 5px;
    width: 11px;
    height: 6px;
    border-left: 2px solid #16A34A;
    border-bottom: 2px solid #16A34A;
    transform: rotate(-45deg);
}
.s34-dots li::before {
    content: "";
    position: absolute;
    left: 7px;
    top: 8px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #94A3B8;
}

/* Field-by-field explainer, used by help_topic.php */
.s34-deflist { margin: 0; }
.s34-deflist dt {
    font-size: 13px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 3px;
}
.s34-deflist dd {
    margin: 0 0 14px;
    padding-left: 11px;
    border-left: 2px solid #E2E8F0;
    font-size: 13px;
    line-height: 1.6;
    color: #475569;
}
.s34-deflist dd:last-child { margin-bottom: 0; }

/* Rules of thumb -- numbered, since these are things that bite if ignored. */
.s34-rules {
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: s34rule;
}
.s34-rules li {
    position: relative;
    counter-increment: s34rule;
    padding: 0 0 0 28px;
    margin-bottom: 11px;
    font-size: 13px;
    line-height: 1.55;
    color: #1E2A3B;
}
.s34-rules li::before {
    content: counter(s34rule);
    position: absolute;
    left: 0;
    top: 1px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 10.5px;
    font-weight: 700;
    color: #92400E;
    background: #FEF3C7;
    border-radius: 50%;
}

.s34-tip {
    display: flex;
    gap: 11px;
    margin: 20px 0 0;
    padding: 13px 15px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 8px;
}
.s34-tip-icon { font-size: 15px; line-height: 1.4; }
.s34-tip strong {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: #92400E;
    margin-bottom: 3px;
}
.s34-tip p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: #78350F;
}
.s34-est {
    margin: 20px 0 0;
    padding-top: 15px;
    border-top: 1px solid #E2E8F0;
    font-size: 12.5px;
    color: #64748B;
}
.s34-est strong { color: #0F172A; font-weight: 600; }
/* "Show the welcome guide again" -- the way back from dismissing the Coach */
.s34-restore-wrap {
    margin: 16px 0 0;
    padding-top: 15px;
    border-top: 1px solid #E2E8F0;
}
.s34-restore-wrap[hidden] { display: none; }
.s34-restore {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0;
    font-size: 13px;
    font-weight: 500;
    color: #005CB9;
    background: transparent;
    border: 0;
    cursor: pointer;
}
.s34-restore:hover { text-decoration: underline; }
.s34-restore:focus-visible { outline: 2px solid #005CB9; outline-offset: 2px; }

.s34-cadence {
    margin: 18px 0 0;
    padding: 11px 14px;
    background: #F8FAFC;
    border-left: 3px solid #CBD5E1;
    border-radius: 0 6px 6px 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: #475569;
}

/* ── Empty state ─────────────────────────────────────────────────────── */
.s34-empty {
    max-width: 400px;
    margin: 8px auto;
    padding: 40px 28px 44px;
    text-align: center;
}
.s34-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    margin-bottom: 16px;
    color: #94A3B8;
    background: #F1F5F9;
    border-radius: 50%;
}
.s34-empty-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #0F172A;
}
.s34-empty-lede {
    margin: 7px 0 0;
    font-size: 13.5px;
    color: #64748B;
}
.s34-empty-steps {
    margin: 20px 0 0;
    padding: 0;
    list-style: none;
    text-align: left;
    display: inline-block;
}
.s34-empty-steps li {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 11px;
    font-size: 13.5px;
    color: #1E2A3B;
}
.s34-empty-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 21px;
    height: 21px;
    font-size: 11.5px;
    font-weight: 600;
    color: #005CB9;
    background: #E6F1FC;
    border-radius: 50%;
}
.s34-empty-steps a { color: #005CB9; text-decoration: none; font-weight: 500; }
.s34-empty-steps a:hover { text-decoration: underline; }
.s34-empty-note {
    margin: 18px 0 0;
    font-size: 12.5px;
    color: #94A3B8;
}

/* ── Hover tips ──────────────────────────────────────────────────────── */
/* Attach to any element: <span class="s34-tt" data-s34-tip="...">  */
.s34-tt {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted #94A3B8;
}
.s34-tt::after {
    content: attr(data-s34-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    width: max-content;
    max-width: 230px;
    padding: 8px 11px;
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    text-transform: none;
    text-align: left;
    white-space: normal;
    color: #fff;
    background: #1E2A3B;
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .22);
    opacity: 0;
    visibility: hidden;
    transition: opacity .14s ease-out, visibility .14s;
    pointer-events: none;
}
.s34-tt:hover::after, .s34-tt:focus-visible::after { opacity: 1; visibility: visible; }

/* Right-anchored variant. A centred tooltip on an element near the right edge
   of a .td-card is cut off, because the card sets overflow:hidden to keep its
   own rounded corners. Anchoring to the element's right edge keeps the bubble
   inside the card. Use on anything in a right-hand actions column. */
.s34-tt--right::after { left: auto; right: 0; transform: none; }
/* Mirror for the left edge, same reasoning. */
.s34-tt--left::after { left: 0; right: auto; transform: none; }

/* A bare "i" affordance for tips on labels that shouldn't get a dotted rule */
.s34-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    margin-left: 5px;
    font-size: 10px;
    font-weight: 700;
    font-style: normal;
    line-height: 1;
    color: #fff;
    background: #B6C4D4;
    border-radius: 50%;
    border-bottom: 0;
    vertical-align: middle;
}
.s34-info:hover { background: #64748B; }

/* ── Clickable KPI cards ─────────────────────────────────────────────── */
/* Wraps an existing .sd-kpi in an <a> without disturbing its own styles. */
.s34-kpi-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 12px;
    transition: transform .15s ease-out, box-shadow .15s ease-out;
}
.s34-kpi-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
}
.s34-kpi-link:focus-visible { outline: 2px solid #005CB9; outline-offset: 3px; }
.s34-kpi-cta {
    display: block;
    margin-top: 7px;
    font-size: 11.5px;
    font-weight: 500;
    color: #005CB9;
    opacity: 0;
    transition: opacity .15s ease-out;
}
.s34-kpi-link:hover .s34-kpi-cta { opacity: 1; }
/* Keyboard and touch users never hover -- keep the affordance visible. */
.s34-kpi-link:focus-visible .s34-kpi-cta { opacity: 1; }
@media (hover: none) {
    .s34-kpi-cta { opacity: 1; }
}

/* ── Date range presets ──────────────────────────────────────────────── */
.s34-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 6px;
}
.s34-preset {
    font-family: 'Poppins', system-ui, sans-serif;
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    background: #fff;
    border: 1px solid #CBD5E1;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.s34-preset:hover { background: #F1F5F9; border-color: #94A3B8; }
.s34-preset[aria-pressed="true"] {
    color: #fff;
    background: #005CB9;
    border-color: #005CB9;
}
.s34-preset:focus-visible { outline: 2px solid #005CB9; outline-offset: 2px; }

/* ── Report contents summary ─────────────────────────────────────────── */
.s34-includes {
    padding: 16px 18px;
    margin: 4px 0 0;
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
}
.s34-includes .s34-h3 { margin-top: 0; }
.s34-includes .s34-checks { display: flex; flex-wrap: wrap; gap: 0 28px; }
.s34-includes .s34-checks li { margin-bottom: 6px; }

/* ── Narrow screens ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .s34-hd { gap: 14px; }
    .s34-hd-title { font-size: 20px; }
    .s34-hd-actions { width: 100%; justify-content: flex-start; }
    .s34-drawer { max-width: none; }
    .s34-coach { padding-right: 40px; }
    .s34-includes .s34-checks { gap: 0; }
}
