/* Content Evaluator - Custom Styles */

:root {
    --primary-color: #4472C4;
    --success-color: #70AD47;
    --warning-color: #FFC000;
    --danger-color: #FF6B6B;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.card-header {
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

/* Forms */
.form-label {
    color: #333;
    font-weight: 500;
}

.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid #ddd;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(68, 114, 196, 0.25);
}

/* Buttons */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 500;
}

.btn-primary:hover {
    background-color: #3860a0;
    border-color: #3860a0;
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-success:hover {
    background-color: #5d8f3a;
    border-color: #5d8f3a;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: #f5f5f5;
    border-color: #ddd;
    font-weight: 600;
    color: #333;
}

.table tbody tr:hover {
    background-color: #f9f9f9;
}

.table-responsive {
    border-radius: 6px;
    border: 1px solid #ddd;
}

/* Alerts */
.alert {
    border: none;
    border-radius: 6px;
    border-left: 4px solid;
}

.alert-info {
    border-left-color: var(--primary-color);
    background-color: #f0f4ff;
    color: #003d99;
}

.alert-success {
    border-left-color: var(--success-color);
    background-color: #f0f7e8;
    color: #2d5016;
}

.alert-warning {
    border-left-color: var(--warning-color);
    background-color: #fffaf0;
    color: #8c6600;
}

.alert-danger {
    border-left-color: var(--danger-color);
    background-color: #ffe8e8;
    color: #8c2020;
}

/* Navigation */
.navbar-brand {
    font-size: 1.3rem;
}

.nav-tabs .nav-link {
    color: #666;
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: transparent;
}

/* Pagination */
.pagination .page-link {
    color: var(--primary-color);
    border-color: #ddd;
}

.pagination .page-link:hover {
    color: white;
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.pagination .page-link.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* D2: Ensure radio buttons are clearly visible in admin settings */
.form-check-input[type="radio"] {
    width: 1.2em;
    height: 1.2em;
    border: 2px solid #6c757d;
    cursor: pointer;
}

.form-check-input[type="radio"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* D3: Ensure range sliders are visible and styled */
.form-range {
    height: 1.5rem;
    cursor: pointer;
}

.form-range::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    background-color: var(--primary-color);
}

.form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background-color: var(--primary-color);
    border: none;
}

.form-range::-webkit-slider-runnable-track {
    height: 6px;
}

.form-range::-moz-range-track {
    height: 6px;
}

/* Loading spinner — standalone (progress indicators, loading states) */
.text-center > .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Inline spinners (progress steps, buttons) — keep Bootstrap defaults */
.spinner-border-sm {
    width: 1rem !important;
    height: 1rem !important;
    border-width: 0.15em !important;
    vertical-align: middle;
}

/* ── A6: Heatmap table (matching reference layout) ────────────────── */
.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
}

.heatmap-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 12px;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.heatmap-table td {
    padding: 10px;
    border-bottom: 1px solid #eee;
}

/* Query column — constrained width with ellipsis */
.heatmap-table td:nth-child(2) {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Index column — narrow and centered */
.heatmap-table td:first-child,
.heatmap-table th:first-child {
    width: 50px;
    text-align: center;
    font-weight: 600;
    color: #666;
}

/* Score cells — aligned, readable */
.heatmap-cell {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    padding: 10px 8px !important;
    width: 120px;
    min-width: 120px;
    transition: opacity 0.15s ease;
    white-space: nowrap;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.7);
    color: #333;
}

.heatmap-cell:hover {
    opacity: 0.85;
}

/* Winning score indicator */
.heatmap-cell strong {
    text-shadow: none;
}

.totals-row td {
    border-top: 2px solid #333 !important;
    background-color: #f9f9f9;
    font-weight: bold;
    font-size: 1.05em;
}

