/* Import modern fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&display=swap');

/* Custom properties for RDI-based color theming */
:root {
    /* Normal Level (RDI < 5) - Green tones */
    --normal-gradient: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --normal-light: linear-gradient(135deg, #a7f3d0 0%, #6ee7b7 100%);
    
    /* Mild Level (RDI 5-15) - Yellow/Orange tones */
    --mild-gradient: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    --mild-light: linear-gradient(135deg, #fde68a 0%, #fed7aa 100%);
    
    /* Moderate Level (RDI 15-30) - Orange/Red tones */
    --moderate-gradient: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
    --moderate-light: linear-gradient(135deg, #fed7aa 0%, #fdba74 100%);
    
    /* Severe Level (RDI >= 30) - Red tones */
    --severe-gradient: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    --severe-light: linear-gradient(135deg, #fca5a5 0%, #f87171 100%);
    
    /* Default primary colors - can be overridden based on RDI level */
    --primary-gradient: var(--normal-gradient);
    --secondary-gradient: var(--mild-gradient);
    --success-gradient: var(--normal-gradient);
    --warning-gradient: var(--mild-gradient);
    --danger-gradient: var(--severe-gradient);
    
    /* Additional gradients for variety */
    --emerald-gradient: linear-gradient(135deg, #059669 0%, #10b981 100%);
    --sunset-gradient: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
    --ocean-gradient: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 100%);
    
    /* Glass effects */
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-light: 0 8px 32px rgba(31, 38, 135, 0.37);
    --shadow-heavy: 0 20px 60px rgba(0, 0, 0, 0.15);
    --border-radius: 20px;
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* RDI Level-specific color classes */
.rdi-normal {
    --primary-gradient: var(--normal-gradient);
    --accent-color: #10b981;
    --text-color: #065f46;
    --bg-tint: rgba(16, 185, 129, 0.1);
}

.rdi-mild {
    --primary-gradient: var(--mild-gradient);
    --accent-color: #f59e0b;
    --text-color: #92400e;
    --bg-tint: rgba(245, 158, 11, 0.1);
}

.rdi-moderate {
    --primary-gradient: var(--moderate-gradient);
    --accent-color: #ea580c;
    --text-color: #9a3412;
    --bg-tint: rgba(234, 88, 12, 0.1);
}

.rdi-severe {
    --primary-gradient: var(--severe-gradient);
    --accent-color: #dc2626;
    --text-color: #991b1b;
    --bg-tint: rgba(220, 38, 38, 0.1);
}

/* Base styling with animated background */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    background: linear-gradient(-45deg, #10b981, #f59e0b, #ea580c, #dc2626);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: #2d3748;
    line-height: 1.6;
    overflow-x: hidden;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Glassmorphism RDI card with floating animation */
.rdi {
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.1));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius);
    color: #fff;
    text-align: center;
    box-shadow: var(--shadow-heavy);
    position: relative;
    overflow: hidden;
    animation: float 6s ease-in-out infinite;
    transition: var(--transition);
}

.rdi::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.8s;
}

.rdi:hover::before {
    left: 100%;
}

.rdi:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.2);
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-15px); }
}

.rdi h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 15px;
    color: #1a202c;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.5px;
}

.rdi p {
    font-size: 20px;
    margin: 0;
    line-height: 1.7;
    color: rgba(7, 7, 7, 0.95);
    font-weight: 500;
}

.rdi span {
    font-weight: 800;
    color: var(--accent-color, #dc2626);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    display: inline-block;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* RDI level status indicator */
.rdi-status {
    padding: 15px 25px;
    margin: 20px 0;
    border-radius: 15px;
    font-weight: 600;
    font-size: 18px;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid transparent;
    transition: var(--transition);
}

.rdi-status.normal {
    background: var(--normal-light);
    color: #065f46;
    border-color: #10b981;
}

.rdi-status.mild {
    background: var(--mild-light);
    color: #92400e;
    border-color: #f59e0b;
}

.rdi-status.moderate {
    background: var(--moderate-light);
    color: #9a3412;
    border-color: #ea580c;
}

.rdi-status.severe {
    background: var(--severe-light);
    color: #991b1b;
    border-color: #dc2626;
    animation: urgentPulse 2s ease-in-out infinite;
}

@keyframes urgentPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    50% { 
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(220, 38, 38, 0);
    }
}

/* Main container with advanced styling */
.container {
    max-width: 1500px;
    margin: 20px auto;
    padding: 40px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-heavy);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-gradient);
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Main title with gradient text */
h1 {
    text-align: center;
    font-family: 'Poppins', sans-serif;
    font-size: 42px;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 40px;
    letter-spacing: -1px;
    position: relative;
    animation: slideInDown 1s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Enhanced stats section */
.stats {
    margin: 30px 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.6));
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 30px;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: var(--shadow-light);
    position: relative;
    transition: var(--transition);
    animation: slideInUp 1s ease-out 0.3s both;
}

