/*
 * Practice Onboarding layer — additive, metadata-driven guided-workflow + learning system.
 * Empty state, mode toolbar, spotlight tour, "why this field?" help, consultation coach,
 * and sample-case library. Does not alter any clinical form markup or JSON schema.
 */

:root {
    --pob-primary: #0d8a74;
    --pob-primary-dark: #0a6f5d;
    --pob-accent: #2563eb;
    --pob-ink: #0f172a;
    --pob-muted: #64748b;
    --pob-border: #e2e8f0;
    --pob-bg-soft: #f0faf8;
    --pob-warn: #b45309;
    --pob-warn-bg: #fef3c7;
    --pob-radius: 0.75rem;
    --pob-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.25);
}

/* ===================== Toolbar ===================== */
.pob-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.75rem;
    background: #fff;
    border: 1px solid var(--pob-border);
    border-radius: var(--pob-radius);
}
.pob-toolbar-spacer { flex: 1 1 auto; }

.pob-mode-switch {
    display: inline-flex;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.pob-mode-btn {
    border: none;
    background: transparent;
    color: var(--pob-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.pob-mode-btn.active {
    background: #fff;
    color: var(--pob-primary-dark);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}

.pob-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--pob-border);
    background: #fff;
    color: var(--pob-ink);
    cursor: pointer;
    text-decoration: none;
}
.pob-btn:hover { background: #f8faf9; }
.pob-btn-primary {
    background: var(--pob-primary);
    border-color: var(--pob-primary);
    color: #fff;
}
.pob-btn-primary:hover { background: var(--pob-primary-dark); color: #fff; }

/* Sample-case dropdown */
.pob-dropdown { position: relative; }
.pob-menu {
    position: absolute;
    z-index: 1056;
    top: calc(100% + 6px);
    right: 0;
    min-width: 260px;
    background: #fff;
    border: 1px solid var(--pob-border);
    border-radius: var(--pob-radius);
    box-shadow: var(--pob-shadow);
    padding: 0.4rem;
    display: none;
}
.pob-menu.open { display: block; }
.pob-menu-head {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--pob-muted);
    padding: 0.35rem 0.6rem;
}
.pob-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--pob-ink);
}
.pob-menu-item:hover { background: var(--pob-bg-soft); }
.pob-menu-item strong { display: block; font-size: 0.85rem; }
.pob-menu-item span { display: block; font-size: 0.75rem; color: var(--pob-muted); }

/* ===================== Empty state ===================== */
.pob-empty {
    text-align: center;
    border: 1px dashed var(--pob-border);
    border-radius: var(--pob-radius);
    background: var(--pob-bg-soft);
    padding: 2.25rem 1.25rem;
    margin-bottom: 1rem;
}
.pob-empty-icon { font-size: 2.25rem; color: var(--pob-primary); }
.pob-empty h3 { font-size: 1.15rem; font-weight: 700; margin: 0.5rem 0 0.25rem; color: var(--pob-ink); }
.pob-empty p { color: var(--pob-muted); margin: 0 0 1.1rem; }
.pob-empty-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }

/* ===================== Help ("Why this field?") ===================== */
.pob-help-trigger {
    border: none;
    background: transparent;
    color: var(--pob-accent);
    cursor: pointer;
    padding: 0 0.15rem;
    font-size: 0.95rem;
    line-height: 1;
    vertical-align: middle;
}
.pob-help-trigger:hover { color: var(--pob-primary-dark); }

/* ===================== Overlay (modal + spotlight share) ===================== */
.pob-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
}
.pob-overlay.open { display: block; }

/* Welcome / help modal */
.pob-modal-scrim {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
}
.pob-modal {
    position: relative;
    z-index: 1;
    max-width: 520px;
    margin: 8vh auto 0;
    background: #fff;
    border-radius: var(--pob-radius);
    box-shadow: var(--pob-shadow);
    padding: 1.5rem;
    animation: pob-pop .18s ease;
}
@keyframes pob-pop { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.pob-modal h3 { font-size: 1.2rem; font-weight: 700; margin: 0 0 0.35rem; }
.pob-modal .pob-eyebrow { font-size: 0.75rem; font-weight: 600; color: var(--pob-primary); text-transform: uppercase; letter-spacing: .04em; }
.pob-learn-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.45rem; }
.pob-learn-list li { display: flex; gap: 0.5rem; font-size: 0.9rem; color: var(--pob-ink); }
.pob-learn-list .pob-check { color: var(--pob-primary); font-weight: 700; }
.pob-modal-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.1rem; }