/* Sortable column headers */
.sortable-col {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.sortable-col:hover {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

/* ── A6: Evidence sections ─────────────────────────────────────────── */
.qc-results .collapse {
    transition: none;
}

.qc-results .btn-outline-secondary {
    text-align: left;
    border-color: #e0e0e0;
    padding: 10px 15px;
}

.qc-results .btn-outline-secondary:hover {
    background-color: #f8f9fa;
    border-color: #ccc;
}

/* Evidence table spacing */
.qc-results .table-sm td {
    padding: 8px 10px;
    vertical-align: top;
}

.qc-results .table-sm td:nth-child(4) {
    /* Snippet column — allow wrapping */
    max-width: 500px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
}

/* ── A6: Results layout — max-width centering ──────────────────────── */
.qc-results {
    max-width: 1200px;
    margin: 0 auto;
}

/* ── A6: Go-to-top button ──────────────────────────────────────────── */
.go-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background-color: var(--primary-color);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
}

.go-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.go-to-top:hover {
    background-color: #3860a0;
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

/* Footer */
footer {
    margin-top: auto;
}

/* ── A6: Responsiveness (desktop/laptop viewport focus) ─────────── */

/* Large screens — give heatmap tables room to breathe */
@media (min-width: 1400px) {
    .qc-results {
        max-width: 1400px;
    }
}

/* Medium screens — smaller desktops / laptops */
@media (max-width: 1200px) {
    .heatmap-cell {
        min-width: 100px;
        width: 100px;
        font-size: 0.8rem;
        padding: 8px 6px !important;
    }

    .heatmap-table td:nth-child(2) {
        max-width: 300px;
    }
}

/* Tablet / small laptop */
@media (max-width: 992px) {
    .heatmap-cell {
        min-width: 90px;
        font-size: 0.75rem;
    }

    .heatmap-table th {
        padding: 8px;
        font-size: 0.85rem;
    }
}

/* Narrow / mobile (low priority per spec, but prevent breakage) */
@media (max-width: 768px) {
    .card {
        margin-bottom: 1rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    .nav-tabs {
        flex-wrap: wrap;
    }

    .nav-tabs .nav-link {
        padding: 0.5rem 0.75rem;
    }

    .go-to-top {
        bottom: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}


/* v2.8.1: Navbar status bar removed — tool availability is shown via the
   Tool Status panel (dashboard) and the below-navbar banner (all pages).
   CSS for .nav--available / .nav--busy / #nav-status-text deleted. */

/* ═════════════════════════════════════════════════════════════════════
 * v2.8.0 Phase B4 — Tool Status Banner
 *
 * Sits below the sticky navbar, above the container flash messages.
 * Hidden by default (the `hidden` HTML attribute); `tool_status.js`
 * toggles it based on the global lock / maintenance snapshot.
 *
 * Three level modifiers:
 *   --info  : in-use (someone else is running an analysis)
 *   --warn  : maintenance mode, SSE degraded-mode fallback
 *   --error : reserved for future critical surface area
 *
 * Styling stays deliberately light-touch so it doesn't fight the
 * Bootstrap alerts used for flashed messages immediately below it.
 * ═══════════════════════════════════════════════════════════════════ */
.tool-status-banner {
    padding: 10px 16px;
    font-size: 0.95rem;
    border-bottom: 1px solid transparent;
    text-align: center;
    line-height: 1.4;
}
.tool-status-banner[hidden] {
    display: none !important;
}
.tool-status-banner--info {
    background: #e7f5ff;
    color: #0b4e77;
    border-bottom-color: #b5d8eb;
}
.tool-status-banner--warn {
    background: #fff7e6;
    color: #7a4a00;
    border-bottom-color: #e8c38a;
}
.tool-status-banner--error {
    background: #fde8e8;
    color: #7a1a1a;
    border-bottom-color: #eaa0a0;
}

@media (prefers-reduced-motion: no-preference) {
    /* Soft fade when the banner toggles — avoids a jarring layout jump. */
    .tool-status-banner {
        transition: background 120ms ease, color 120ms ease;
    }
}

/* v2.8.0 Phase B5 — Dashboard Tool Status panel.
   Five state modifiers plus a `loading` initial state. Leans on the
   existing `.card` base for shadow/radius. Colors are kept close to
   the banner palette above so the two pieces read as one system. */
.tool-status-panel .tsp-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    vertical-align: middle;
}
.tool-status-panel .tsp-summary { min-width: 0; flex: 1 1 260px; }
.tool-status-panel .tsp-controls { flex: 0 0 auto; }

.tool-status-panel--loading {
    border-left: 4px solid #b5d8eb;
}
.tool-status-panel--loading .tsp-icon { color: #6c757d; }

.tool-status-panel--idle {
    border-left: 4px solid #70AD47;
    background: #f3faf1;
}
.tool-status-panel--idle .tsp-icon { color: #4f8131; }

.tool-status-panel--in_use_me {
    border-left: 4px solid #4472C4;
    background: #eef3fb;
}
.tool-status-panel--in_use_me .tsp-icon { color: #2a4d84; }

.tool-status-panel--in_use_other {
    border-left: 4px solid #f0ad4e;
    background: #fff7e6;
}
.tool-status-panel--in_use_other .tsp-icon { color: #7a4a00; }

.tool-status-panel--maintenance {
    border-left: 4px solid #6c757d;
    background: #f1f3f5;
}
.tool-status-panel--maintenance .tsp-icon { color: #495057; }

.tool-status-panel--stream_down {
    border-left: 4px solid #FF6B6B;
    background: #fde8e8;
}
.tool-status-panel--stream_down .tsp-icon { color: #7a1a1a; }

@media (prefers-reduced-motion: no-preference) {
    .tool-status-panel {
        transition: background 160ms ease, border-color 160ms ease;
    }
}