.stats:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats h2 {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    background: var(--ocean-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 24px;
    margin-bottom: 20px;
}

.stats p {
    font-size: 17px;
    line-height: 1.7;
    color: #4a5568;
    margin-bottom: 15px;
}

.stats p span {
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Canvas with modern styling */
canvas {
    margin-top: 30px;
    max-width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    animation: fadeIn 1s ease-out 0.6s both;
}

canvas:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-heavy);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Beautiful time filter */
.time-filter {
    margin-bottom: 30px;
    text-align: center;
    padding: 25px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    position: relative;
    overflow: hidden;
    animation: slideInLeft 1s ease-out 0.4s both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.time-filter::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--sunset-gradient);
}

.time-filter label {
    font-family: 'Poppins', sans-serif;
    font-size: 18px;
    font-weight: 600;
    margin-right: 15px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.time-filter select {
    padding: 15px 20px;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    border-radius: 12px;
    border: 2px solid transparent;
    background: linear-gradient(white, white) padding-box,
                var(--primary-gradient) border-box;
    color: #4a5568;
    box-shadow: var(--shadow-light);
    transition: var(--transition);
    cursor: pointer;
    min-width: 200px;
}

.time-filter select:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(var(--accent-color), 0.25);
    transform: translateY(-2px);
}

.time-filter select:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
}

/* Selected date with premium styling */
.selected-date {
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.8));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-light);
    font-size: 19px;
    position: relative;
    animation: slideInRight 1s ease-out 0.5s both;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.selected-date::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.selected-date h2 {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    font-size: 22px;
    font-weight: 600;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    /* -webkit-text-fill-color: transparent; */
    background-clip: text;
}

/* Advanced responsive design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 25px;
        margin: 10px auto;
    }

    .rdi, .stats, .time-filter, .selected-date {
        padding: 20px;
        margin-bottom: 20px;
    }

    .rdi h2, .stats h2, .selected-date h2 {
        font-size: 22px;
    }

    .rdi p, .stats p {
        font-size: 16px;
    }

    .time-filter label, .time-filter select, .selected-date {
        font-size: 16px;
    }

    h1 {
        font-size: 32px;
    }

    canvas {
        max-width: 100%;
        height: 350px;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
        margin: 5px auto;
        border-radius: 15px;
    }

    .rdi, .stats, .time-filter, .selected-date {
        padding: 15px;
        margin-bottom: 15px;
        border-radius: 15px;
    }

    .rdi h2, .stats h2, .selected-date h2 {
        font-size: 20px;
    }

    .rdi p, .stats p {
        font-size: 14px;
    }

    .time-filter label, .selected-date {
        font-size: 14px;
    }

    .time-filter select {
        font-size: 14px;
        padding: 12px 15px;
        min-width: 150px;
    }

    h1 {
        font-size: 28px;
    }

    canvas {
        height: 250px;
        border-radius: 10px;
    }

    .chartjs-render-monitor {
        font-size: 10px !important;
    }
}

/* Additional premium touches */
@media (prefers-reduced-motion: no-preference) {
    * {
        scroll-behavior: smooth;
    }
}

/* Focus states for accessibility */
*:focus-visible {
    outline: 2px solid var(--accent-color, #10b981);
    outline-offset: 2px;
}

/* Selection styling */
::selection {
    background: rgba(var(--accent-color), 0.3);
    color: #1a202c;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-gradient);
}