/* kbo-bookgenie-spa.css - SPA (progressive disclosure) Book Genie */

/* ---------- Step sections ---------- */
.genie-step:focus {
    outline: none;
}

.genie-step {
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    background: #fff;
    margin-bottom: .75rem;
    overflow: hidden;
}

.genie-step-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .75rem 1rem;
    cursor: pointer;
    background: #f8f9fa;
    border-bottom: 1px solid transparent;
    user-select: none;
}

    .genie-step-header:focus {
        outline: 2px solid #0d6efd;
        outline-offset: -2px;
    }

.genie-step-title {
    font-weight: 600;
    color: #212529;
}

/* Chosen value(s) for a confirmed step, right-aligned on the collapsed header.
   Multiple selections are joined with ", " by the step renderer. */
.genie-step-summary {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    text-align: right;
    font-size: .875rem;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .genie-step-summary[hidden] {
        display: none;
    }

.genie-step-badge {
    font-size: .75rem;
    font-weight: 600;
    padding: .15rem .5rem;
    border-radius: 1rem;
    color: #6c757d;
    background: #e9ecef;
}

.genie-step-body {
    padding: 1rem;
}

/* #messages is relocated into the active step, so it reads as that
   step's prompt rather than a page-level log. */
.genie-step-body > #messages {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 0 .75rem 0 !important;
    margin: 0 !important;
    flex: none !important;
}

.genie-step-body > #messages:empty {
    display: none;
}

.genie-step-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    padding-bottom: .5rem;
}

/* Description/action panel: overview on the left, step actions on the right */
.genie-step-desc {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: .375rem;
}

/* Actions panel is moved above the step header; show it only on the active step. */
.genie-step > .genie-step-desc {
    margin: .5rem;
}

.genie-step:not(.is-active) > .genie-step-desc {
    display: none;
}

/* #messages stays hidden until relocated into the active step. */
#conversation-container > #messages {
    display: none;
}

.genie-step-overview {
    flex: 1 1 auto;
    min-width: 0;
}

.genie-step-overview > #messages {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    margin: 0 !important;
}

.genie-step-desc .genie-step-actions {
    flex: 0 0 auto;
    padding-bottom: 0;
}

.genie-step-actions > button[hidden] {
    display: none !important;
}

.genie-step[hidden],
.genie-step-confirm[hidden] {
    display: none !important;
}

/* ---------- Step states ---------- */

/* Collapsed: header only */
.genie-step.is-collapsed > .genie-step-body {
    display: none;
}

/* Active: currently open step */
.genie-step.is-active {
    border-color: #0d6efd;
    box-shadow
}

    .genie-step.is-active > .genie-step-header {
        background: #e7f1ff;
        border-bottom-color: #dee2e6;
    }

    .genie-step.is-active .genie-step-badge {
        color: #0d6efd;
        background: #cfe2ff;
    }

/* Complete: confirmed, collapsed, re-openable */
.genie-step.is-complete > .genie-step-header {
    background: #f1f8f3;
}

.genie-step.is-complete .genie-step-badge {
    color: #0f5132;
    background: #d1e7dd;
}

/* Locked: not yet reachable */
.genie-step.is-locked {
    opacity: .55;
}

    .genie-step.is-locked > .genie-step-header {
        cursor: not-allowed;
    }

/* SPA drives visibility via section state, so the legacy
   one-at-a-time rules must be fully neutralised. The base
   stylesheet hides containers with display:none AND opacity:0,
   so overriding display alone leaves them invisible. */
#input-areas .input-container,
#input-areas .input-container.active {
    display: block;
    opacity: 1;
    transform: none;
}

/* ---------- Allocation lock overlay ---------- */
.genie-overlay {
    position: absolute;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.65);
    backdrop-filter: blur(1.5px);
}

    .genie-overlay[hidden] {
        display: none;
    }

.genie-overlay-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    min-width: 20rem;
    max-width: 28rem;
    padding: 1.5rem 2rem;
    text-align: center;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.2);
}

.genie-overlay-title {
    margin: 0;
    font-weight: 600;
}

.genie-overlay-status {
    margin: 0;
    color: #6c757d;
    font-size: .9rem;
}

.genie-overlay-counts {
    font-weight: 600;
    color: #495057;
}

.genie-overlay-progress {
    width: 100%;
    height: 1.25rem;
}

/* While allocating, other steps are hidden by script; Cancel and
   Reset Allocation must stay interactive. */

/* Error/confirm dialogs must stack above the scrim */
#errorDialog {
    z-index: 1100;
}

/* ---------- Spinner ---------- */
.genie-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: .25rem solid #cfe2ff;
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: genie-spin .8s linear infinite;
}

@keyframes genie-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .genie-spinner {
        animation-duration: 2.4s;
    }
}
