/* ============================================================
   Hunter — custom styles on top of AdminLTE v4 + Bootstrap 5
   AdminLTE provides: layout, sidebar, navbar, cards, tables.
   This file only adds what AdminLTE doesn't cover.
============================================================ */

/* ── Page header typography ── */
.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    color: var(--bs-body-color);
}
.page-subtitle {
    font-size: .8rem;
    color: var(--bs-secondary-color);
    margin: 0;
    line-height: 1.4;
}

/* ── Avatar ── */
.avatar-xs {
    width: 28px; height: 28px;
    border-radius: 50%;
    background-color: #0d6efd;
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ── Monospace helper ── */
.font-mono { font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace; }

/* ── Log output (terminal) ── */
.log-output {
    background: #212529;
    color: #20c997;
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: .75rem;
    line-height: 1.6;
    padding: 1rem;
    border-radius: .375rem;
    max-height: 600px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ── Stat cards ── */
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.stat-label {
    font-size: .75rem;
    color: #6c757d;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: .15rem;
}
.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}
.stat-icon {
    width: 42px; height: 42px;
    border-radius: .5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

/* Dashboard valid results doughnut */
.hunter-valid-card-body {
    height: 220px;
}
.hunter-valid-chart-layout {
    display: grid;
    grid-template-columns: minmax(120px, 42%) minmax(0, 1fr);
    gap: .75rem;
    align-items: center;
    height: 100%;
}
.hunter-valid-canvas-wrap {
    height: 176px;
    min-width: 0;
}
.hunter-valid-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}
.hunter-valid-legend {
    display: grid;
    gap: .28rem;
    align-content: center;
    min-width: 0;
}
.hunter-valid-legend-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: .42rem;
    min-height: 24px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    font: inherit;
    font-size: .78rem;
    text-decoration: none;
    text-align: left;
    min-width: 0;
}
.hunter-valid-legend-item:hover {
    color: var(--bs-primary);
}
.hunter-valid-legend-item:focus-visible {
    outline: 2px solid rgba(13, 110, 253, .45);
    outline-offset: 2px;
    border-radius: .25rem;
}
.hunter-valid-other-btn {
    cursor: pointer;
}
.hunter-valid-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.hunter-valid-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    min-width: 0;
}
.hunter-valid-count {
    color: var(--bs-success);
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
.hunter-valid-detail-icon {
    color: var(--bs-primary);
    font-size: .75rem;
}
.hunter-valid-detail-table {
    table-layout: fixed;
}
.hunter-valid-detail-table th {
    color: var(--bs-secondary-color);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.hunter-valid-detail-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .hunter-valid-chart-layout {
        grid-template-columns: 110px minmax(0, 1fr);
        gap: .5rem;
    }
    .hunter-valid-canvas-wrap {
        height: 150px;
    }
}

/* ── Status tabs (results page) ── */
.result-tabs {
    display: flex;
    gap: .375rem;
    flex-wrap: wrap;
}
.result-tab {
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: .375rem;
    padding: .3rem .75rem;
    font-size: .8rem;
    font-weight: 500;
    color: #6c757d;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    transition: all .15s;
}
.result-tab:hover { border-color: #adb5bd; color: #343a40; }
.result-tab.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}
.result-tab-count {
    background: rgba(0,0,0,.1);
    border-radius: .25rem;
    padding: 0 .35rem;
    font-size: .7rem;
}
.result-tab.active .result-tab-count { background: rgba(255,255,255,.25); }

/* ── Compact search strip ── */
.search-strip {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: .5rem;
    overflow: hidden;
}
.search-strip-row {
    display: flex;
    align-items: center;
    gap: 0;
    flex-wrap: nowrap;
}
.search-strip-input {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .45rem .75rem;
    border-right: 1px solid #dee2e6;
    color: #6c757d;
}
.search-strip-input input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 0;
    font-size: .875rem;
    background: transparent;
    color: #212529;
}
.search-strip-select {
    border: none;
    border-right: 1px solid #dee2e6;
    outline: none;
    font-size: .875rem;
    padding: .45rem .75rem;
    background: transparent;
    color: #495057;
    max-width: 180px;
}
.strip-clear {
    border: none;
    background: none;
    color: #adb5bd;
    cursor: pointer;
    padding: 0 .2rem;
    font-size: 1rem;
    line-height: 1;
}
.strip-clear:hover { color: #dc3545; }
.strip-btn {
    border: none;
    border-right: 1px solid #dee2e6;
    background: transparent;
    padding: .45rem .7rem;
    color: #6c757d;
    cursor: pointer;
    font-size: .875rem;
    position: relative;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}
.strip-btn:hover { background: #f8f9fa; color: #343a40; }
.strip-btn.active { color: #0d6efd; }
.strip-btn.danger { color: #dc3545; }
.strip-btn:last-child { border-right: none; }
.strip-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #0d6efd;
}
.strip-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    padding: .4rem .75rem;
    border-top: 1px solid #f3f4f6;
    background: #fafafa;
}
.strip-tag {
    font-size: .72rem;
    padding: .15rem .45rem;
    border-radius: .25rem;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    font-weight: 500;
}
.strip-tag a { text-decoration: none; opacity: .7; }
.strip-tag a:hover { opacity: 1; }
.strip-tag.primary { background: #dbeafe; color: #1e40af; }
.strip-tag.secondary { background: #f3f4f6; color: #374151; }
.strip-tag.danger { background: #fee2e2; color: #991b1b; }
.strip-tag.success { background: #d1fae5; color: #065f46; }
.strip-tag.warning { background: #fef3c7; color: #92400e; }
.strip-tag.muted { background: #f3f4f6; color: #6c757d; }
.search-strip-count {
    padding: .45rem .75rem;
    font-size: .8rem;
    color: #9ca3af;
    white-space: nowrap;
    border-left: 1px solid #dee2e6;
}

/* ── Advanced filter panel ── */
.adv-panel { border-radius: .5rem; }
.adv-layout {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.adv-controls-pane { flex: 1; min-width: 220px; }
.adv-flags-pane { flex: 2; min-width: 280px; }
.adv-control-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.adv-date-grid { display: flex; gap: .5rem; flex-wrap: wrap; }
.adv-control-item { flex: 1; min-width: 130px; }
.adv-input { font-size: .8rem !important; }
.adv-toggles-wrap { display: flex; flex-wrap: wrap; gap: .75rem; }
.adv-flag-group { }
.adv-flag-group-title {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #9ca3af;
    margin-bottom: .3rem;
}
.adv-flag-buttons { display: flex; flex-wrap: wrap; gap: .3rem; }
.adv-flag-btn { font-size: .72rem !important; padding: .15rem .5rem !important; }

/* ── Result detail panel ── */
.result-detail-panel {
    border-radius: .5rem;
    padding: 1rem;
    border: 1px solid #dee2e6;
    background: #fff;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}
.result-detail-valid { border-left: 3px solid #10b981; }
.result-detail-invalid { border-left: 3px solid #9ca3af; }

.detail-key-block {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: .375rem;
    padding: .6rem .8rem;
    margin-bottom: .5rem;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
}
.detail-key-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    margin-bottom: .25rem;
}
.detail-key-value {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-width: 0;
    max-width: 100%;
}
.detail-key-code {
    font-size: .8rem;
    background: transparent;
    color: #1e293b;
    padding: 0;
    flex: 1;
    min-width: 0;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.detail-key-copy {
    border: none;
    background: none;
    color: #94a3b8;
    cursor: pointer;
    padding: .1rem .3rem;
    border-radius: .25rem;
    flex-shrink: 0;
    font-size: .8rem;
}
.detail-key-copy:hover { color: #0d6efd; background: #eff6ff; }
.detail-key-copy.copied { color: #10b981; }

.result-detail-panel code,
.result-detail-panel .badge {
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    text-align: left;
}

.detail-tags-row { display: flex; align-items: center; min-width: 0; }
.detail-tags-wrap { display: flex; flex-wrap: wrap; gap: .3rem; min-width: 0; max-width: 100%; }
.detail-tag {
    font-size: .72rem;
    font-weight: 500;
    padding: .15rem .5rem;
    border-radius: .25rem;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.candidate-score-line {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    align-items: center;
    gap: .5rem;
    max-width: 360px;
}
.candidate-score-track {
    height: .42rem;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
    min-width: 0;
}
.candidate-score-fill {
    height: 100%;
    border-radius: inherit;
    transition: width .2s ease;
}
.candidate-score-fill.high { background: #10b981; }
.candidate-score-fill.medium { background: #f59e0b; }
.candidate-score-fill.low { background: #94a3b8; }
.candidate-score-text {
    font-size: .72rem;
    font-weight: 700;
    color: #475569;
}
.candidate-evidence {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    max-width: 100%;
}
.candidate-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: .12rem .42rem;
    border-radius: .3rem;
    font-size: .68rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}
.candidate-chip.good {
    background: #ecfdf5;
    color: #047857;
}
.candidate-chip.warn {
    background: #fff7ed;
    color: #c2410c;
}

.detail-info-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .5rem;
    min-width: 0;
    max-width: 100%;
}
.detail-info-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: .375rem;
    padding: .4rem .7rem;
    min-width: 140px;
    max-width: 100%;
    flex: 1;
    overflow-x: hidden;
}
.detail-info-item.error-item {
    background: #fff5f5;
    border-color: #fed7d7;
    flex: 100%;
}
.detail-info-item.models-item { flex: 100%; }
.detail-info-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #94a3b8;
    margin-bottom: .15rem;
}
.detail-info-value {
    font-size: .82rem;
    color: #1e293b;
    word-break: break-word;
    overflow-wrap: anywhere;
    min-width: 0;
    max-width: 100%;
}
.detail-info-value.plain {
    font-family: 'Cascadia Code', Consolas, monospace;
    word-break: break-all;
}

.detail-chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    min-width: 0;
    max-width: 100%;
}
.detail-chip {
    font-size: .7rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: .25rem;
    padding: .1rem .4rem;
    color: #475569;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.detail-chip.more { color: #0d6efd; cursor: pointer; border-color: #bfdbfe; background: #eff6ff; }

.databricks-llm-panel {
    background: #f8fafc;
    border: 1px solid #dbe5ef;
    border-radius: .375rem;
    padding: .6rem .75rem;
    max-width: 100%;
    min-width: 0;
}
.databricks-llm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    flex-wrap: wrap;
    color: #334155;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.databricks-llm-badges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: .25rem;
    justify-content: flex-end;
}
.databricks-llm-note {
    margin-top: .35rem;
    font-size: .76rem;
    font-weight: 600;
}
.databricks-llm-models {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .4rem;
}
.databricks-llm-model {
    font-size: .7rem;
    background: #fff;
    border: 1px solid #dbeafe;
    color: #1e40af;
    border-radius: .25rem;
    padding: .1rem .4rem;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.databricks-llm-model.more {
    background: #eff6ff;
    color: #0d6efd;
}

.detail-source-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .6rem;
    padding-top: .5rem;
    border-top: 1px solid #f1f5f9;
    font-size: .78rem;
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}
.detail-source-row > * { min-width: 0; }

/* ── Empty state ── */
.empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 2rem 1rem;
}
.empty-state i {
    font-size: 2rem;
    display: block;
    margin-bottom: .5rem;
    opacity: .4;
}

/* ── Clickable rows ── */
tr.clickable-row:hover { background: rgba(13,110,253,.04); }


/* ── Strategy stats row ── */
.strategy-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: .75rem;
}
.stat-strip-item {
    display: flex;
    align-items: baseline;
    gap: .3rem;
    padding: .25rem .6rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: .375rem;
}
.stat-strip-label { font-size: .72rem; color: #6c757d; }
.stat-strip-value { font-size: .95rem; font-weight: 600; }
.stat-flash { animation: stat-flash .6s ease; }
@keyframes stat-flash {
    0%   { background: #fef3c7; }
    100% { background: transparent; }
}

/* ── Table helpers ── */
.col-chk  { width: 36px; }
.col-actions { width: 1%; white-space: nowrap; }
.table-purple { --bs-table-color: #5b21b6; --bs-table-bg: #ede9fe; }

/* ── Sidebar: level-1 vs level-2 distinction ── */

/* Level-1 parent items: more vertical breathing room */
.sidebar-menu > .nav-item > .nav-link {
    padding-top: .6rem;
    padding-bottom: .6rem;
}

/* Level-2 submenu items: compact + indented */
.nav-treeview .nav-item .nav-link {
    padding-top: .25rem;
    padding-bottom: .25rem;
    padding-left: 2.5rem;
}

/* Intelligence workspace */
.intel-page {
    --intel-border: #dbe5ef;
    --intel-border-soft: #edf2f7;
    --intel-ink: #0f172a;
    --intel-muted: #64748b;
    --intel-soft: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.intel-page > .row,
.intel-page > .card,
.intel-page > .search-strip {
    margin-bottom: 0 !important;
}
.intel-page .stat-card {
    min-height: 112px;
    border-color: var(--intel-border);
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    background: linear-gradient(180deg, #fff 0%, #f9fbfd 100%);
    overflow: hidden;
    position: relative;
}
.intel-page .stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: #94a3b8;
    opacity: .7;
}
.intel-page .stat-label {
    color: var(--intel-muted);
    font-size: .68rem;
    letter-spacing: .045em;
}
.intel-page .stat-value {
    color: var(--intel-ink);
    font-size: 1.5rem;
}
.intel-page .card {
    border-color: var(--intel-border);
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    overflow: hidden;
}
.intel-page .card-header {
    background: #fff;
    border-bottom-color: var(--intel-border-soft);
    color: var(--intel-ink);
    font-weight: 600;
    padding: .72rem 1rem !important;
}
.intel-page .card-body { padding: 1rem; }
.intel-page .table {
    --bs-table-hover-bg: #f8fbff;
    font-size: .82rem;
}
.intel-page .table thead th {
    background: var(--intel-soft);
    border-bottom-color: #dfe7f0;
    color: var(--intel-muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .045em;
    padding: .58rem .75rem;
    text-transform: uppercase;
    white-space: nowrap;
}
.intel-page .table tbody td {
    border-color: var(--intel-border-soft);
    padding: .68rem .75rem;
}
.intel-page .badge {
    border-radius: .35rem;
    font-weight: 600;
}
.intel-page code {
    background: #f1f5f9;
    border-radius: .25rem;
    color: #334155;
    padding: .05rem .28rem;
}
.intel-page .search-strip {
    border-color: var(--intel-border);
    border-radius: .5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .03);
}
.intel-jumpbar {
    align-items: center;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    border: 1px solid var(--intel-border);
    border-radius: .5rem;
    display: flex;
    gap: .9rem;
    justify-content: space-between;
    padding: .85rem 1rem;
}
.intel-jump-title {
    color: var(--intel-ink);
    font-size: .84rem;
    font-weight: 700;
}
.intel-jump-subtitle {
    color: var(--intel-muted);
    font-size: .76rem;
}
.intel-jump-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    justify-content: flex-end;
}
.intel-jump-actions .btn {
    background: #fff;
    border-radius: .4rem;
    padding: .32rem .64rem;
}
.intel-chip-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}
.intel-chip {
    align-items: center;
    background: #fff;
    border: 1px solid var(--intel-border);
    border-radius: .4rem;
    color: #334155;
    display: inline-flex;
    font-size: .74rem;
    gap: .35rem;
    padding: .22rem .55rem;
}
.intel-chip code {
    background: transparent;
    padding: 0;
}
.intel-chip .count {
    color: var(--intel-muted);
    font-weight: 700;
}
.intel-empty-cell {
    padding: 2.4rem 1rem !important;
}
.intel-empty-title {
    color: var(--intel-ink);
    font-weight: 700;
    margin-bottom: .2rem;
}
@media (max-width: 768px) {
    .intel-jumpbar {
        align-items: flex-start;
        flex-direction: column;
    }
    .intel-jump-actions { justify-content: flex-start; }
    .intel-page .table { font-size: .78rem; }
}

@media (max-width: 576px) {
    .app-main {
        overscroll-behavior-x: contain;
        touch-action: pan-y;
    }

    #chatModal .modal-dialog {
        width: min(540px, calc(100vw - 1rem));
        max-width: calc(100vw - 1rem);
        height: calc(100vh - 1rem);
        height: calc(100dvh - 1rem);
        margin: .5rem auto;
    }
    #chatModal .modal-content {
        height: 100%;
        border-radius: .5rem;
        overflow: hidden;
    }
    #chatModal .modal-header {
        align-items: flex-start;
        gap: .5rem;
    }
    #chatModalLabel {
        min-width: 0;
        flex: 1 1 auto;
        line-height: 1.25;
    }
    #chatModalLabel small {
        display: block;
        max-width: calc(100vw - 4rem);
        margin-left: 0 !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #chat-status {
        flex: 0 1 auto;
        max-width: 38vw;
        margin-left: 0 !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #chatModal .modal-body {
        display: flex;
        min-height: 0;
        overflow: hidden;
        flex-direction: column;
        padding: .75rem !important;
    }
    #pg-tabs {
        flex: 0 0 auto;
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: .25rem;
    }
    #pg-tabs .btn {
        flex: 0 0 auto;
    }
    #pg-agent-chat {
        display: flex;
        min-height: 0;
        flex: 1 1 auto;
        flex-direction: column;
    }
    #pg-agent-chat > .row {
        flex: 0 0 auto;
    }
    .playground-chat-messages {
        min-height: 120px !important;
        max-height: none !important;
        flex: 1 1 auto;
    }
    .playground-chat-composer {
        flex: 0 0 auto;
    }
    .playground-chat-composer textarea {
        max-height: 88px;
    }
    .playground-chat-actions .btn {
        min-width: 44px;
        min-height: 36px;
    }
}
