/* Ghibli-Inspired Dashboard Styles */
@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@300;400;500;600;700&family=Nunito:wght@300;400;500;600;700&display=swap');

body {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8ff 50%, #fff8e1 100%);
    font-family: 'Nunito', sans-serif;
    min-height: 100vh;
    position: relative;
}

/* Ghibli-style floating elements background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 80%, rgba(139, 195, 74, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(76, 175, 80, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(165, 214, 167, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.navbar {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%) !important;
    box-shadow: 0 4px 20px rgba(76, 175, 80, 0.3);
    border-bottom: 3px solid #8bc34a;
}

.navbar-brand {
    font-family: 'Comfortaa', cursive;
    font-weight: 600;
    font-size: 1.6rem;
    color: white !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Ghibli-Inspired KPI Cards */
.kpi-card {
    border: none;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,255,248,0.8) 100%);
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.15), 
                0 2px 8px rgba(139, 195, 74, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(165, 214, 167, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    height: 100%;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 195, 74, 0.05) 0%, transparent 70%);
    transition: all 0.6s ease;
    transform: scale(0);
}

.kpi-card:hover::before {
    transform: scale(1);
}

.kpi-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 16px 48px rgba(76, 175, 80, 0.25), 
                0 8px 16px rgba(139, 195, 74, 0.2);
    border-color: rgba(139, 195, 74, 0.5);
}

.kpi-icon {
    font-size: 2.8rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 2px 4px rgba(76, 175, 80, 0.3));
    position: relative;
    z-index: 2;
}

.kpi-card .card-title {
    font-family: 'Comfortaa', cursive;
    font-size: 2.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #2e7d32;
    text-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
    position: relative;
    z-index: 2;
}

.kpi-card .card-text {
    color: #558b2f;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
    font-family: 'Nunito', sans-serif;
    position: relative;
    z-index: 2;
}

/* Ghibli-Inspired Chart Cards */
.chart-card {
    border: none;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,255,248,0.9) 100%);
    box-shadow: 0 12px 40px rgba(76, 175, 80, 0.15), 
                0 4px 12px rgba(139, 195, 74, 0.1);
    backdrop-filter: blur(15px);
    border: 2px solid rgba(165, 214, 167, 0.2);
    margin-bottom: 1.5rem;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #4caf50 0%, #8bc34a 50%, #cddc39 100%);
}

.chart-card .card-header {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 50%, #388e3c 100%);
    color: white;
    border-radius: 24px 24px 0 0 !important;
    border: none;
    padding: 1.2rem 1.8rem;
    position: relative;
    overflow: hidden;
}

.chart-card .card-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="1.5" fill="rgba(255,255,255,0.08)"/><circle cx="40" cy="70" r="1" fill="rgba(255,255,255,0.06)"/></svg>');
    pointer-events: none;
}

.chart-card .card-header .card-title {
    color: white;
    margin-bottom: 0;
    font-family: 'Comfortaa', cursive;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    z-index: 2;
}

.chart-card .card-header small {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    position: relative;
    z-index: 2;
}

.chart-card .card-body {
    padding: 2rem;
    background: rgba(255,255,255,0.6);
}

/* Filter Controls */
.form-select {
    border-radius: 8px;
    border: 2px solid #e9ecef;
    transition: border-color 0.3s ease;
}

.form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

/* Loading and Error States */
#loading {
    margin-top: 100px;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .kpi-card .card-title {
        font-size: 2rem;
    }
    
    .kpi-icon {
        font-size: 2rem;
    }
    
    .chart-card {
        margin-bottom: 1rem;
    }
    
    .chart-card .card-body {
        padding: 1rem;
    }
}

/* Custom Plotly Styling */
.plotly .modebar {
    display: none !important;
}

/* Animation for dashboard appearance */
#dashboard {
    animation: fadeIn 0.5s ease-in;
}

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

/* Card hover effects */
.card {
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

/* Smooth transitions for chart containers */
.chart-container {
    transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    opacity: 1;
    transform: scale(1) translateY(0);
}

.chart-container.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
    pointer-events: none;
}

.chart-container.focused {
    transform: scale(1.03) translateY(-12px);
    box-shadow: 0 24px 48px rgba(76, 175, 80, 0.25), 
                0 8px 24px rgba(139, 195, 74, 0.2);
    z-index: 10;
    position: relative;
    border: 3px solid rgba(139, 195, 74, 0.4);
}

/* Focused chart gets special styling */
.focused-mode .chart-container:not(.focused) {
    opacity: 0.3;
    transform: scale(0.95) translateY(10px);
}

/* Smooth layout transitions */
.charts-grid {
    transition: all 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.charts-grid.single-focus {
    justify-content: center;
    align-items: center;
}

.charts-grid.single-focus .chart-container.focused {
    max-width: 800px;
    margin: 0 auto;
}

/* Ghibli-Enhanced filter transitions */
.form-select {
    transition: all 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 12px;
    border: 2px solid rgba(139, 195, 74, 0.3);
    background: linear-gradient(135deg, rgba(255,255,255,0.9) 0%, rgba(248,255,248,0.8) 100%);
    backdrop-filter: blur(8px);
    color: #2e7d32;
    font-weight: 500;
}

.form-select:focus {
    transform: scale(1.02);
    border-color: #66bb6a;
    box-shadow: 0 0 0 0.25rem rgba(76, 175, 80, 0.2), 
                0 4px 12px rgba(139, 195, 74, 0.3);
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(248,255,248,0.9) 100%);
}

