/* ==========================================================================
   DataDriftMonitor -- Main Stylesheet
   ========================================================================== */

/* --- CSS Variables -------------------------------------------------------- */
:root {
    --color-bg: #0f1117;
    --color-surface: #1a1d27;
    --color-surface-2: #242736;
    --color-border: #2d3148;
    --color-text: #e4e6f0;
    --color-text-muted: #8b8fa3;
    --color-primary: #6366f1;
    --color-primary-hover: #818cf8;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    --color-none: #6b7280;
    --color-low: #22c55e;
    --color-medium: #f59e0b;
    --color-high: #ef4444;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s ease;
}

/* --- Reset ---------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--color-primary-hover);
}

/* --- Navbar --------------------------------------------------------------- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text);
    font-weight: 700;
    font-size: 1.2rem;
}

.brand-link:hover {
    color: var(--color-primary);
}

.brand-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.navbar-menu {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    color: var(--color-text-muted);
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover, .nav-link.active {
    color: var(--color-text);
    background: var(--color-surface-2);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--color-primary);
    border-radius: 1px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--color-danger);
    color: #fff;
    border-radius: 10px;
    margin-left: 4px;
}

.badge.hidden {
    display: none;
}

/* --- Main Content --------------------------------------------------------- */
.main-content {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 64px - 60px);
}

/* --- Footer --------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: 1rem 2rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
}

/* --- Cards ---------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 0;
}

/* --- Stat Cards ----------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* --- Tables --------------------------------------------------------------- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    background: var(--color-surface-2);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

tr:hover {
    background: var(--color-surface-2);
}

tr:last-child td {
    border-bottom: none;
}

/* --- Buttons -------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--color-success);
    color: #fff;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* --- Forms ---------------------------------------------------------------- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fa3' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* --- Severity Badges ------------------------------------------------------ */
.severity {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.severity-none { background: rgba(107,114,128,0.2); color: var(--color-none); }
.severity-low { background: rgba(34,197,94,0.15); color: var(--color-low); }
.severity-medium { background: rgba(245,158,11,0.15); color: var(--color-medium); }
.severity-high { background: rgba(239,68,68,0.15); color: var(--color-high); }

/* --- Charts --------------------------------------------------------------- */
.chart-container {
    position: relative;
    width: 100%;
    margin: 1rem 0;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 120px;
    padding: 0 4px;
}

.bar-group {
    display: flex;
    gap: 1px;
    flex: 1;
    align-items: flex-end;
    height: 100%;
}

.bar {
    flex: 1;
    min-width: 8px;
    border-radius: 2px 2px 0 0;
    transition: var(--transition);
    position: relative;
}

.bar.ref {
    background: var(--color-primary);
    opacity: 0.6;
}

.bar.cur {
    background: var(--color-warning);
    opacity: 0.8;
}

.bar:hover {
    opacity: 1;
}

.chart-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
    justify-content: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.legend-dot.ref { background: var(--color-primary); }
.legend-dot.cur { background: var(--color-warning); }

/* --- Grid Layout ---------------------------------------------------------- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* --- Alerts List ---------------------------------------------------------- */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    background: var(--color-surface);
    transition: var(--transition);
}

.alert-item:hover {
    border-color: var(--color-primary);
}

.alert-item.acknowledged {
    opacity: 0.5;
}

.alert-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-message {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.alert-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* --- Page Headers --------------------------------------------------------- */
.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

/* --- Loading & Empty States ----------------------------------------------- */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem;
    color: var(--color-text-muted);
    font-size: 1rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* --- Drift Score Gauge ---------------------------------------------------- */
.gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem;
}

.gauge-value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.gauge-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

.gauge-bar {
    width: 100%;
    height: 8px;
    background: var(--color-surface-2);
    border-radius: 4px;
    margin-top: 1rem;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* --- Feature Detail ------------------------------------------------------- */
.feature-card {
    margin-bottom: 1.5rem;
}

.feature-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.feature-name {
    font-weight: 600;
    font-size: 1rem;
}

.feature-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.metric-box {
    background: var(--color-surface-2);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    text-align: center;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* --- Responsive ----------------------------------------------------------- */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .navbar-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .main-content {
        padding: 1rem;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* --- Scrollbar ------------------------------------------------------------ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* --- Utility -------------------------------------------------------------- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--color-text-muted); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.fw-bold { font-weight: 700; }
.mono { font-family: var(--font-mono); }
