/* ========================================================== */
/* GLOBAL STYLES                                             */
/* ========================================================== */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #1a1a2e;
    color: #eee;
}
.container { background: #16213e; padding: 20px; border-radius: 10px; }

/* ========================================================== */
/* HEADER                                                     */
/* ========================================================== */
.header { text-align: center; }
.header h1 { color: #00d4ff; font-size: 28px; margin: 5px 0 0 0; }
.header h1 span { color: #ffd93d; }
.logo { width: 15vw; height: auto; max-width: 100%; display: block; margin: 0 auto; }
.version { font-size: 11px; color: #555; margin-top: 2px; }
.status { background: #0f3460; padding: 8px 12px; border-radius: 5px; margin: 10px 0; font-size: 13px; }

/* ========================================================== */
/* PROVIDER CONFIG TABLE                                      */
/* ========================================================== */
.provider-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px 0;
    font-size: 12px;
    background: #0a1a2e;
    border-radius: 8px;
    overflow: hidden;
}
.provider-table th {
    background: #0f2030;
    color: #00d4ff;
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid #1a3a5e;
    font-weight: bold;
}
.provider-table td {
    padding: 5px 10px;
    border-bottom: 1px solid #0f2030;
    color: #ccc;
}
.provider-table .local-row { background: #0a1a2e; }
.provider-table .external-row { background: #0f2030; }
.provider-table .waitlist-row { background: #0a1a2e; opacity: 0.85; }
.provider-table .waitlist-row td { color: #88aacc; }
.provider-table .waitlist-label { color: #ffd93d; font-style: italic; font-size: 10px; margin-left: 4px; }
.provider-table .trust-high { color: #00ff88; }
.provider-table .trust-medium { color: #ffd93d; }
.provider-table .trust-low { color: #ff6b6b; }
.provider-table .icon { font-size: 14px; margin-right: 4px; }
.provider-table .type-badge {
    display: inline-block;
    padding: 0 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
}
.type-badge.local { background: #0f3460; color: #00d4ff; }
.type-badge.external { background: #1a2a4a; color: #ffd93d; }
.type-badge.waitlist { background: #1a2a4a; color: #ffd93d; border: 1px dashed #ffd93d; }
.provider-table .free { color: #ffd93d; }
.provider-table .paid { color: #ff6b6b; }
.provider-table .provider-checkbox {
    accent-color: #00d4ff;
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.provider-table .provider-checkbox:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.provider-table .provider-radio {
    accent-color: #00d4ff;
    width: 14px;
    height: 14px;
    cursor: pointer;
}
.provider-table .select-cell { text-align: center; width: 50px; }
.provider-table .cost-cell { font-size: 11px; }
.provider-table .award { font-size: 14px; margin-left: 4px; }

/* ========================================================== */
/* SAVE BAR                                                   */
/* ========================================================== */
.save-bar {
    display: flex;
    gap: 8px;
    padding: 4px 0 8px 0;
    justify-content: flex-end;
}
.save-bar button {
    background: #00d4ff;
    color: #1a1a2e;
    border: none;
    padding: 3px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
}
.save-bar button:hover { background: #ff6b6b; color: white; }
.save-bar button.secondary {
    background: #0f3460;
    color: #00d4ff;
    border: 1px solid #00d4ff;
}
.save-bar button.secondary:hover { background: #00d4ff; color: #1a1a2e; }

/* ========================================================== */
/* STATS SUMMARY                                             */
/* ========================================================== */
.stats-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    padding: 8px 12px;
    background: #0a1a2e;
    border-radius: 8px;
    margin: 6px 0 10px 0;
    border: 1px solid #1a3a5e;
    font-size: 12px;
    color: #aaa;
}
.stats-summary .stat-item .value {
    font-weight: bold;
    color: #00d4ff;
}
.stats-summary .stat-item .value.confidence { color: #00ff88; }
.stats-summary .stat-item .value.speed { color: #ffd93d; }
.stats-summary .stat-item .value.trust { color: #ff6b6b; }
.stats-summary .stat-item .value.rating { color: #ffa94d; }

/* ========================================================== */
/* CHAT BOX                                                   */
/* ========================================================== */
.chat-box {
    background: #0f3460;
    padding: 15px;
    border-radius: 5px;
    min-height: 150px;
    max-height: none;
    overflow-y: auto;
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.8;
}
.user-msg { color: #00d4ff; font-weight: bold; margin: 10px 0; }
.assistant-msg { color: #ffd93d; }

/* ========================================================== */
/* RESPONSE CARDS                                             */
/* ========================================================== */
.response-card {
    background: #0a1a2e;
    border-radius: 8px;
    margin: 10px 0;
    padding: 0;
    border: 1px solid #1a3a5e;
    overflow: hidden;
}
.response-card.best { border-color: #ffd93d; box-shadow: 0 0 15px rgba(255, 217, 61, 0.1); }
.response-card.best .card-header { background: #1a2a4a; }

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 6px 12px;
    background: #0f2030;
    border-bottom: 1px solid #1a3a5e;
    font-size: 13px;
}
.card-header .provider { font-weight: bold; font-size: 14px; display: flex; align-items: center; gap: 4px; }
.card-header .provider .icon { font-size: 16px; }
.card-header .badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: bold; }
.badge.best-badge { background: #ffd93d; color: #1a1a2e; }
.badge.trust-high { background: #00ff8833; color: #00ff88; }
.badge.trust-medium { background: #ffd93d33; color: #ffd93d; }
.badge.trust-low { background: #ff6b6b33; color: #ff6b6b; }

.meta-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 11px;
    color: #aaa;
    align-items: center;
}
.meta-info .label { color: #666; }
.meta-info .value { font-weight: bold; color: #ddd; }
.meta-info .value.reported { color: #88ccff; }
.meta-info .value.adjusted { color: #ffd93d; }
.meta-info .value.trust-high { color: #00ff88; }
.meta-info .value.trust-medium { color: #ffd93d; }
.meta-info .value.trust-low { color: #ff6b6b; }

.card-header .rating-buttons { display: flex; gap: 2px; margin-left: auto; }
.card-header .rating-btn {
    background: #1a1a2e;
    border: 1px solid #333;
    color: #888;
    padding: 1px 6px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 10px;
    transition: all 0.2s;
}
.card-header .rating-btn:hover { background: #00d4ff; color: #1a1a2e; }
.card-header .rating-btn.selected { background: #ffd93d; color: #1a1a2e; border-color: #ffd93d; }
.card-header .rating-btn.rated-1 { background: #ff6b6b; color: white; }
.card-header .rating-btn.rated-2 { background: #ffa94d; color: white; }
.card-header .rating-btn.rated-3 { background: #ffd93d; color: #1a1a2e; }
.card-header .rating-btn.rated-4 { background: #51cf66; color: white; }
.card-header .rating-btn.rated-5 { background: #00ff88; color: #1a1a2e; }
.card-header .feedback-text { font-size: 11px; color: #888; margin-left: auto; }
.card-header .feedback-text .thanks { color: #00ff88; }
.card-header .feedback-text .error { color: #ff6b6b; }

.card-body {
    padding: 8px 14px 10px 14px;
    font-size: 14px;
    line-height: 1.7;
    color: #ddd;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.card-body p { margin: 4px 0; }
.card-body h1, .card-body h2, .card-body h3 { color: #ffd93d; margin: 6px 0 4px 0; }
.card-body table { border-collapse: collapse; width: 100%; margin: 6px 0; font-size: 13px; }
.card-body th, .card-body td { border: 1px solid #1a3a5e; padding: 4px 8px; text-align: left; }
.card-body th { background: #0f3460; color: #00d4ff; }
.card-body code { background: #0f2030; padding: 1px 4px; border-radius: 3px; font-family: monospace; font-size: 13px; }
.card-body pre { background: #0f2030; padding: 8px; border-radius: 5px; overflow-x: auto; font-size: 13px; border: 1px solid #1a3a5e; margin: 4px 0; }
.card-body blockquote { border-left: 3px solid #00d4ff; padding-left: 12px; margin: 4px 0; color: #aaa; }
.card-body ul, .card-body ol { padding-left: 18px; margin: 4px 0; }
.card-body a { color: #00d4ff; }

/* ========================================================== */
/* QUERY INPUT                                                */
/* ========================================================== */
.query-input { display: flex; gap: 8px; margin: 10px 0; }
.query-input input {
    flex: 1;
    padding: 10px;
    background: #0f3460;
    color: #eee;
    border: 1px solid #00d4ff;
    border-radius: 5px;
    font-size: 14px;
    outline: none;
}
.query-input input:focus { border-color: #ffd93d; }
.query-input button {
    background: #00d4ff;
    color: #1a1a2e;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    font-weight: bold;
}
.query-input button:hover { background: #ff6b6b; color: white; }

/* ========================================================== */
/* FOOTER                                                     */
/* ========================================================== */
.footer {
    text-align: center;
    color: #555;
    font-size: 11px;
    margin-top: 10px;
}
.examples { color: #888; font-size: 12px; margin-top: 5px; }
.examples span { color: #00d4ff; cursor: pointer; padding: 2px 4px; border-radius: 3px; }
.examples span:hover { background: #00d4ff; color: #1a1a2e; }

/* ========================================================== */
/* RESPONSIVE                                                 */
/* ========================================================== */
@media (max-width: 768px) {
    .card-header { flex-wrap: wrap; }
    .card-header .rating-buttons { margin-left: 0; }
    .provider-table { font-size: 11px; }
    .provider-table th, .provider-table td { padding: 4px 6px; }
    .meta-info { gap: 4px 8px; font-size: 10px; }
}

/* ========================================================== */
/* SHARED HEAVY-MEMORY STATUS                                */
/* ========================================================== */
.resource-warning {
    border: 2px solid #ff6b6b;
    background: #351f36;
    color: #eee;
    padding: 16px;
    border-radius: 8px;
    margin: 10px 0 14px 0;
    line-height: 1.45;
}
.resource-warning.restoring {
    border-color: #ffd93d;
    background: #302b35;
}
.resource-warning-title {
    color: #ff6b6b;
    font-size: 19px;
    font-weight: bold;
    margin-bottom: 7px;
}
.resource-warning.restoring .resource-warning-title { color: #ffd93d; }
.resource-warning-meta { color: #bbb; font-size: 12px; margin-top: 8px; }
.resource-warning button {
    margin-top: 12px;
    background: #ffd93d;
    color: #1a1a2e;
    border: none;
    padding: 8px 14px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}
.resource-warning button:disabled { opacity: 0.5; cursor: not-allowed; }
.provider-table .local-unavailable-note {
    display: inline-block;
    margin-left: 5px;
    color: #ff6b6b;
    font-size: 10px;
    font-weight: bold;
}


/* OPO_LOCAL_TOKEN_CONTROLS_V1
   Per-request local token selector and continuation controls. */

.local-token-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -2px 0 10px 0;
    color: #aaa;
    font-size: 12px;
}

.local-token-control label {
    color: #ddd;
    font-weight: bold;
}

.local-token-control select {
    background: #0f3460;
    color: #eee;
    border: 1px solid #00d4ff;
    border-radius: 5px;
    padding: 5px 8px;
}

.local-truncation-controls {
    margin: 8px 10px 10px 10px;
    padding: 10px;
    border: 1px solid #ffd93d;
    border-radius: 6px;
    background: #302b35;
}

.local-truncation-title {
    color: #ffd93d;
    font-weight: bold;
}

.local-truncation-note {
    color: #bbb;
    font-size: 12px;
    margin-top: 4px;
}

.local-truncation-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 8px;
}

.local-truncation-buttons button {
    background: #00d4ff;
    color: #1a1a2e;
    border: none;
    border-radius: 5px;
    padding: 7px 10px;
    cursor: pointer;
    font-weight: bold;
}

.local-truncation-buttons button:hover {
    background: #ffd93d;
}

/* OPO_BOOST_BRAINPOWER_V1 */
.boost-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 10px 10px 10px;
    padding-top: 8px;
    border-top: 1px solid #1a3a5e;
    color: #aaa;
    font-size: 12px;
}

.boost-controls button {
    background: #ffd93d;
    color: #1a1a2e;
    border: none;
    border-radius: 5px;
    padding: 7px 10px;
    cursor: pointer;
    font-weight: bold;
}

.boost-controls button:hover {
    background: #00d4ff;
}

.card-header .boost-badge {
    background: #ffd93d;
    color: #1a1a2e;
}


/* OPO_LOCAL_MODEL_SELECTOR_STYLES_V1 */
.provider-table .local-selector-heading td {
    background: #0b2036;
    color: #00d4ff;
    font-weight: bold;
    padding-top: 7px;
    padding-bottom: 6px;
    border-top: 1px solid #1a5a7e;
    border-left: 1px solid #1a5a7e;
    border-right: 1px solid #1a5a7e;
    border-bottom: 0;
}

.provider-table .local-selector-title {
    font-size: 11px;
    letter-spacing: 0.2px;
}

.provider-table .local-group-row td:first-child {
    border-left: 1px solid #1a5a7e;
}

.provider-table .local-group-row td:last-child {
    border-right: 1px solid #1a5a7e;
}

.provider-table .local-group-last td {
    border-bottom: 1px solid #1a5a7e;
}

.provider-table .local-none-row td {
    background: #0a1a2e;
}

.provider-table .local-none-label {
    color: #aab7c4;
    font-style: italic;
}

.provider-table .local-selector-heading + .local-none-row td {
    border-top: 0;
}


/* ========================================================== */
/* OPO UI ARCHITECTURE BATCH 1                               */
/* ========================================================== */
.configuration-panel {
    margin: 8px 0 10px 0;
    border: 1px solid #1a5a7e;
    border-radius: 8px;
    background: #0a1a2e;
    overflow: hidden;
}

.configuration-panel > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 9px 12px;
    background: #0b2036;
    color: #00d4ff;
    list-style: none;
    user-select: none;
}

.configuration-panel > summary::-webkit-details-marker { display: none; }
.configuration-panel > summary::before {
    content: '▸';
    color: #ffd93d;
    font-size: 13px;
    width: 12px;
}
.configuration-panel[open] > summary::before { content: '▾'; }
.configuration-title { font-weight: bold; white-space: nowrap; }
.configuration-summary {
    color: #aab7c4;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.configuration-body { padding: 0 10px 6px 10px; }

.provider-table .local-token-row td {
    background: #0a1a2e;
    padding-top: 5px;
    padding-bottom: 7px;
}
.provider-table .local-token-row td:first-child {
    border-left: 1px solid #1a5a7e;
}
.provider-table .local-token-row td:last-child {
    border-right: 1px solid #1a5a7e;
}

.local-token-control {
    margin: 0;
    min-height: 30px;
}
.local-token-control.disabled { opacity: 0.48; }
.local-token-control.disabled select { cursor: not-allowed; }

.ask-workflow {
    margin: 8px 0 10px 0;
    padding: 10px;
    border: 1px solid #1a3a5e;
    border-radius: 8px;
    background: #0a1a2e;
}
.ask-workflow .query-input { margin: 0; }
.ask-workflow .examples { margin-top: 6px; }

.local-inline-status {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 24px;
    margin-top: 7px;
    color: #ffd93d;
    font-size: 12px;
}
.local-inline-status.ready { color: #00ff88; }
.local-inline-status.neutral { color: #8899aa; }
.local-inline-status.waiting { color: #ffd93d; }
.local-inline-status.error { color: #ff6b6b; }
.local-inline-text { flex: 0 1 auto; }
.local-inline-progress {
    position: relative;
    flex: 1 1 150px;
    max-width: 240px;
    height: 5px;
    overflow: hidden;
    border-radius: 4px;
    background: #1a2a4a;
}
.local-inline-progress > span {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 38%;
    border-radius: 4px;
    background: #00d4ff;
    animation: opo-local-progress 1.25s ease-in-out infinite alternate;
}
@keyframes opo-local-progress {
    from { left: 0; }
    to { left: 62%; }
}

#askBtn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.history-label {
    color: #00d4ff;
    font-weight: bold;
    font-size: 12px;
    margin: 10px 0 -3px 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

@media (max-width: 768px) {
    .configuration-panel > summary { align-items: flex-start; }
    .configuration-summary { white-space: normal; }
    .local-inline-status { flex-wrap: wrap; }
    .local-inline-progress { max-width: none; flex-basis: 100%; }
}

/* ========================================================== */
/* OPO STRUCTURED QUERY HISTORY - BATCH 2                    */
/* ========================================================== */
.configuration-feedback {
    min-height: 18px;
    margin: 3px 2px 1px 2px;
    color: #8ecfff;
    font-size: 11px;
}
.configuration-feedback.error { color: #ff6b6b; }

.chat-box {
    background: transparent;
    padding: 0;
    border-radius: 0;
    overflow: visible;
}

.query-panel {
    margin: 8px 0;
    border: 1px solid #1a3a5e;
    border-radius: 8px;
    background: #0a1a2e;
    overflow: hidden;
}
.query-panel.newest { border-color: #1a5a7e; }
.query-panel > summary,
.response-panel > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.query-panel > summary::-webkit-details-marker,
.response-panel > summary::-webkit-details-marker {
    display: none;
}

.query-panel-summary {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 7px 10px;
    background: #0f2030;
}
.query-panel.newest .query-panel-summary { background: #0b2944; }
.query-chevron::before,
.response-chevron::before {
    content: '▸';
    color: #ffd93d;
}
.query-panel[open] > .query-panel-summary .query-chevron::before,
.response-panel[open] > .response-panel-summary .response-chevron::before {
    content: '▾';
}
.query-summary-question {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e8f3ff;
    font-weight: bold;
    font-size: 13px;
}
.query-summary-meta {
    display: flex;
    gap: 9px;
    color: #8fa5b8;
    font-size: 10px;
    white-space: nowrap;
}
.query-panel-body { padding: 8px; }
.query-configuration-snapshot {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0 2px 7px 2px;
    color: #71879b;
    font-size: 10px;
}
.query-pending,
.query-error,
.query-partial-errors {
    padding: 9px 11px;
    border-radius: 6px;
    background: #10263a;
    color: #ffd93d;
    font-size: 12px;
}
.query-error,
.query-partial-errors {
    color: #ff9a9a;
    background: #2b1d2a;
}
.query-partial-errors { margin-top: 7px; }

.response-panel {
    margin: 6px 0;
    border: 1px solid #1a3a5e;
    border-radius: 7px;
    background: #0b1728;
    overflow: hidden;
}
.response-panel.best { border-color: #8e7a25; }
.response-panel-summary {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 5px 9px;
    background: #0f2030;
}
.response-panel.best > .response-panel-summary { background: #1a2a3d; }
.response-summary-provider {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    color: #e3edf7;
    font-size: 12px;
}
.response-summary-provider strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.response-summary-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8fa5b8;
    font-size: 10px;
    white-space: nowrap;
}
.response-summary-rating { color: #ffd93d; }
.response-panel-content { border-top: 1px solid #1a3a5e; }
.response-expanded-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 6px 10px;
    background: #0d1b2b;
}
.response-expanded-meta .rating-buttons {
    display: flex;
    gap: 2px;
    margin-left: auto;
}
.response-expanded-meta .rating-btn {
    background: #1a1a2e;
    border: 1px solid #333;
    color: #888;
    padding: 1px 6px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 10px;
}
.response-expanded-meta .rating-btn:hover { background: #00d4ff; color: #1a1a2e; }
.response-expanded-meta .rating-btn.selected { background: #ffd93d; color: #1a1a2e; border-color: #ffd93d; }
.response-expanded-meta .rating-btn.rated-1 { background: #ff6b6b; color: white; }
.response-expanded-meta .rating-btn.rated-2 { background: #ffa94d; color: white; }
.response-expanded-meta .rating-btn.rated-3 { background: #ffd93d; color: #1a1a2e; }
.response-expanded-meta .rating-btn.rated-4 { background: #51cf66; color: white; }
.response-expanded-meta .rating-btn.rated-5 { background: #00ff88; color: #1a1a2e; }
.response-expanded-meta .feedback-text { font-size: 11px; color: #888; }
.response-panel .card-body {
    max-height: 520px;
    border: 0;
}

.boost-children {
    margin: 8px 10px 10px 22px;
    padding-left: 10px;
    border-left: 2px solid #ffd93d55;
}
.boost-response-panel { background: #141a29; }
.boost-pending {
    margin: 8px 10px 10px 22px;
    padding: 7px 9px;
    border-left: 2px solid #ffd93d;
    color: #ffd93d;
    font-size: 11px;
}

@media (max-width: 768px) {
    .query-panel-summary,
    .response-panel-summary {
        grid-template-columns: 14px minmax(0, 1fr);
    }
    .query-summary-meta,
    .response-summary-meta {
        grid-column: 2;
        white-space: normal;
        flex-wrap: wrap;
    }
    .response-expanded-meta .rating-buttons { margin-left: 0; }
    .boost-children { margin-left: 8px; }
}
.query-full-question {
    margin: 0 2px 7px 2px;
    color: #cfe8ff;
    font-size: 12px;
    line-height: 1.45;
}
