/* =====================================================================
   P62 · NL Query Panel — statistical query surface
   Separate from research/writing. Dark-theme, desktop-first.
   ===================================================================== */

/* ---- Tab button in exec-bar ---------------------------------------- */
.vi-eb-tab[data-view="nl-query"] svg { stroke: currentColor; }

/* ---- Panel container ----------------------------------------------- */
#nl-query-view {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--ip-bg, #0d0d1a);
    color: var(--ip-text, #e0e0e0);
}
#nl-query-view.nlq-active { display: flex; }

/* ---- Top search bar ------------------------------------------------ */
.nlq-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px 12px;
    border-bottom: 1px solid var(--vc-border, rgba(150,145,175,0.15));
    background: var(--ip-bg-surface, #1a1a2e);
    flex-shrink: 0;
}

.nlq-input {
    flex: 1;
    background: var(--vc-bg3, #0f0f1a);
    border: 1px solid var(--vc-border, rgba(150,145,175,0.2));
    border-radius: 8px;
    color: var(--ip-text, #e0e0e0);
    font-size: 14px;
    padding: 9px 14px;
    outline: none;
    transition: border-color 0.15s;
}
.nlq-input:focus { border-color: var(--ip-accent, #8b5cf6); }
.nlq-input::placeholder { color: var(--ip-text-muted, #787670); }

.nlq-submit-btn {
    background: var(--ip-accent, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, opacity 0.15s;
}
.nlq-submit-btn:hover { background: #7c3aed; }
.nlq-submit-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- Body: presets + results --------------------------------------- */
.nlq-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ---- Preset sidebar ------------------------------------------------ */
.nlq-presets {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid var(--vc-border, rgba(150,145,175,0.15));
    overflow-y: auto;
    padding: 14px 10px;
    background: var(--ip-bg-surface, #1a1a2e);
}
.nlq-presets-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ip-text-muted, #787670);
    margin-bottom: 8px;
    padding: 0 4px;
}
.nlq-preset-chip {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 1px solid var(--vc-border, rgba(150,145,175,0.15));
    border-radius: 6px;
    color: var(--ip-text, #e0e0e0);
    font-size: 11.5px;
    padding: 7px 10px;
    margin-bottom: 5px;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.12s, border-color 0.12s;
}
.nlq-preset-chip:hover {
    background: rgba(139,92,246,0.1);
    border-color: var(--ip-accent, #8b5cf6);
}
.nlq-saved-sep {
    border: none;
    border-top: 1px solid var(--vc-border, rgba(150,145,175,0.1));
    margin: 10px 0;
}

/* ---- Results pane -------------------------------------------------- */
.nlq-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Idle state */
.nlq-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--ip-text-muted, #787670);
    text-align: center;
    gap: 10px;
}
.nlq-idle svg { opacity: 0.3; }
.nlq-idle p { font-size: 13px; max-width: 340px; line-height: 1.5; }

/* Interpretation banner */
.nlq-interpretation {
    background: rgba(139,92,246,0.08);
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    color: var(--ip-text, #e0e0e0);
    line-height: 1.5;
}
.nlq-interpretation strong {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ip-accent, #8b5cf6);
    margin-bottom: 3px;
}

/* Loading spinner */
.nlq-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ip-text-muted, #787670);
    font-size: 13px;
}
.nlq-spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--vc-border, rgba(150,145,175,0.2));
    border-top-color: var(--ip-accent, #8b5cf6);
    border-radius: 50%;
    animation: nlq-spin 0.7s linear infinite;
}
@keyframes nlq-spin { to { transform: rotate(360deg); } }

/* Error */
.nlq-error {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    color: #fca5a5;
}

/* Clarification */
.nlq-clarification {
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12.5px;
    color: #fcd34d;
}

/* Result meta bar */
.nlq-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: var(--ip-text-muted, #787670);
}
.nlq-meta .nlq-row-count { font-weight: 600; color: var(--ip-text, #e0e0e0); }
.nlq-meta .nlq-duration { }
.nlq-meta .nlq-cached-badge {
    background: rgba(34,197,94,0.15);
    color: #4ade80;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
}
.nlq-export-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--vc-border, rgba(150,145,175,0.2));
    border-radius: 6px;
    color: var(--ip-text, #e0e0e0);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.12s;
}
.nlq-export-btn:hover { background: rgba(255,255,255,0.05); }

/* Single-number visual */
.nlq-visual-number {
    text-align: center;
    padding: 24px 0;
}
.nlq-big-number {
    font-size: 48px;
    font-weight: 700;
    color: var(--ip-accent, #8b5cf6);
    line-height: 1;
}
.nlq-big-label {
    font-size: 12px;
    color: var(--ip-text-muted, #787670);
    margin-top: 6px;
}

/* Chart canvas */
.nlq-chart-wrap {
    background: var(--ip-bg-surface, #1a1a2e);
    border: 1px solid var(--vc-border, rgba(150,145,175,0.1));
    border-radius: 8px;
    padding: 12px;
}
/* Plotly chart container fills the wrap */

/* Table */
.nlq-table-wrap {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--vc-border, rgba(150,145,175,0.1));
}
.nlq-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}
.nlq-table th {
    background: var(--ip-bg-surface, #1a1a2e);
    color: var(--ip-text-muted, #787670);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.04em;
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--vc-border, rgba(150,145,175,0.1));
    white-space: nowrap;
}
.nlq-table td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--vc-border, rgba(150,145,175,0.07));
    color: var(--ip-text, #e0e0e0);
    vertical-align: top;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.nlq-table tr:last-child td { border-bottom: none; }
.nlq-table tr:hover td { background: rgba(255,255,255,0.025); }

/* Pagination */
.nlq-pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ip-text-muted, #787670);
}
.nlq-page-btn {
    background: none;
    border: 1px solid var(--vc-border, rgba(150,145,175,0.2));
    border-radius: 5px;
    color: var(--ip-text, #e0e0e0);
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.1s;
}
.nlq-page-btn:hover { background: rgba(255,255,255,0.05); }
.nlq-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Save preset row */
.nlq-save-preset-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nlq-save-preset-btn {
    background: none;
    border: 1px solid var(--vc-border, rgba(150,145,175,0.2));
    border-radius: 6px;
    color: var(--ip-text-muted, #787670);
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    transition: color 0.1s, border-color 0.1s;
}
.nlq-save-preset-btn:hover { color: var(--ip-accent, #8b5cf6); border-color: var(--ip-accent, #8b5cf6); }
