/* ============================================================
   TQL — Threat Query Language UI
   ============================================================ */

/* ── Query input container ── */
.bql-container {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

.bql-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.bql-input {
    flex: 1;
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    padding: 12px 16px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s;
    min-height: 44px;
}

.bql-input:focus {
    border-color: #36d0ea;
    box-shadow: 0 0 0 2px rgba(54, 208, 234, 0.1);
}

.bql-input::placeholder {
    color: #555;
    font-style: italic;
}

.bql-btn {
    padding: 0 16px;
    background: linear-gradient(135deg, #36d0ea 0%, #2bb8d1 100%);
    border: none;
    border-radius: 6px;
    color: #ffffff;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.bql-btn:hover {
    opacity: 0.85;
}

.bql-btn-help {
    padding: 0 12px;
    background: #222;
    border: 1px solid #444;
    border-radius: 6px;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.bql-btn-help:hover {
    color: #36d0ea;
    border-color: #36d0ea;
}

/* ── Error message ── */
.bql-error {
    display: none;
    margin-top: 6px;
    padding: 8px 12px;
    background: rgba(153, 27, 27, 0.1);
    border: 1px solid rgba(153, 27, 27, 0.3);
    border-radius: 4px;
    color: #f87171;
    font-size: 12px;
    font-family: monospace;
}

.bql-error.visible {
    display: block;
}

/* ── Autocomplete dropdown ── */
.bql-autocomplete {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: #f8fafc;
    border: 1px solid #333;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.bql-autocomplete.visible {
    display: block;
}

.bql-ac-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #222;
    transition: background 0.1s;
}

.bql-ac-item:last-child {
    border-bottom: none;
}

.bql-ac-item:hover,
.bql-ac-item.selected {
    background: #252525;
}

.bql-ac-item.selected {
    border-left: 2px solid #36d0ea;
    padding-left: 10px;
}

.bql-ac-label {
    color: #e0e0e0;
    font-family: monospace;
    font-size: 13px;
    font-weight: 600;
    min-width: 120px;
}

.bql-ac-desc {
    color: #666;
    font-size: 12px;
    flex: 1;
}

.bql-ac-cat {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.bql-ac-cat.field { background: rgba(54, 208, 234, 0.15); color: #36d0ea; }
.bql-ac-cat.operator { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.bql-ac-cat.value { background: rgba(34, 197, 94, 0.15); color: #cbd5e1; }
.bql-ac-cat.connector { background: rgba(100, 116, 139, 0.15); color: #64748b; }

/* ── Help modal ── */
.bql-help-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
}

.bql-help-overlay.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bql-help-modal {
    background: #f8fafc;
    border: 1px solid #333;
    border-radius: 12px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.bql-help-modal h2 {
    color: #e0e0e0;
    margin: 0 0 20px;
    font-size: 20px;
}

.bql-help-modal h3 {
    color: #36d0ea;
    margin: 24px 0 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bql-help-modal table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 13px;
}

.bql-help-modal th {
    text-align: left;
    padding: 6px 8px;
    color: #888;
    border-bottom: 1px solid #333;
    font-weight: 600;
}

.bql-help-modal td {
    padding: 5px 8px;
    color: #ccc;
    border-bottom: 1px solid #222;
}

.bql-help-modal code {
    background: #222;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 12px;
    color: #36d0ea;
}

.bql-help-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
}

.bql-help-close:hover {
    color: #0f172a;
}

.bql-help-examples code {
    display: block;
    margin: 4px 0;
    padding: 6px 10px;
    background: #111;
    border-radius: 4px;
    color: #ccc;
}

/* ── Active query indicator ── */
.bql-active-indicator {
    display: none;
    margin-top: 6px;
    font-size: 12px;
    color: #36d0ea;
}

.bql-active-indicator.visible {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bql-clear-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 12px;
    text-decoration: underline;
}

.bql-clear-btn:hover {
    color: #0f172a;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .bql-input {
        font-size: 13px;
        padding: 10px 12px;
    }

    .bql-help-modal {
        padding: 20px;
        max-height: 90vh;
    }

    .bql-help-modal table {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .bql-input-row {
        flex-direction: column;
    }

    .bql-btn, .bql-btn-help {
        width: 100%;
        justify-content: center;
    }
}
