/* ═══════════════════════════════════════════════════════════════════════════════
   Termnova — Cross-Contract Intelligence, Clause Heatmap & Portfolio Analytics
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Main Container */
.intelligence-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 3rem;
}

/* Executive Header Widget */
.intelligence-summary-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.intel-stat-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.intel-stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 102, 241, 0.3);
}

.intel-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.intel-stat-card.risk-card::before {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
}

.intel-stat-card.value-card::before {
    background: linear-gradient(90deg, #10b981, #06b6d4);
}

.intel-stat-card.compliance-card::before {
    background: linear-gradient(90deg, #3b82f6, #6366f1);
}

.intel-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted, #94a3b8);
}

.intel-stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--color-text, #f8fafc);
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.intel-stat-sub {
    font-size: 0.75rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Sub-Navigation Tabs */
.intelligence-tabs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 0.75rem;
    overflow-x: auto;
}

.intel-tab-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.intel-tab-btn:hover {
    background: rgba(51, 65, 85, 0.6);
    color: #f1f5f9;
}

.intel-tab-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.25));
    border-color: rgba(99, 102, 241, 0.5);
    color: #a5b4fc;
    box-shadow: 0 0 16px rgba(99, 102, 241, 0.15);
}

/* Filter Toolbar */
.intel-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.75rem 1rem;
}

.intel-filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.intel-select,
.intel-input {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f8fafc;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    font-size: 0.825rem;
    outline: none;
    transition: border-color 0.2s;
}

.intel-select:focus,
.intel-input:focus {
    border-color: #6366f1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   1. Clause Heatmap Matrix Visualization
   ═══════════════════════════════════════════════════════════════════════════════ */

.heatmap-wrapper {
    position: relative;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    backdrop-filter: blur(16px);
    overflow-x: auto;
    max-height: 650px;
    overflow-y: auto;
}

.heatmap-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 0.8rem;
    min-width: 900px;
}

/* Sticky Headers */
.heatmap-table thead th {
    position: sticky;
    top: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    z-index: 10;
    padding: 1rem 0.5rem;
    font-weight: 600;
    color: #cbd5e1;
    text-align: center;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.heatmap-table thead th.doc-header-col {
    left: 0;
    z-index: 20;
    text-align: left;
    min-width: 240px;
    padding-left: 1rem;
}

/* Angled Category Header Labels */
.category-header-wrap {
    display: inline-block;
    white-space: nowrap;
    transform: rotate(-35deg);
    transform-origin: left bottom;
    margin-bottom: 10px;
    margin-left: 10px;
    font-size: 0.75rem;
    color: #94a3b8;
}

/* Sticky Document Column */
.heatmap-table tbody td.doc-cell {
    position: sticky;
    left: 0;
    background: rgba(15, 23, 42, 0.95);
    z-index: 5;
    padding: 0.6rem 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.doc-cell-content {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.doc-name {
    font-weight: 600;
    color: #f1f5f9;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-meta {
    font-size: 0.7rem;
    color: #64748b;
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Heatmap Matrix Cells */
.heatmap-cell {
    width: 44px;
    height: 44px;
    text-align: center;
    vertical-align: middle;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.heatmap-cell:hover {
    transform: scale(1.18);
    z-index: 8;
    filter: brightness(1.25);
}

/* Presence & Risk Color Tokens */
.heatmap-cell.absent {
    background: rgba(30, 41, 59, 0.4);
    color: #475569;
}

.heatmap-cell.risk-low {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.35), rgba(5, 150, 105, 0.5));
    border: 1px solid rgba(16, 185, 129, 0.5);
    color: #6ee7b7;
}

.heatmap-cell.risk-medium {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.35), rgba(217, 119, 6, 0.5));
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: #fde68a;
}

.heatmap-cell.risk-high {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.4), rgba(220, 38, 38, 0.6));
    border: 1px solid rgba(239, 68, 68, 0.6);
    color: #fca5a5;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.heatmap-cell.risk-critical {
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.6), rgba(159, 18, 57, 0.8));
    border: 1px solid #f43f5e;
    color: #ffe4e6;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.5);
    animation: pulse-critical 2s infinite ease-in-out;
}

@keyframes pulse-critical {
    0%, 100% { box-shadow: 0 0 8px rgba(244, 63, 94, 0.4); }
    50% { box-shadow: 0 0 16px rgba(244, 63, 94, 0.8); }
}

/* Heatmap Summary Footer */
.heatmap-table tfoot td {
    position: sticky;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    z-index: 10;
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-top: 2px solid rgba(255, 255, 255, 0.1);
}

.heatmap-table tfoot td.doc-cell {
    font-weight: 700;
    color: #a5b4fc;
    text-align: left;
}

.column-coverage-bar-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.coverage-pct-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #cbd5e1;
}

.mini-cov-bar {
    width: 32px;
    height: 4px;
    background: rgba(51, 65, 85, 0.8);
    border-radius: 2px;
    overflow: hidden;
}

.mini-cov-fill {
    height: 100%;
    background: #6366f1;
    border-radius: 2px;
}

/* Tooltip */
.intel-tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(99, 102, 241, 0.4);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.8), 0 0 15px rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(16px);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    max-width: 280px;
    font-size: 0.75rem;
    color: #f1f5f9;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.intel-tooltip.visible {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   2. Vendor Scorecard Panel
   ═══════════════════════════════════════════════════════════════════════════════ */

.scorecard-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .scorecard-grid {
        grid-template-columns: 1fr;
    }
}

.vendor-profile-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.vendor-title-row {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.vendor-avatar {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.vendor-kpis {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.kpi-tile {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-tile .label {
    font-size: 0.7rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 600;
}

.kpi-tile .val {
    font-size: 1.2rem;
    font-weight: 700;
    color: #f8fafc;
}

.coverage-breakdown-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.coverage-row {
    display: grid;
    grid-template-columns: 140px 1fr 45px;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.775rem;
}

.coverage-bar-track {
    height: 6px;
    background: rgba(51, 65, 85, 0.6);
    border-radius: 3px;
    overflow: hidden;
}

.coverage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #38bdf8);
    border-radius: 3px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   3. Benchmark Scoring Card
   ═══════════════════════════════════════════════════════════════════════════════ */

.benchmark-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .benchmark-layout {
        grid-template-columns: 1fr;
    }
}

.benchmark-gauge-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
}

.gauge-svg {
    width: 180px;
    height: 180px;
}

.gauge-bg {
    fill: none;
    stroke: rgba(51, 65, 85, 0.4);
    stroke-width: 14;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: url(#gauge-grad);
    stroke-width: 14;
    stroke-linecap: round;
    transition: stroke-dasharray 1s ease;
}

.benchmark-details-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.benchmark-narrative {
    background: rgba(30, 41, 59, 0.6);
    border-left: 4px solid #6366f1;
    border-radius: 0 8px 8px 0;
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e2e8f0;
}

.delta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.delta-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: #94a3b8;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.delta-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.delta-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
}

.delta-badge.favorable {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.delta-badge.unfavorable {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   4. Trends & Gap Analysis Panels
   ═══════════════════════════════════════════════════════════════════════════════ */

.trend-chart-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.trend-svg {
    width: 100%;
    height: 260px;
}

.gap-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gap-item-card {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.gap-item-card:hover {
    transform: translateX(4px);
    border-color: rgba(239, 68, 68, 0.4);
}

.gap-missing-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.missing-pill {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}
