/* Shared styles for the per-flow lookup pages — Games, Toys, Puzzles — and their
   form + picker components. Targeted at worker apps that embed the flows, so the
   tokens resolve against the hosting app's --app-primary palette. */

.lookup-flow-page {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    max-width: 1100px;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

.lookup-flow-page-header h1 {
    margin: 0 0 var(--space-1);
    color: var(--text-primary);
}

.lookup-flow-page-header p {
    margin: 0;
    color: var(--text-secondary);
    max-width: 60ch;
}

.lookup-flow-card-wrap {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.lookup-flow-selected {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.lookup-flow-selected h2 {
    margin: 0 0 var(--space-2);
    color: var(--text-primary);
}

.lookup-flow-selected h2 small {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: var(--fs-base);
}

.lookup-flow-busy {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-light);
    border-radius: var(--radius-md);
}

.lookup-alert {
    padding: var(--space-3);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
}

.lookup-alert-danger {
    background: var(--alert-danger-bg);
    color: var(--alert-danger-text);
    border-color: var(--alert-danger-border);
}

/* ---- Search form ------------------------------------------------------ */

.lookup-search-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.lookup-search-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.lookup-search-row > .lookup-search-field {
    flex: 1 1 180px;
}

.lookup-search-field-compact {
    flex: 0 0 auto;
    width: 110px;
}

.lookup-search-field label {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.lookup-search-field input,
.lookup-search-field select {
    min-height: 40px;
    padding: 0.5rem 0.625rem;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    background: var(--bg-white);
}

.lookup-search-field input:focus,
.lookup-search-field select:focus {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px var(--app-focus-ring, rgba(0, 0, 0, 0.1));
}

.lookup-search-row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.lookup-search-row-aligned {
    align-items: center;
    row-gap: var(--space-2);
}

.lookup-search-checkbox {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--fs-base);
    color: var(--text-primary);
}

.lookup-search-actions {
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    min-height: 40px;
    padding: var(--space-2) var(--space-4);
    background: var(--app-primary);
    color: #fff;
    border: 1px solid var(--app-primary);
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    font-weight: 500;
    cursor: pointer;
}

.btn-primary:hover:not(:disabled) {
    background: var(--app-primary-dark);
    border-color: var(--app-primary-dark);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Candidate picker ------------------------------------------------- */

.lookup-candidate-picker {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.lookup-candidate-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.lookup-candidate-picker-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--fs-lg);
}

.lookup-candidate-count {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.lookup-candidate-filter {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: flex-end;
}

.lookup-candidate-filter label {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.lookup-candidate-filter input {
    min-height: 36px;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
}

.lookup-candidate-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-white);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    text-align: left;
    width: 100%;
    min-height: 48px;
    cursor: pointer;
    margin-bottom: var(--space-1);
}

.lookup-candidate-row:hover {
    background: var(--app-primary-light);
    border-color: var(--app-primary);
}

.lookup-candidate-name {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1 1 auto;
}

.lookup-candidate-meta {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.lookup-candidate-expansion {
    background: var(--app-primary-light);
    color: var(--app-primary-dark);
    border: 1px solid var(--app-primary);
    border-radius: var(--radius-sm);
    padding: 0 var(--space-1);
    font-size: var(--fs-xs);
    text-transform: uppercase;
}

.lookup-candidate-empty {
    padding: var(--space-4);
    text-align: center;
    color: var(--text-secondary);
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}

.lookup-candidate-scroll {
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-right: var(--space-1);
}

/* ---- Mode toggle (Toys LEGO / Other, Puzzles Jigsaw / Logic) --------- */

.lookup-mode-toggle {
    display: inline-flex;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    overflow: hidden;
    align-self: flex-start;
}

.lookup-mode-btn {
    padding: var(--space-2) var(--space-4);
    background: var(--bg-white);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
    font-size: var(--fs-base);
    min-height: 40px;
}

.lookup-mode-btn + .lookup-mode-btn {
    border-left: 1px solid var(--border-medium);
}

.lookup-mode-btn.is-active {
    background: var(--app-primary);
    color: #fff;
}

.lookup-mode-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- LEGO picker ------------------------------------------------------ */

.lookup-lego-row {
    display: grid;
    grid-template-columns: 64px 1fr auto;
    gap: var(--space-3);
    align-items: center;
    min-height: 80px;
}

.lookup-lego-thumb {
    width: 64px;
    height: 64px;
    object-fit: contain;
    background: var(--bg-muted);
    border-radius: var(--radius-sm);
}

.lookup-lego-thumb-placeholder {
    background: repeating-linear-gradient(
        45deg,
        var(--bg-muted),
        var(--bg-muted) 6px,
        var(--bg-code) 6px,
        var(--bg-code) 12px
    );
}

.lookup-lego-number {
    display: inline-block;
    background: var(--app-primary-light);
    color: var(--app-primary-dark);
    border: 1px solid var(--app-primary);
    border-radius: var(--radius-sm);
    padding: 0 var(--space-2);
    font-size: var(--fs-xs);
    font-family: monospace;
    margin-right: var(--space-2);
}

.lookup-candidate-attribution {
    text-align: right;
    color: var(--text-muted);
    font-size: var(--fs-xs);
    margin: var(--space-2) 0 0;
}

/* ---- Puzzles keyword preview ----------------------------------------- */

.lookup-keyword-preview {
    background: var(--bg-light);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    display: flex;
    gap: var(--space-2);
    align-items: baseline;
    flex-wrap: wrap;
}

.lookup-keyword-preview-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

.lookup-keyword-preview code {
    background: var(--bg-code);
    color: var(--text-primary);
    padding: 0 var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
}

/* ---- Mobile: release pane-locked layout so the document scrolls ------ */

@media (max-width: 767.98px) {
    .lookup-flow-page {
        overflow: visible;
        min-height: 0;
    }
}
