/* Design System */
:root {
    --primary: #0f172a;
    --accent: #0ea5e9;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --surface: #ffffff;
    --background: #f8fafc;
    --muted: #64748b;
    --border: #e2e8f0;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Typography */
.font-display {
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: -0.02em;
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

@keyframes pulse-slow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

@keyframes fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes count-up {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

.animate-pulse-slow {
    animation: pulse-slow 4s ease-in-out infinite;
}

.fade-in {
    animation: fade-in 0.5s ease-out;
}

.slide-up {
    animation: slide-up 0.4s ease-out;
}

/* Glass Effects */
.glass {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted);
}

/* Form Elements */
input, select {
    transition: all 0.2s ease;
}

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

/* Buttons */
button {
    transition: all 0.2s ease;
    cursor: pointer;
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Cards & Surfaces */
.surface {
    background: var(--surface);
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border);
}

.surface:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
}

/* Status Indicators */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.status-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Progress Bars */
.progress-bar {
    height: 0.5rem;
    background: var(--border);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.3s ease;
    background: linear-gradient(90deg, var(--accent), var(--primary));
}

/* SHAP Waterfall Chart Styles */
.shap-bar {
    height: 1.5rem;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
    position: relative;
}

.shap-positive {
    background: linear-gradient(90deg, var(--success), #34d399);
}

.shap-negative {
    background: linear-gradient(90deg, #f87171, var(--danger));
}

.shap-label {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Confusion Matrix */
.confusion-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
    transition: transform 0.2s ease;
}

.confusion-cell:hover {
    transform: scale(1.05);
}

/* Intervention Cards */
.intervention-card {
    border-left: 4px solid;
    padding: 1rem;
    border-radius: 0 0.75rem 0.75rem 0;
    background: white;
    transition: all 0.2s ease;
}

.intervention-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.intervention-urgent {
    border-color: var(--danger);
}

.intervention-moderate {
    border-color: var(--warning);
}

.intervention-low {
    border-color: var(--accent);
}

/* Range Slider */
input[type="range"] {
    -webkit-appearance: none;
    height: 0.5rem;
    border-radius: 9999px;
    background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Table Styles */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 0.875rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s ease;
}

.data-table tr:hover td {
    background: rgba(14, 165, 233, 0.03);
}

/* Risk Score Visualization */
.risk-donut {
    position: relative;
    width: 120px;
    height: 120px;
}

.risk-donut svg {
    transform: rotate(-90deg);
}

.risk-donut-bg {
    fill: none;
    stroke: var(--border);
    stroke-width: 8;
}

.risk-donut-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease;
}

.risk-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Tooltip */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    border-radius: 0.5rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s ease;
}

.tooltip:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-0.5rem);
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .surface {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .font-display {
        font-size: 1.875rem;
    }
    
    .animate-float {
        animation: none;
    }
}

/* Dark Mode (prepared) */
.dark-mode {
    --primary: #f8fafc;
    --background: #0f172a;
    --surface: #1e293b;
    --border: #334155;
    --muted: #94a3b8;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Selection */
::selection {
    background: rgba(14, 165, 233, 0.2);
    color: var(--primary);
}