/* ===== CyberGuard AI — Dashboard — Red Theme ===== */

:root {
    --bg-primary:    #110a0c;
    --bg-sidebar:    #0e0809;
    --bg-card:       #1c1014;
    --bg-card-hover: #261620;
    --bg-input:      #150c0f;
    --border:        #2e1a22;
    --text-primary:  #f2e8eb;
    --text-secondary:#a0808c;
    --text-dim:      #6b4a55;
    --accent:        #ff2d55;
    --accent-2:      #ff6b35;
    --accent-glow:   rgba(255, 45, 85, 0.12);
    --red:           #ff2d55;
    --orange:        #ff6b35;
    --yellow:        #ffd600;
    --green:         #00e676;
    --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono:          'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

* { box-sizing: border-box; margin: 0; }

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

::selection { background: var(--accent); color: #fff; }
.text-accent { color: var(--accent) !important; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand a {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.15rem;
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 16px rgba(255, 45, 85, 0.2);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-dim);
    padding: 8px 12px 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s;
    position: relative;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: rgba(255, 45, 85, 0.06);
}

.sidebar-link.active {
    color: var(--accent);
    background: var(--accent-glow);
}

.sidebar-link i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
}

/* ===== LANG TOGGLE ===== */
.lang-toggle {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.lang-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lang-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--accent-glow);
    border-color: rgba(255, 45, 85, 0.3);
    color: var(--accent);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(17, 10, 12, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 12px;
}

.topbar-title {
    font-weight: 700;
    font-size: 1.1rem;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}

.status-dot.online { background: var(--green); box-shadow: 0 0 8px rgba(0, 230, 118, 0.4); }

.topbar-time {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    font-family: var(--mono);
}

/* Page content */
.page-content {
    display: none;
    padding: 28px;
    animation: fadeIn 0.3s ease;
}

.page-content.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== METRIC CARDS ===== */
.metric-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.metric-card:hover {
    border-color: rgba(255, 45, 85, 0.15);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 45, 85, 0.06);
}

.metric-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
    background: var(--accent-glow);
    color: var(--accent);
}

.metric-icon.blue { background: rgba(255, 45, 85, 0.12); color: var(--accent); }
.metric-icon.red { background: rgba(255, 107, 53, 0.12); color: var(--orange); }
.metric-icon.green { background: rgba(0, 230, 118, 0.12); color: var(--green); }
.metric-icon.orange { background: rgba(255, 140, 66, 0.12); color: var(--orange); }

.metric-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

/* Risk colors */
.risk-critique { color: var(--red) !important; }
.risk-eleve { color: var(--orange) !important; }
.risk-moyen { color: var(--yellow) !important; }
.risk-faible { color: var(--green) !important; }
.risk-normal { color: var(--green) !important; }

.metric-risk.critique { border-color: rgba(255, 45, 85, 0.3); }
.metric-risk.critique .metric-icon { background: rgba(255, 45, 85, 0.12); color: var(--red); }

.metric-risk.eleve { border-color: rgba(255, 107, 53, 0.3); }
.metric-risk.eleve .metric-icon { background: rgba(255, 107, 53, 0.12); color: var(--orange); }

.metric-risk.moyen { border-color: rgba(255, 215, 0, 0.2); }
.metric-risk.moyen .metric-icon { background: rgba(255, 215, 0, 0.12); color: var(--yellow); }

.metric-risk.normal { border-color: rgba(0, 230, 118, 0.2); }
.metric-risk.normal .metric-icon { background: rgba(0, 230, 118, 0.12); color: var(--green); }

/* ===== STAT CARDS ===== */
.stat-card {
    padding: 18px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.3s;
}

.stat-card:hover {
    border-color: rgba(255, 45, 85, 0.12);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
}

.stat-bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    margin-top: 10px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--green), var(--yellow), var(--accent));
    transition: width 0.6s ease;
}

/* ===== CHART CARDS ===== */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: all 0.3s;
}

.chart-card:hover {
    border-color: rgba(255, 45, 85, 0.1);
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 0;
}

.chart-header h6 {
    font-weight: 700;
    font-size: 0.9rem;
    margin: 0;
}

.chart-container { height: 300px; }
.chart-container-lg { height: 350px; }

/* ===== ALERT LIST ===== */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.alert-item:last-child { border-bottom: none; }
.alert-item:hover { background: rgba(255, 45, 85, 0.03); }

.alert-risk-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.alert-risk-dot.critique { background: var(--red); box-shadow: 0 0 8px rgba(255, 45, 85, 0.4); }
.alert-risk-dot.eleve { background: var(--orange); box-shadow: 0 0 8px rgba(255, 107, 53, 0.3); }
.alert-risk-dot.moyen { background: var(--yellow); }
.alert-risk-dot.faible { background: var(--green); }

.alert-info { flex: 1; min-width: 0; }

.alert-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.alert-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.alert-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

.alert-score {
    font-weight: 700;
    font-size: 0.85rem;
    text-align: right;
    flex-shrink: 0;
    font-family: var(--mono);
}