.form-label {
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 0.8rem;
    font-family: 'Comfortaa', cursive;
    font-size: 0.95rem;
}

/* Ghibli-style pulse animation for active filters */
@keyframes ghibliPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(139, 195, 74, 0.1);
        transform: scale(1.01);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
        transform: scale(1);
    }
}

.filter-active {
    animation: ghibliPulse 2.5s infinite;
    border-color: #4caf50;
    background: linear-gradient(135deg, rgba(165, 214, 167, 0.2) 0%, rgba(200, 230, 201, 0.3) 100%);
}

/* Interactive Elements */
.insight-content {
    font-family: 'Nunito', sans-serif;
    color: #2e7d32;
}

.magical-loading {
    animation: fadeInUp 0.6s ease-out;
}

.floating-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.dot {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #66bb6a, #4caf50);
    border-radius: 50%;
    animation: float 2s ease-in-out infinite;
}

.dot:nth-child(2) {
    animation-delay: 0.3s;
}

.dot:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    50% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

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

/* Enhanced chart hover effects */
.chart-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 48px rgba(76, 175, 80, 0.2);
}

/* Interactive cursor for clickable elements */
[data-clickable="true"] {
    cursor: pointer;
}

/* Full Screen Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
        rgba(139, 195, 74, 0.95) 0%, 
        rgba(102, 187, 106, 0.95) 50%, 
        rgba(76, 175, 80, 0.95) 100%);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: all 0.8s cubic-bezier(0.4, 0.0, 0.2, 1);
}

.loading-screen.fade-out {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.loading-content {
    text-align: center;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    animation: contentGlow 3s ease-in-out infinite alternate;
    max-width: 400px;
    position: relative;
    overflow: hidden;
}

@keyframes contentGlow {
    from { box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2), 0 0 30px rgba(255, 255, 255, 0.1); }
    to { box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 0 0 50px rgba(255, 255, 255, 0.2); }
}

.loading-logo {
    font-size: 4rem;
    color: white;
    margin-bottom: 1.5rem;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: logoSpin 6s linear infinite;
}

@keyframes logoSpin {
    from { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(90deg) scale(1.1); }
    50% { transform: rotate(180deg) scale(1); }
    75% { transform: rotate(270deg) scale(1.1); }
    to { transform: rotate(360deg) scale(1); }
}

.loading-title {
    font-family: 'Comfortaa', cursive;
    font-size: 1.8rem;
    color: white;
    margin-bottom: 2rem;
    font-weight: 600;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    animation: titleBreathe 2s ease-in-out infinite alternate;
}

@keyframes titleBreathe {
    from { opacity: 0.9; transform: scale(1); }
    to { opacity: 1; transform: scale(1.02); }
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    margin-top: 2rem;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.8) 0%, 
        rgba(255, 255, 255, 1) 50%, 
        rgba(255, 255, 255, 0.8) 100%);
    border-radius: 10px;
    animation: progressLoad 3s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

@keyframes progressLoad {
    0% { width: 0%; transform: translateX(-100%); }
    50% { width: 70%; transform: translateX(0%); }
    100% { width: 100%; transform: translateX(0%); }
}

.loading-particles {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: particleFloat 8s infinite linear;
}

.particle:nth-child(1) { 
    left: 10%; 
    animation-delay: 0s;
    animation-duration: 6s; 
}
.particle:nth-child(2) { 
    left: 20%; 
    animation-delay: 1s;
    animation-duration: 8s; 
}
.particle:nth-child(3) { 
    left: 70%; 
    animation-delay: 2s;
    animation-duration: 7s; 
}
.particle:nth-child(4) { 
    left: 80%; 
    animation-delay: 3s;
    animation-duration: 9s; 
}
.particle:nth-child(5) { 
    left: 90%; 
    animation-delay: 1.5s;
    animation-duration: 5s; 
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.7;
        transform: scale(1);
    }
    90% {
        opacity: 0.7;
        transform: scale(1);
    }
    100% {
        transform: translateY(-100vh) scale(0);
        opacity: 0;
    }
}

/* Loading text styling */
.loading-text {
    font-family: 'Comfortaa', cursive;
    color: white;
    font-weight: 500;
    font-size: 1.1rem;
    margin-top: 1rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    animation: textShimmer 2s ease-in-out infinite alternate;
}

@keyframes textShimmer {
    from { opacity: 0.8; }
    to { opacity: 1; }
}

/* Override for loading text in dashboard data refresh */
#loading .loading-text {
    color: #4caf50;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Floating dots for loading screen */
.floating-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.floating-dots .dot {
    width: 12px;
    height: 12px;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 1));
    border-radius: 50%;
    animation: dotFloat 2s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(255, 255, 255, 0.3);
}

#loading .floating-dots .dot {
    background: linear-gradient(45deg, #66bb6a, #4caf50);
    box-shadow: 0 2px 8px rgba(102, 187, 106, 0.3);
}

.floating-dots .dot:nth-child(1) { animation-delay: 0s; }
.floating-dots .dot:nth-child(2) { animation-delay: 0.33s; }
.floating-dots .dot:nth-child(3) { animation-delay: 0.66s; }

@keyframes dotFloat {
    0%, 100% { transform: translateY(0px) scale(1); }
    50% { transform: translateY(-15px) scale(1.1); }
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(139, 195, 74, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #66bb6a, #4caf50);
    border-radius: 4px;
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #4caf50, #388e3c);
}