.pob-help-block { margin-bottom: 0.85rem; }
.pob-help-block h4 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--pob-muted); margin: 0 0 0.2rem; }
.pob-help-block p { margin: 0; font-size: 0.92rem; color: var(--pob-ink); }
.pob-help-target { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--pob-bg-soft); border-radius: 8px; padding: 0.3rem 0.6rem; font-size: 0.82rem; color: var(--pob-primary-dark); }

/* ===================== Spotlight tour ===================== */
.pob-spot-mask {
    position: absolute;
    inset: 0;
    /* box-shadow ring drawn around the highlighted rect via inline style */
    pointer-events: none;
}
.pob-spot-ring {
    position: absolute;
    border-radius: 10px;
    box-shadow: 0 0 0 4px rgba(13, 138, 116, 0.9), 0 0 0 100vmax rgba(15, 23, 42, 0.62);
    transition: all .2s ease;
    pointer-events: none;
}
.pob-tip {
    position: absolute;
    z-index: 2;
    width: min(360px, 92vw);
    background: #fff;
    border-radius: var(--pob-radius);
    box-shadow: var(--pob-shadow);
    padding: 1rem 1.1rem;
    animation: pob-pop .18s ease;
}
.pob-tip-step { font-size: 0.72rem; font-weight: 600; color: var(--pob-muted); text-transform: uppercase; letter-spacing: .04em; }
.pob-tip h4 { font-size: 1.02rem; font-weight: 700; margin: 0.15rem 0 0.4rem; }
.pob-tip-desc { font-size: 0.9rem; color: var(--pob-ink); margin: 0 0 0.6rem; }
.pob-tip-meta { display: grid; gap: 0.5rem; margin-bottom: 0.6rem; }
.pob-tip-meta .pob-help-block p { font-size: 0.85rem; }
.pob-tip-tip {
    background: var(--pob-warn-bg);
    color: var(--pob-warn);
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
}
.pob-tip-actions { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.75rem; }
.pob-tip-actions .pob-tip-spacer { flex: 1 1 auto; }
.pob-tip-skip { border: none; background: transparent; color: var(--pob-muted); font-size: 0.8rem; cursor: pointer; text-decoration: underline; }

