/**
 * GEOINT Dashboard v4.2 - Feature Styles
 * AI Predictor, Conflict Simulator, Energy Monitor, Elections, Search, Alert Rules, Audit
 */

/* ===== AI THREAT PREDICTOR ===== */
.predictor-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.predictor-stat-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.predictor-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #8b5cf6, #06b6d4);
}

.predictor-stat-val {
    font-size: 22px;
    font-weight: 800;
    color: #8b5cf6;
}

.predictor-stat-lbl {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #64748b);
    margin-top: 2px;
}

/* Prediction Cards */
.prediction-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.prediction-card:hover {
    border-color: #8b5cf6;
    box-shadow: 0 0 12px rgba(139, 92, 246, 0.08);
}

.pred-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.pred-confidence {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.conf-ring {
    width: 44px;
    height: 44px;
    transform: rotate(-90deg);
}

.conf-val {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px;
    font-weight: 800;
    color: var(--conf-color, #8b5cf6);
}

.pred-info { flex: 1; min-width: 0; }
.pred-title { font-size: 13px; font-weight: 700; color: var(--text-primary, #e2e8f0); margin-bottom: 4px; }
.pred-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pred-desc { font-size: 11px; color: var(--text-secondary, #94a3b8); line-height: 1.4; margin-top: 8px; }
.pred-basis { font-size: 10px; color: #8b5cf6; margin-top: 6px; font-style: italic; opacity: 0.8; }

/* Trend Items */
.trend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.trend-item:last-child { border-bottom: none; }
.trend-category { font-size: 11px; color: var(--text-primary, #e2e8f0); width: 110px; flex-shrink: 0; }
.trend-dir { font-size: 12px; font-weight: 700; width: 60px; text-align: right; flex-shrink: 0; }
.trend-bar { height: 4px; flex: 1; background: rgba(51, 65, 85, 0.3); border-radius: 2px; overflow: hidden; }
.trend-bar-fill { height: 100%; border-radius: 2px; transition: width 0.6s ease; }
.trend-label { font-size: 8px; letter-spacing: 0.5px; width: 50px; text-align: right; flex-shrink: 0; }

/* Risk Forecast */
.forecast-item {
    padding: 8px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.forecast-item:last-child { border-bottom: none; }
.forecast-region { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); margin-bottom: 4px; }
.forecast-score-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.forecast-score { font-size: 14px; font-weight: 800; min-width: 30px; text-align: right; }
.forecast-trend { font-size: 12px; }
.forecast-threats { display: flex; gap: 4px; flex-wrap: wrap; }

/* Hotspots */
.hotspot-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.hotspot-item:last-child { border-bottom: none; }
.hotspot-spike { font-size: 18px; font-weight: 900; min-width: 50px; text-align: center; }
.hotspot-info { flex: 1; }
.hotspot-name { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); }
.hotspot-meta { display: flex; gap: 12px; }


/* ===== CONFLICT SIMULATOR ===== */
.simulator-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 12px;
    min-height: 500px;
}

.scenario-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.scenario-card:hover { border-color: var(--accent, #00d4ff); background: rgba(0, 212, 255, 0.03); }
.scenario-card.selected { border-color: var(--accent, #00d4ff); background: rgba(0, 212, 255, 0.08); }
.scenario-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.scenario-name { font-size: 12px; font-weight: 700; color: var(--text-primary, #e2e8f0); }
.scenario-desc { font-size: 10px; color: var(--text-secondary, #94a3b8); line-height: 1.3; margin-bottom: 4px; }
.scenario-meta { display: flex; gap: 10px; }

/* Sim Variables */
.sim-var {
    margin-bottom: 10px;
    padding: 8px 10px;
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border, #334155);
    border-radius: 6px;
}

.sim-var-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.sim-var-icon { font-size: 14px; }
.sim-var-name { font-size: 11px; color: var(--text-primary, #e2e8f0); flex: 1; }
.sim-var-val { font-size: 13px; font-weight: 800; color: var(--accent, #00d4ff); min-width: 30px; text-align: right; }

.sim-slider {
    width: 100%;
    height: 4px;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(51, 65, 85, 0.4);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.sim-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent, #00d4ff);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(0, 212, 255, 0.4);
}

.sim-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent, #00d4ff);
    cursor: pointer;
    border: none;
}

/* Sim Results */
.sim-result-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.sim-result-card {
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.sim-result-card.danger { border-color: rgba(239, 68, 68, 0.3); }
.sim-result-card.warning { border-color: rgba(245, 158, 11, 0.3); }
.sim-result-val { font-size: 20px; font-weight: 800; color: var(--text-primary, #e2e8f0); }
.sim-result-lbl { font-size: 9px; text-transform: uppercase; color: var(--text-muted, #64748b); margin-top: 2px; }

.sim-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent, #00d4ff);
    margin: 16px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border, #334155);
}

.sim-outcome { margin-bottom: 8px; }
.sim-outcome-bar { height: 6px; background: rgba(51, 65, 85, 0.3); border-radius: 3px; overflow: hidden; margin-bottom: 4px; }
.sim-outcome-bar div { height: 100%; border-radius: 3px; transition: width 0.6s; }
.sim-outcome-info { display: flex; gap: 8px; font-size: 11px; }
.sim-outcome-pct { font-weight: 700; color: var(--accent, #00d4ff); min-width: 35px; }
.sim-outcome-desc { color: var(--text-secondary, #94a3b8); }

.sim-timeline { padding-left: 8px; }
.sim-tl-item { display: flex; gap: 10px; margin-bottom: 8px; }
.sim-tl-marker {
    width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    background: var(--accent, #00d4ff); color: #000; font-size: 11px; font-weight: 800; flex-shrink: 0;
}
.sim-tl-period { font-size: 10px; color: var(--accent, #00d4ff); font-weight: 600; }
.sim-tl-event { font-size: 11px; color: var(--text-secondary, #94a3b8); }
.sim-recommendations { }
.sim-rec-item { font-size: 11px; color: var(--text-secondary, #94a3b8); padding: 4px 0; line-height: 1.4; }


/* ===== ENERGY & RESOURCES ===== */
.energy-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.energy-stat-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.energy-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, #f59e0b, #10b981);
}

.energy-stat-val { font-size: 22px; font-weight: 800; color: #f59e0b; }
.energy-stat-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted, #64748b); margin-top: 2px; }

/* Commodities */
.commodity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
    transition: background 0.15s;
}

.commodity-item:hover { background: rgba(245, 158, 11, 0.03); }
.commodity-item:last-child { border-bottom: none; }
.commodity-info { flex: 1; min-width: 0; }
.commodity-name { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); }
.commodity-unit { font-size: 10px; color: var(--text-muted); }
.commodity-price { font-size: 14px; font-weight: 800; color: var(--text-primary, #e2e8f0); min-width: 70px; text-align: right; }
.commodity-change { font-size: 11px; font-weight: 700; min-width: 60px; text-align: right; }
.commodity-risk { font-size: 8px; font-weight: 800; letter-spacing: 0.5px; min-width: 55px; text-align: right; }

/* Pipelines */
.pipeline-item {
    padding: 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
    transition: background 0.15s;
}

.pipeline-item:hover { background: rgba(0, 212, 255, 0.03); }
.pipeline-item:last-child { border-bottom: none; }
.pipeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.pipeline-name { font-size: 12px; font-weight: 700; color: var(--text-primary, #e2e8f0); }
.pipeline-meta { display: flex; gap: 12px; margin-bottom: 4px; }
.pipeline-threats { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

/* Chokepoints */
.chokepoint-item {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.chokepoint-item:last-child { border-bottom: none; }
.choke-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.choke-name { font-size: 12px; font-weight: 700; color: var(--text-primary, #e2e8f0); }
.choke-stats { display: flex; gap: 16px; font-size: 10px; color: var(--text-secondary, #94a3b8); }


/* ===== ELECTION MONITOR ===== */
.election-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.election-stat-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

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

.election-stat-val { font-size: 22px; font-weight: 800; color: #3b82f6; }
.election-stat-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted, #64748b); margin-top: 2px; }

.election-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    transition: border-color 0.2s;
}

.election-card:hover { border-color: #3b82f6; }

.election-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.election-flag { font-size: 26px; flex-shrink: 0; }
.election-flag-sm { font-size: 18px; flex-shrink: 0; }
.election-title { flex: 1; }
.election-country { font-size: 13px; font-weight: 700; color: var(--text-primary, #e2e8f0); }
.election-type { font-size: 10px; color: var(--text-muted, #64748b); text-transform: capitalize; }

.election-date-badge {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    color: #3b82f6;
    white-space: nowrap;
}

.election-desc { font-size: 11px; color: var(--text-secondary, #94a3b8); line-height: 1.4; margin-bottom: 8px; }

.election-indicators {
    display: flex;
    gap: 16px;
    margin-bottom: 6px;
}

.election-ind {
    display: flex;
    align-items: center;
    gap: 6px;
}

.election-candidates {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 6px;
}

.election-completed-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.election-completed-item:last-child { border-bottom: none; }
.election-comp-info { flex: 1; min-width: 0; }
.election-comp-country { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); }
.election-comp-meta { font-size: 10px; color: var(--text-muted, #64748b); }


/* ===== GLOBAL SEARCH MODAL ===== */
#globalSearchModal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

#globalSearchModal.show { display: flex; }

.search-modal-content {
    width: 640px;
    max-width: 90vw;
    max-height: 70vh;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.search-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #334155);
}

.search-header input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary, #e2e8f0);
    font-size: 16px;
    outline: none;
}

.search-header input::placeholder { color: var(--text-muted, #64748b); }
.search-header select {
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border, #334155);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.search-header .search-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}

.search-header .search-close:hover { color: var(--text-primary); }

.search-result-count {
    padding: 6px 16px;
    font-size: 10px;
    color: var(--text-muted, #64748b);
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
}

.search-results-list {
    overflow-y: auto;
    flex: 1;
    padding: 4px 0;
}

.search-result-item {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover { background: rgba(0, 212, 255, 0.05); }
.search-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; padding-top: 2px; }
.search-info { flex: 1; min-width: 0; }
.search-title { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); margin-bottom: 2px; }
.search-desc { font-size: 11px; color: var(--text-secondary, #94a3b8); line-height: 1.3; margin-bottom: 4px; }
.search-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.search-shortcut {
    padding: 8px 16px;
    border-top: 1px solid var(--border, #334155);
    font-size: 10px;
    color: var(--text-muted, #64748b);
    text-align: center;
}

.search-shortcut kbd {
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border, #334155);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
}


/* ===== ALERT RULES ===== */
.alert-rule-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
    transition: background 0.15s;
}

.alert-rule-item:hover { background: rgba(0, 212, 255, 0.03); }
.alert-rule-item:last-child { border-bottom: none; }
.alert-rule-item.inactive { opacity: 0.5; }

.rule-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.rule-info { flex: 1; min-width: 0; }
.rule-name { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); margin-bottom: 2px; }
.rule-meta { display: flex; gap: 6px; }
.rule-actions { display: flex; gap: 4px; }


/* ===== AUDIT LOG ===== */
.audit-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.audit-stat-card {
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.audit-stat-val { font-size: 22px; font-weight: 800; color: var(--accent, #00d4ff); }
.audit-stat-lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted, #64748b); margin-top: 2px; }

.audit-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.2);
    transition: background 0.15s;
}

.audit-item:hover { background: rgba(0, 212, 255, 0.03); }
.audit-item:last-child { border-bottom: none; }
.audit-item.critical { border-left: 2px solid #ef4444; }
.audit-item.warning { border-left: 2px solid #f59e0b; }

.audit-sev { font-size: 12px; flex-shrink: 0; padding-top: 2px; }
.audit-info { flex: 1; min-width: 0; }
.audit-action { font-size: 12px; font-weight: 600; color: var(--text-primary, #e2e8f0); }
.audit-meta { display: flex; gap: 8px; font-size: 10px; color: var(--text-muted, #64748b); }
.audit-time { font-size: 10px; color: var(--text-muted, #64748b); white-space: nowrap; flex-shrink: 0; }

.audit-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.15);
    font-size: 11px;
}

.audit-summary-item:last-child { border-bottom: none; }
.audit-summary-action { color: var(--text-secondary, #94a3b8); }
.audit-summary-count { font-weight: 700; color: var(--accent, #00d4ff); }


/* ===== SEARCH TRIGGER BUTTON ===== */
.search-trigger-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--bg-secondary, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 8px;
    color: var(--text-muted, #64748b);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.search-trigger-btn:hover {
    border-color: var(--accent, #00d4ff);
    color: var(--text-primary, #e2e8f0);
}

.search-trigger-btn kbd {
    background: var(--bg-primary, #0f172a);
    border: 1px solid var(--border, #334155);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    color: var(--text-muted);
}


/* ===== RESPONSIVE v4.2 ===== */
@media (max-width: 1200px) {
    .simulator-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .predictor-stats-row,
    .energy-stats-row,
    .election-stats-row,
    .sim-result-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .search-modal-content {
        max-width: 95vw;
    }
}

@media (max-width: 640px) {
    .commodity-item {
        flex-wrap: wrap;
    }
    .election-header {
        flex-wrap: wrap;
    }
    .sim-var-header {
        flex-wrap: wrap;
    }
}
