/* Catalog Modal (Split Pane) */
/* [V10] Standard Modal Overlay (Centered Pop-up) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    /* Controlled by .open class or JS display */
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 24px;
}

.modal-overlay.open {
    display: flex;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 20px;
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 700;
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    background: #fff;
    color: var(--text-secondary);
    font-size: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.modal-container {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.catalog-modal-content {
    max-width: 680px !important;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.catalog-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 0 !important;
    background: #fff;
}

.catalog-search-wrapper {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
}

.catalog-search-wrapper input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.catalog-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 24px;
    background: #fff;
}

.catalog-card-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.catalog-card {
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}

.catalog-card.is-pending {
    border-style: dashed;
    opacity: 0.85;
}

.catalog-card-category {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
}

.catalog-card-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 6px 0 8px;
}

.catalog-status {
    margin-left: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #a15f00;
    background: #fff5e6;
    border: 1px solid #ffd9a6;
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
}

.catalog-status-note {
    margin-bottom: 10px;
    font-size: 0.78rem;
    color: #8a4a00;
}

.catalog-card-summary {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.catalog-card .catalog-detail-grid {
    margin-bottom: 12px;
}

.catalog-detail-card {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.catalog-detail-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 8px 0;
}

.catalog-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.catalog-detail-block {
    padding: 16px;
    background: var(--bg-hover);
    border-radius: 12px;
}

.catalog-detail-block strong {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 4px;
}

.catalog-example-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.catalog-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.catalog-chip-btn {
    border: 1px solid var(--line-2);
    background: #f3f6fb;
    color: var(--text-primary);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.catalog-chip-btn:hover {
    border-color: #90b8ff;
    background: #eaf1ff;
}

.catalog-chip-btn:disabled,
.catalog-example .mini-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.catalog-example {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #f9fafb;
    border-radius: 8px;
    font-size: 0.9rem;
}

.catalog-example-copy {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.catalog-example-text {
    line-height: 1.35;
    color: var(--text-primary);
}

.catalog-example-meaning {
    line-height: 1.35;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.catalog-example .mini-btn {
    flex-shrink: 0;
    align-self: center;
}

.catalog-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    background: #fafafa;
}

.hint {
    font-size: 0.85rem;
    color: var(--muted);
}

/* ZERO STATE (Premium Polish) */
.state-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
    pointer-events: none;
    /* Background removed/simplified per user request */
    background: transparent;
    padding: 0;
    /* Minimal padding */
}

.state-text strong {
    font-size: 1.5rem;
    /* Larger title */
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
    display: block;
    margin-bottom: 12px;
}

/* ── Running spinner (shown during screener execution) ── */
.running-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 16px;
    border: 3px solid var(--border-subtle, #e0e0e0);
    border-top-color: var(--accent-primary, #1e78ff);
    border-radius: 50%;
    animation: running-spin 0.8s linear infinite;
}
@keyframes running-spin {
    to { transform: rotate(360deg); }
}

.state-text span {
    font-size: 1rem !important;
    /* Readable subtitle */
    line-height: 1.6;
    color: var(--text-secondary) !important;
    opacity: 0.8;
}

/* Mobile specific adjustments to fill space */
@media (max-width: 1024px) {
    .state-overlay {
        position: static;
        /* Let it flow in mobile center pane */
        transform: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        /* Use flex to fill space instead of fixed height */
        width: 100%;
        min-height: 200px;
        /* Reduced from 300px to fit smaller screens */
        /* Ensure minimum visibility */
        padding: 20px;
        /* Integrated padding */
        background: transparent;
        overflow: hidden;
        /* Prevent spillover */
        box-sizing: border-box;
        /* Fix width calculation */
    }

    .state-text strong {
        font-size: 1.25rem !important;
        /* Smaller title for mobile */
    }

    /* NUCLEAR OPTION: Global White for Mobile */
    body,
    .app-container {
        background-color: #ffffff !important;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(30, 120, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(30, 120, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(30, 120, 255, 0);
    }
}

.pulse-anim {
    animation: pulse 2s infinite;
}


/* =========================================
   MOBILE RESPONSIVENESS
   ========================================= */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: #fff;
    border-top: 1px solid var(--border-light);
    height: 60px;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    gap: 4px;
    cursor: pointer;
}

.mobile-nav-item.active {
    color: var(--accent-primary);
    font-weight: 600;
}

.mobile-nav-icon {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

@media (max-width: 1024px) {
    :root {
        --results-pad: 16px;
    }

    .app-container {
        flex-direction: column;
    }

    .app-container .panel {
        width: 100% !important;
        position: fixed !important;
        /* Force full screen overlay */
        top: 0;
        left: 0;
        bottom: 60px;
        /* Leave space for bottom nav */
        height: calc(100% - 60px) !important;
        /* Force full available height */
        border: none;
        display: none;
        /* Default hidden */
        background: #ffffff;
        /* Unified White Background for Mobile */
        z-index: 10;
        flex-direction: column;
        /* Ensure flex context */
    }

    .app-container .panel.mobile-active {
        display: flex;
    }

    .pane-center {
        padding: 0;
        background: #ffffff !important;
    }

    /* Mobile: Stack results in 1 column */
    .results-grid {
        grid-template-columns: 1fr;
        padding: var(--results-pad);
        /* Reduce padding on mobile */
        gap: 16px;
    }

    .center-input-header {
        padding: 16px;
        border-bottom: 1px solid var(--border-light);
        background: #ffffff !important;
        /* Unified White */
        /* Ensure opaque */
        flex-shrink: 0;
        /* Fixed Header */
    }

    .query-input {
        font-size: 1rem;
        padding: 12px 16px;
        padding-right: 50px;
    }

    .pane-right {
        background: #fff;
        padding-bottom: 0;
    }

    .mobile-nav {
        display: flex;
    }

    .feedback-fab {
        right: 16px;
        bottom: calc(76px + env(safe-area-inset-bottom));
        font-size: 0.8rem;
        padding: 10px 14px;
    }

    .feedback-fab.is-docked {
        --feedback-fab-shift-x: calc(100% - 18px);
    }

    .brand-header {
        height: 56px;
        min-height: 56px;
        padding: 0 16px;
    }


    .status-badge {
        font-size: 0.7rem;
    }

    .pane-footer {
        display: flex;
        flex-direction: column;
        width: 100%;
        position: relative !important;
        bottom: auto;
        left: auto;
        padding: 24px 16px;
        z-index: 5;
        background: transparent !important;
        border-top: 1px solid var(--border-light);
        gap: 8px;
        margin-top: auto;
        flex-shrink: 0;
    }

    /* Wrap inner row naturally */
    .footer-row {
        display: flex;
        flex-direction: row;
        /* Back to row */
        flex-wrap: wrap;
        /* Allow wrapping */
        justify-content: center;
        align-items: center;
        gap: 8px;
        /* Horizontal gap */
        text-align: center;
    }

    .footer-links {
        margin-left: 0 !important;
    }

    /* Ensure content area scrolls and shrinks properly */
    .app-content {
        flex: 1 1 auto;
        overflow-y: auto;
        overflow-x: hidden;
        display: flex;
        flex-direction: column;
        height: 100%;
        width: 100%;
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
        background: #ffffff;
        position: relative;
        -webkit-overflow-scrolling: touch;
    }

    /* Content Blocks: Prevent Flex Squashing */
    .results-area,
    .results-grid-container,
    .state-overlay,
    .clarify-area {
        display: block;
        width: 100%;
        flex-shrink: 0;
        /* CRITICAL: Prevent collapse */
        height: auto !important;
        min-height: 0;
        overflow: visible;
        background: #ffffff !important;
    }

    /* Force fixed height for header to prevent collapse */
    .builder-header {
        height: 56px !important;
        flex-shrink: 0;
        width: 100%;
        background: #ffffff !important;
        display: flex;
        /* Ensure it stays visible */
    }
}
