/* ============================================================ */
/* RISK DASHBOARD STYLES */
/* ============================================================ */

/* Compact Sidebar Card */
.risk-summary-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 16px;
}

.risk-summary-card .card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.risk-summary-card .card-title span {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.risk-summary-card .period-badge {
    font-size: 11px;
    color: #999;
    background: #2a2a2a;
    padding: 2px 6px;
    border-radius: 4px;
}

.risk-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #222;
}

.risk-metric-row:last-child {
    border-bottom: none;
}

.risk-metric-label {
    color: #999;
    font-size: 12px;
}

.risk-metric-value {
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.risk-metric-value.positive { color: #4ade80; }
.risk-metric-value.negative { color: #f87171; }
.risk-metric-value.warning { color: #fbbf24; }
.risk-metric-value.neutral { color: #fff; }

.risk-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.risk-status-dot.green { background: #4ade80; }
.risk-status-dot.yellow { background: #fbbf24; }
.risk-status-dot.red { background: #f87171; }

.risk-divider {
    height: 1px;
    background: #333;
    margin: 10px 0;
}

.risk-alerts-compact {
    margin-top: 8px;
}

.risk-alert-item {
    font-size: 11px;
    padding: 4px 0;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.risk-alert-item.critical { color: #f87171; }
.risk-alert-item.warning { color: #fbbf24; }
.risk-alert-item.info { color: #60a5fa; }

.open-dashboard-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: rgba(124, 195, 228, 0.1);
    border: 1px solid rgba(124, 195, 228, 0.3);
    border-radius: 8px;
    color: #7CC3E4;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.open-dashboard-btn:hover {
    background: rgba(124, 195, 228, 0.2);
}

/* Full Risk Dashboard Overlay */
/* Risk Dashboard Page (like Market Overview) */
.risk-dashboard-layout {
    display: none;
    height: 100%;
    overflow-y: auto;
    background: #111;
}

.risk-dashboard-container {
    padding: 20px;
    max-width: 1125px;
    margin: 0 auto;
    color: #fff;
}

/* Dashboard Header */
.rd-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 2px solid #333;
    margin-bottom: 24px;
}

.rd-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #caa999;
}

.rd-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rd-period-selector {
    display: flex;
    gap: 4px;
}

.rd-period-btn {
    padding: 6px 12px;
    background: transparent;
    border: 1px solid #444;
    color: #999;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.rd-period-btn.active {
    background: rgba(124, 195, 228, 0.2);
    border-color: #7CC3E4;
    color: #7CC3E4;
}

.rd-close-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #444;
    color: #999;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.rd-close-btn:hover {
    border-color: #666;
    color: #fff;
}

/* Summary Bar */
.rd-summary-bar {
    display: flex;
    gap: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.rd-summary-item {
    flex: 1;
    text-align: center;
}

.rd-summary-value {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.rd-summary-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
}

/* Dashboard Grid */
.rd-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.rd-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

/* Dashboard Card */
.rd-card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
}

.rd-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #caa999;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rd-card-subtitle {
    font-size: 11px;
    color: #666;
    font-weight: normal;
    margin-left: 8px;
}

/* Metric Rows */
.rd-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.rd-metric-row:last-child {
    border-bottom: none;
}

.rd-metric-label {
    color: #999;
    font-size: 13px;
}

.rd-metric-value {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rd-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.rd-status-dot.green { background: #4ade80; }
.rd-status-dot.lightgreen { background: #86efac; }
.rd-status-dot.yellow { background: #fbbf24; }
.rd-status-dot.orange { background: #fb923c; }
.rd-status-dot.red { background: #f87171; }

/* Stress Test Card */
.rd-stress-big {
    font-size: 36px;
    font-weight: 700;
    color: #f87171;
    text-align: center;
    margin-bottom: 4px;
}

.rd-stress-sub {
    font-size: 14px;
    color: #999;
    text-align: center;
    margin-bottom: 16px;
}

/* Progress Bars */
.rd-progress-row {
    margin-bottom: 12px;
}

.rd-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.rd-progress-label {
    font-size: 12px;
    color: #999;
}

.rd-progress-value {
    font-size: 12px;
    font-weight: 600;
}

.rd-progress-bar {
    height: 8px;
    background: #2a2a2a;
    border-radius: 4px;
    overflow: hidden;
}

.rd-progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.rd-progress-fill.blue { background: #3b82f6; }
.rd-progress-fill.green { background: #4ade80; }
.rd-progress-fill.yellow { background: #fbbf24; }
.rd-progress-fill.red { background: #f87171; }

/* Correlation Items */
.rd-corr-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

.rd-corr-value {
    font-weight: 600;
    margin-left: auto;
}

.rd-cluster-item {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}

.rd-cluster-tickers {
    font-weight: 600;
    color: #f87171;
    margin-bottom: 4px;
}

.rd-cluster-risk {
    font-size: 11px;
    color: #999;
}

.rd-diversifier {
    color: #4ade80;
}

/* Alerts Section */
.rd-alerts {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.rd-alert-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.rd-alert-row:last-child {
    margin-bottom: 0;
}

.rd-alert-row.critical {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.rd-alert-row.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.rd-alert-row.info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.rd-alert-icon {
    font-size: 16px;
}

.rd-alert-text {
    font-size: 13px;
    line-height: 1.4;
}

/* Deep Analysis Button */
.rd-deep-analysis-btn {
    width: 100%;
    padding: 16px;
    background: rgba(124, 195, 228, 0.1);
    border: 1px solid rgba(124, 195, 228, 0.3);
    border-radius: 12px;
    color: #7CC3E4;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.rd-deep-analysis-btn:hover {
    background: rgba(124, 195, 228, 0.2);
}

/* Loading State */
.rd-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    color: #999;
}

.rd-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: #7CC3E4;
    border-radius: 50%;
    animation: rd-spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes rd-spin {
    to { transform: rotate(360deg); }
}

/* Risk Dashboard Help Tooltips (click-based) */
.rd-help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 9px;
    background: #333;
    border-radius: 50%;
    color: #888;
    margin-left: 4px;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    flex-shrink: 0;
    user-select: none;
}
.rd-help-icon:hover { background: #555; }
.rd-help-icon.active { background: #caa999; color: #111; }
.rd-help-tooltip {
    display: none;
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 12px;
    color: #ddd;
    line-height: 1.5;
    width: 260px;
    z-index: 10000;
    text-align: left;
    box-shadow: 0 4px 20px rgba(0,0,0,0.6);
    font-weight: normal;
    text-transform: none;
    letter-spacing: normal;
}
.rd-help-tooltip.show { display: block; }
.rd-help-tooltip strong { color: #caa999; }
.rd-help-tooltip .tooltip-formula {
    background: #252525;
    padding: 6px 8px;
    border-radius: 4px;
    margin: 6px 0;
    font-family: monospace;
    font-size: 11px;
}
.rd-help-tooltip .tooltip-scale {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #333;
}
.rd-help-tooltip .scale-good { color: #4ade80; }
.rd-help-tooltip .scale-ok { color: #fbbf24; }
.rd-help-tooltip .scale-bad { color: #f87171; }
/* Arrow pointing up */
.rd-help-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #444;
}
.rd-help-tooltip::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid #1a1a1a;
}

/* Responsive */
@media (max-width: 900px) {
    .rd-grid {
        grid-template-columns: 1fr;
    }
    .rd-grid-2 {
        grid-template-columns: 1fr;
    }
    .rd-summary-bar {
        flex-wrap: wrap;
    }
    .rd-summary-item {
        flex: 0 0 45%;
    }
}