/* ===== FILTER BAR ===== */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px 24px;
}

.form-select, .form-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 0.9rem;
}

.form-select:focus, .form-control:focus {
    background: var(--bg-input);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ===== ALERTS TABLE ===== */
.table {
    color: var(--text-primary);
    margin-bottom: 0;
}

.table thead th {
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
    font-weight: 600;
    padding: 14px 16px;
    background: transparent;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(46, 26, 34, 0.5);
    vertical-align: middle;
    font-size: 0.88rem;
}

.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: rgba(255, 45, 85, 0.03); }

.table tbody tr.row-critique { border-left: 3px solid var(--red); }
.table tbody tr.row-eleve { border-left: 3px solid var(--orange); }
.table tbody tr.row-moyen { border-left: 3px solid var(--yellow); }
.table tbody tr.row-faible { border-left: 3px solid var(--green); }

/* Badges */
.badge-risk {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.3px;
}

.badge-critique { background: rgba(255, 45, 85, 0.15); color: var(--red); }
.badge-eleve { background: rgba(255, 107, 53, 0.15); color: var(--orange); }
.badge-moyen { background: rgba(255, 215, 0, 0.15); color: var(--yellow); }
.badge-faible { background: rgba(0, 230, 118, 0.15); color: var(--green); }

/* ===== SCAN PAGE ===== */
.scan-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    text-align: center;
}

.scan-icon {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--accent-glow);
    border: 1px solid rgba(255, 45, 85, 0.2);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
}

.scan-card h3 { font-weight: 700; }

.btn-accent {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    color: #fff;
    font-weight: 600;
    border-radius: 10px;
    transition: all 0.3s;
    box-shadow: 0 0 20px rgba(255, 45, 85, 0.15);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 45, 85, 0.25);
    color: #fff;
}

.progress {
    height: 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

.progress-bar {
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

/* Form range custom */
.form-range::-webkit-slider-runnable-track {
    background: var(--border);
    border-radius: 4px;
}

.form-range::-webkit-slider-thumb {
    background: var(--accent);
    box-shadow: 0 0 8px rgba(255, 45, 85, 0.3);
}

.form-range::-moz-range-track {
    background: var(--border);
}

.form-range::-moz-range-thumb {
    background: var(--accent);
    border: none;
    box-shadow: 0 0 8px rgba(255, 45, 85, 0.3);
}

/* ===== MODAL ===== */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
}

.modal-body { padding: 24px; }

.modal-title { font-weight: 700; font-size: 1rem; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    border: 1px solid rgba(46, 26, 34, 0.3);
}

.detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.detail-value {
    font-weight: 600;
    font-size: 0.9rem;
}

.detail-section {
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    border-left: 3px solid var(--accent);
}

.detail-section h6 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    font-weight: 700;
    margin-bottom: 8px;
}

.detail-section p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0;
}

.detail-raw {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 10px;
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid var(--border);
}

/* ===== BTN OVERRIDES ===== */
.btn-outline-secondary {
    border-color: var(--border);
    color: var(--text-secondary);
}

.btn-outline-secondary:hover {
    background: rgba(255, 45, 85, 0.08);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-outline-danger {
    border-color: rgba(255, 45, 85, 0.3);
    color: var(--accent);
}

.btn-outline-danger:hover {
    background: rgba(255, 45, 85, 0.12);
    border-color: var(--accent);
    color: #fff;
}

.btn-success {
    background: rgba(0, 230, 118, 0.15);
    border: 1px solid rgba(0, 230, 118, 0.3);
    color: var(--green);
}

.btn-success:hover {
    background: rgba(0, 230, 118, 0.25);
    border-color: var(--green);
    color: #fff;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar.open + .main-content + .sidebar-overlay { display: block; }

    .main-content { margin-left: 0; }

    .detail-grid { grid-template-columns: 1fr; }

    .topbar { padding: 12px 16px; }
    .topbar-title { font-size: 0.95rem; }

    .metric-card { padding: 16px 18px; }
    .metric-value { font-size: 1.3rem; }

    .chart-container { height: 260px; }
    .chart-container-lg { height: 300px; }
}

@media (max-width: 768px) {
    .topbar-right {
        gap: 8px;
    }

    .topbar-status span:not(.status-dot) {
        display: none;
    }

    .filter-bar .row > div {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    .page-content { padding: 16px; }
    .topbar { padding: 10px 12px; }
    .scan-card { padding: 28px 20px; }
    .metric-card { flex-direction: column; text-align: center; gap: 10px; padding: 16px; }
    .metric-icon { margin: 0 auto; }
    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 1.2rem; }

    .chart-header { padding: 12px 14px 0; }
    .chart-header h6 { font-size: 0.82rem; }

    .alert-item { padding: 12px 14px; gap: 10px; }
    .alert-meta { font-size: 0.72rem; }

    .table thead th { font-size: 0.65rem; padding: 10px 8px; }
    .table tbody td { font-size: 0.78rem; padding: 8px; }

    .lang-toggle { margin-left: 0; }
}