/* ===================== Consultation Coach (GPS) ===================== */
.pob-coach {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1050;
    width: 240px;
    background: #fff;
    border: 1px solid var(--pob-border);
    border-radius: var(--pob-radius);
    box-shadow: var(--pob-shadow);
    overflow: hidden;
    display: none;
}
.pob-coach.open { display: block; }
.pob-coach-head {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem;
    background: var(--pob-primary);
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}
.pob-coach-head .pob-coach-toggle { margin-left: auto; background: transparent; border: none; color: #fff; cursor: pointer; }
.pob-coach-body { padding: 0.6rem 0.75rem; }
.pob-coach-progress { height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-bottom: 0.6rem; }
.pob-coach-progress > span { display: block; height: 100%; background: var(--pob-primary); width: 0; transition: width .25s ease; }
.pob-coach-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.3rem; }
.pob-coach-steps li { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--pob-muted); }
.pob-coach-steps li.done { color: var(--pob-ink); }
.pob-coach-steps li.current { color: var(--pob-primary-dark); font-weight: 600; }
.pob-coach-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #cbd5e1; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 0.62rem; }
.pob-coach-steps li.done .pob-coach-dot { background: var(--pob-primary); border-color: var(--pob-primary); color: #fff; }
.pob-coach-steps li.current .pob-coach-dot { border-color: var(--pob-primary); }
.pob-coach-next { margin-top: 0.6rem; }
.pob-coach-next .pob-btn { width: 100%; justify-content: center; }
.pob-coach.collapsed .pob-coach-body { display: none; }
.pob-coach-head.pob-coach-draggable { cursor: move; touch-action: none; user-select: none; }
.pob-coach-grip { opacity: 0.7; margin-right: 0.1rem; font-size: 0.9rem; }
.pob-coach-launch { display: inline-flex; align-items: center; gap: 0.3rem; }
.pob-coach-launch .bi { color: var(--pob-primary); }
.pob-coach-launch-floating {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1050;
    background: #fff;
    box-shadow: var(--pob-shadow);
}

/* Mode-driven visibility (advanced sections hidden in simple mode) */
.pob-mode-simple [data-pob-advanced] { display: none !important; }
/* Progressive disclosure: reveal advanced fields without leaving Simple mode (Phase 11) */
.pob-mode-simple.pob-reveal-advanced [data-pob-advanced] { display: revert !important; }
.pob-reveal-btn.active { background: var(--pob-bg-soft); border-color: var(--pob-primary); color: var(--pob-primary-dark); }

/* Simple mode hides the sidebar (.pf-gyn-aside) — collapse the 2-column grid so the
   main column spans the full width instead of leaving the aside track empty.
   (Not scoped to .practice-form-shell so it still applies if the mode class lands
   on <body>, and the main is forced to span every track as a safety net.) */
.pob-mode-simple:not(.pob-reveal-advanced) .pf-gyn-consult-layout {
    grid-template-columns: minmax(0, 1fr) !important;
}
.pob-mode-simple:not(.pob-reveal-advanced) .pf-gyn-consult-layout > .pf-gyn-main {
    grid-column: 1 / -1;
    width: 100%;
}

/* Voice narration toggle (Phase 13) */
.pob-icon-btn { padding-left: 0.5rem; padding-right: 0.5rem; }
[data-pob-voice].active { background: var(--pob-bg-soft); border-color: var(--pob-primary); color: var(--pob-primary-dark); }
[data-pob-voice].active .bi { color: var(--pob-primary); }

/* Coach "go to section" flash highlight */
.pob-flash { animation: pob-flash-kf 1.1s ease; border-radius: 8px; }
@keyframes pob-flash-kf {
    0% { box-shadow: 0 0 0 0 rgba(13, 138, 116, 0.0); }
    25% { box-shadow: 0 0 0 4px rgba(13, 138, 116, 0.45); }
    100% { box-shadow: 0 0 0 0 rgba(13, 138, 116, 0.0); }
}

/* ===================== Wizard (Phase 3) ===================== */
.pob-wizard {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%) translateY(140%);
    width: min(720px, calc(100vw - 24px));
    /* Never exceed the viewport — scroll internally so Back/Next/Exit stay reachable. */
    max-height: calc(100vh - 36px);
    background: #fff;
    border: 1px solid var(--pob-border);
    border-radius: var(--pob-radius);
    box-shadow: var(--pob-shadow);
    z-index: 1080;
    opacity: 0;
    transition: transform 0.28s ease, opacity 0.28s ease;
    overflow-x: hidden;
    overflow-y: auto;
}
.pob-wizard.open { transform: translateX(-50%) translateY(0); opacity: 1; }
.pob-wizard-progress { height: 4px; background: #eef2f7; }
.pob-wizard-progress > span {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--pob-primary), var(--pob-accent));
    transition: width 0.3s ease;
}
.pob-wizard-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
    padding: 0.85rem 1rem;
}
.pob-wizard-text { flex: 1 1 280px; min-width: 0; }
.pob-wizard-step {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--pob-muted);
    font-weight: 700;
}
.pob-wizard-title { margin: 0.1rem 0 0.15rem; font-size: 1.05rem; color: var(--pob-ink); }
.pob-wizard-prompt { margin: 0; color: #475569; font-size: 0.9rem; }
.pob-wizard-meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.pob-wizard-chip {
    font-size: 0.76rem;
    background: var(--pob-bg-soft);
    color: #0f766e;
    border: 1px solid #cdeee7;
    border-radius: 999px;
    padding: 0.12rem 0.55rem;
}
.pob-wizard-chip.pob-w-ai { background: #eff6ff; color: #1d4ed8; border-color: #c7dbff; }
.pob-wizard-chip.pob-w-tip { background: #fffbeb; color: var(--pob-warn); border-color: #fde68a; }
.pob-wizard-nav { display: flex; align-items: center; gap: 0.5rem; flex: 0 0 auto; }
.pob-wizard-status { font-size: 0.78rem; min-width: 92px; text-align: center; }
.pob-wizard-status .pob-w-ok { color: #15803d; font-weight: 600; }
.pob-wizard-status .pob-w-pending { color: var(--pob-muted); }
.pob-wizard-close {
    border: none;
    background: transparent;
    color: var(--pob-muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.25rem;
}
.pob-wizard-close:hover { color: var(--pob-ink); }

/* Focused section during the wizard */
.pob-wizard-focus {
    position: relative;
    box-shadow: 0 0 0 3px rgba(13, 138, 116, 0.45), 0 8px 24px -12px rgba(13, 138, 116, 0.6);
    border-radius: 10px;
    transition: box-shadow 0.25s ease;
}
body.pob-wizard-active .pob-coach { display: none !important; }
/* Room to scroll the focused block clear of the fixed wizard bar */
body.pob-wizard-active .practice-form-shell { padding-bottom: 220px; }

/* ===================== Patient summary (Phase 10) ===================== */
.pob-summary {
    background: #fff;
    border: 1px solid var(--pob-border);
    border-left: 4px solid var(--pob-primary);
    border-radius: var(--pob-radius);
    padding: 0.85rem 1rem;
    margin-bottom: 0.85rem;
}
.pob-summary-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.pob-summary-title { font-weight: 700; color: var(--pob-ink); }
.pob-summary-title .bi { color: var(--pob-primary); margin-right: 0.3rem; }
.pob-summary-prio {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    background: #e2e8f0;
    color: #334155;
}
.pob-prio-complete, .pob-prio-low { background: #dcfce7; color: #15803d; }
.pob-prio-routine, .pob-prio-in_progress { background: #e0f2fe; color: #0369a1; }
.pob-prio-moderate { background: #fef3c7; color: var(--pob-warn); }
.pob-prio-attention, .pob-prio-high { background: #fee2e2; color: #b91c1c; }
.pob-summary-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.5rem 1.25rem;
}
.pob-summary-col h6 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--pob-muted);
    margin: 0 0 0.3rem;
}
.pob-summary-col ul { list-style: none; margin: 0; padding: 0; }
.pob-summary-col li {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.88rem;
    padding: 0.15rem 0;
    color: var(--pob-ink);
}
.pob-sum-attn .bi { color: #d97706; flex: 0 0 auto; margin-top: 2px; }
.pob-sum-action .bi { color: var(--pob-primary); font-size: 1.15rem; flex: 0 0 auto; }
.pob-summary-empty { margin: 0; color: #15803d; font-size: 0.9rem; }
.pob-summary-empty .bi { margin-right: 0.3rem; }

@media (max-width: 575.98px) {
    .pob-coach { left: 0; right: 0; bottom: 0; width: 100%; border-radius: 0; }
    .pob-toolbar { position: sticky; top: 0; z-index: 5; }
    .pob-wizard { bottom: 0; border-radius: var(--pob-radius) var(--pob-radius) 0 0; width: 100%; }
    .pob-wizard.open { transform: translateX(-50%) translateY(0); }
    .pob-wizard-main { padding: 0.7rem 0.85rem; }
    .pob-wizard-nav { width: 100%; justify-content: space-between; }
}

/* ===================== Learning progress (Phase 12) ===================== */
.pob-progress-chip { position: relative; padding-left: 0.55rem; }
.pob-progress-chip .pob-progress-ring {
    display: inline-block; width: 34px; height: 4px; border-radius: 999px;
    background: #e2e8f0; overflow: hidden; margin-right: 0.15rem; vertical-align: middle;
}
.pob-progress-chip .pob-progress-fill {
    display: block; height: 100%; width: 0; background: var(--pob-primary); transition: width .3s ease;
}
.pob-progress-chip .pob-progress-count { font-variant-numeric: tabular-nums; }
.pob-progress-chip.pob-progress-done {
    background: var(--pob-bg-soft); border-color: var(--pob-primary); color: var(--pob-primary-dark);
}
.pob-progress-chip.pob-progress-done .bi { color: var(--pob-primary); }

.pob-progress-panel {
    position: fixed;
    z-index: 1057;
    min-width: 270px;
    max-width: 320px;
    background: #fff;
    border: 1px solid var(--pob-border);
    border-radius: var(--pob-radius);
    box-shadow: var(--pob-shadow);
    padding: 0.5rem;
}
.pob-progress-track {
    height: 6px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin: 0.1rem 0.25rem 0.45rem;
}
.pob-progress-track .pob-progress-fill { display: block; height: 100%; background: var(--pob-primary); transition: width .3s ease; }
.pob-progress-item {
    display: flex; align-items: center; gap: 0.5rem; width: 100%;
    background: transparent; border: none; border-radius: 8px;
    padding: 0.45rem 0.5rem; cursor: pointer; text-align: left; color: var(--pob-ink);
}
.pob-progress-item:hover { background: var(--pob-bg-soft); }
.pob-progress-mark {
    flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%;
    border: 1.5px solid var(--pob-border); color: #fff; background: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700;
}
.pob-progress-item.done .pob-progress-mark { background: var(--pob-primary); border-color: var(--pob-primary); }
.pob-progress-text { flex: 1 1 auto; font-size: 0.84rem; font-weight: 600; }
.pob-progress-item.done .pob-progress-text { color: var(--pob-muted); font-weight: 500; }
.pob-progress-cta { flex: 0 0 auto; font-size: 0.72rem; color: var(--pob-primary-dark); font-weight: 600; }
.pob-progress-foot { padding: 0.4rem 0.25rem 0.15rem; }
.pob-progress-resume { width: 100%; justify-content: center; }

/* Progressive-disclosure reveal button (Phase 11) */
.pob-reveal-btn { transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
