:root {
    /* Mapped from GeneratePress, with exact hex fallbacks for stability */
    --ps-dark-purple: var(--global-color-8, #5e2ca5); 
    --ps-light-purple: var(--global-color-9, #ebdcf9);
    
    /* Semantic Colors */
    --ps-bg-light: #f9f9fb;
    --ps-white: #ffffff;
    --ps-text-main: #1e1e2d;
    --ps-text-muted: #646473;
    --ps-safe-green: #10b981;
    --ps-warn-orange: #f59e0b;
    --ps-alert-red: #ef4444;
    
    /* Layout Variables */
    --ps-radius: 16px;
    --ps-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.ps-homepage-wrapper {
    color: var(--ps-text-main);
    background-color: var(--ps-bg-light);
    border-radius: 24px;
    padding: 0;
}

/* =========================================
   Modern Hero Section
   ========================================= */
.ps-hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px;
    background: var(--ps-light-purple);
    border-radius: 24px;
    margin-bottom: 25px;
    box-shadow: 0 10px 40px rgba(94, 44, 165, 0.15);
}

.ps-hero-content {
    flex: 1;
    padding-right: 50px;
}

.ps-hero-subtitle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(94, 44, 165, 0.1);
    color: var(--ps-dark-purple);
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.ps-live-indicator {
    width: 10px;
    height: 10px;
    background-color: var(--ps-alert-red);
    border-radius: 50%;
    display: inline-block;
    animation: ps-pulse 2s infinite;
}

@keyframes ps-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.ps-hero-content h1 {
    color: var(--global-color-8);
    font-size: 48px;
    line-height: 1.2;
    margin-bottom: 20px;
    font-weight: 900;
    letter-spacing: -1px;
}

.ps-hero-content p {
    color: var(--ps-text-muted);
    font-size: 1.15rem;
    line-height: 1.6;
    margin-bottom: 30px;
}

/* Hero Search Bar */
.ps-hero-search {
    margin-top: 30px;
    max-width: 500px;
}

.ps-search-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--ps-white);
    border-radius: 50px;
    padding: 6px 8px;
    box-shadow: 0 8px 25px rgba(94, 44, 165, 0.15);
    border: 2px solid transparent;
    transition: var(--ps-transition);
}

.ps-search-input-wrapper:focus-within {
    border-color: var(--ps-light-purple);
    box-shadow: 0 8px 30px rgba(94, 44, 165, 0.25);
}

.ps-search-input-wrapper input {
    flex: 1;
    border: none !important;
    background: transparent;
    font-size: 1.05rem;
    color: var(--ps-text-main);
    padding: 10px 20px;
    outline: none !important;
    box-shadow: none !important;
}

.ps-search-input-wrapper input::placeholder {
    color: #a0a0a0;
}

.ps-btn-search {
    background-color: var(--ps-dark-purple);
    color: var(--ps-white);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--ps-transition);
}

.ps-btn-search:hover {
    background-color: black;
}

/* Quick Access Chips */
.ps-quick-chips {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 12px;
    overflow-x: auto;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
.ps-quick-chips::-webkit-scrollbar {
    display: none; /* Chrome, Safari and Opera */
}

.ps-chip-label {
    font-size: 0.8rem;
    color: var(--ps-text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.ps-chip {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(94, 44, 165, 0.15);
    color: var(--ps-dark-purple);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: var(--ps-transition);
}

.ps-chip:hover {
    background: var(--ps-dark-purple);
    color: var(--ps-white);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(94, 44, 165, 0.2);
}

.ps-hero-map {
    flex: 0.8;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ps-map-graphic {
    position: relative;
    color: var(--ps-light-purple);
    width: 300px;
    height: 300px;
    filter: drop-shadow(0 20px 30px rgba(94, 44, 165, 0.15));
}

.ps-map-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--ps-dark-purple);
    font-weight: bold;
    font-size: 1.5rem;
    letter-spacing: 1px;
}

/* =========================================
   Districts Dashboard Grid
   ========================================= */
.ps-districts-container {
    padding: 20px 0;
}

.ps-section-header {
    background-color: var(--ps-light-purple);
    padding: 25px;
    border-radius: 24px;
    margin: 15px 0;
    box-shadow: 0 10px 40px rgba(94, 44, 165, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
    text-align: center;
}

.ps-section-header h1 {
    font-size: 36px;
    color: var(--ps-dark-purple);
    font-weight: 800; /* Bold */
    margin-bottom: 15px;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.ps-section-header h2 {
    font-size: 27px;
    color: var(--ps-dark-purple);
    font-weight: 800;
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

.ps-section-header p {
    color: var(--ps-text-main);
    opacity: 0.85;
    font-size: 18px;
    max-width: 800px;
    margin: 0 auto;
}

/* Date Toggle Buttons */
.ps-date-toggle {
    display: inline-flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50px;
    padding: 6px;
    margin-top: 25px;
    border: 1px solid rgba(94, 44, 165, 0.1);
}

.ps-toggle-btn {
    background: transparent;
    border: 2px solid var(--ps-dark-purple);
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ps-dark-purple);
    cursor: pointer;
    transition: var(--ps-transition);
}

.ps-toggle-btn:hover:not(.active) {
    background: rgba(94, 44, 165, 0.1);
    color: var(--ps-dark-purple);
}

.ps-toggle-btn.active {
    background: var(--ps-dark-purple);
    color: var(--ps-white);
    box-shadow: 0 4px 15px rgba(94, 44, 165, 0.25);
}

.ps-districts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

/* District Card Base */
.ps-district-card {
    background-color: var(--ps-light-purple);
    border-radius: var(--ps-radius);
    padding: 20px;
    margin: 0;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    transition: var(--ps-transition);
    border: 2px dashed var(--ps-dark-purple);
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.ps-district-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(94, 44, 165, 0.15);
}

.ps-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.ps-district-name {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ps-text-main);
    margin: 0;
}

.ps-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.ps-card-body {
    flex: 1;
    margin-bottom: 20px;
}

.ps-status-text {
    font-size: 1rem;
    line-height: 1.5;
    margin: 0;
    color: var(--ps-text-main);
    font-weight: 500;
}

.ps-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px dashed rgba(94, 44, 165, 0.1);
    padding-top: 15px;
}

.ps-last-updated {
    font-size: 0.8rem;
    color: var(--ps-text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.ps-view-details {
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--ps-transition);
}

/* Detailed District Page Specific Styles */
.ps-district-wrapper {
    margin-top: 20px;
}
.ps-detailed-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.ps-detail-row {
    font-size: 0.9rem;
    line-height: 1.4;
}
.ps-detail-row .ps-label {
    font-weight: 700;
    color: var(--ps-text-main);
    display: inline-block;
    min-width: 80px;
}
.ps-detail-row .ps-value {
    color: var(--ps-text-muted);
}

.ps-district-search-wrapper {
    margin-top: 25px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
}

.ps-date-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.ps-search-input-container {
    flex-grow: 1;
    min-width: 200px;
}

.ps-search-input {
    width: 100%;
    padding: 10px 24px !important;
    font-size: 1rem !important;
    border: 2px solid var(--ps-dark-purple) !important;
    border-radius: 50px !important;
    outline: none !important;
    transition: var(--ps-transition);
    background-color: transparent !important;
    color: var(--ps-dark-purple) !important;
}

.ps-search-input::placeholder {
    color: rgba(94, 44, 165, 0.6);
}

.ps-search-input:focus {
    background-color: rgba(94, 44, 165, 0.05);
    box-shadow: 0 4px 15px rgba(94, 44, 165, 0.15);
}

.ps-date-input-wrapper {
    position: relative;
    display: inline-block;
}

.ps-calendar-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ps-dark-purple);
    pointer-events: none;
}

.ps-date-input {
    width: 150px; /* Fixed width */
    flex-shrink: 0;
    cursor: pointer;
    font-family: inherit;
    color: var(--ps-dark-purple) !important;
    text-align: center;
    padding-left: 36px !important; /* Make room for icon */
    padding-right: 12px !important;
    font-weight: 600;
}

.ps-text-input {
    flex-grow: 1;
}

/* State: Safe (No Shutdown) */
.ps-district-card.ps-status-safe {
    background-color: rgba(16, 185, 129, 0.05); /* Light Green fixed */
    border-color: var(--ps-safe-green); /* Green fixed */
}
.ps-status-safe .ps-icon {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--ps-safe-green);
}
.ps-status-safe .ps-view-details {
    color: var(--ps-text-muted);
}
.ps-status-safe:hover .ps-view-details {
    color: var(--ps-safe-green);
}

/* State: Warning (1-2 Shutdowns) */
.ps-district-card.ps-status-warning {
    background-color: rgba(245, 158, 11, 0.08); /* Light Orange */
    border-color: var(--ps-warn-orange); /* Orange */
}
.ps-status-warning .ps-icon {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--ps-warn-orange);
}
.ps-status-warning .ps-view-details {
    color: var(--ps-warn-orange);
}
.ps-status-warning:hover .ps-view-details {
    color: var(--ps-warn-orange);
    transform: translateX(5px);
    display: inline-block;
}

/* State: Alert (3+ Shutdowns) */
.ps-district-card.ps-status-alert {
    background-color: rgba(239, 68, 68, 0.08); /* Light Red */
    border-color: var(--ps-alert-red); /* Red */
}
.ps-status-alert .ps-icon {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--ps-alert-red);
}
.ps-status-alert .ps-view-details {
    color: var(--ps-alert-red);
}
.ps-status-alert:hover .ps-view-details {
    color: var(--ps-alert-red);
    transform: translateX(5px);
    display: inline-block;
}

/* Responsive */
@media (max-width: 992px) {
    .ps-homepage-wrapper {
        margin: 0 3px;
    }
    .ps-hero-section {
        flex-direction: column;
        text-align: center;
        padding: 30px;
    }
    .ps-hero-content {
        padding-right: 0;
        margin-bottom: 40px;
        width: 100%; /* Ensure content takes full width for stacking */
    }
    .ps-hero-search {
        margin: 30px auto 0 auto; /* Center the search bar */
        width: 100%;
    }
    .ps-quick-chips {
        justify-content: center; /* Center the chips on mobile */
    }
    .ps-districts-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 576px) {
    .ps-hero-content h1, .ps-section-header h1 {
        font-size: 27px !important;
    }
    .ps-search-input-wrapper {
        padding: 5px;
        border-radius: 40px;
    }
    .ps-search-icon {
        display: none;
    }
    .ps-btn-search {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    .ps-section-header {
        padding: 25px 15px;
    }
    .ps-districts-grid {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
    }
    .ps-district-search-wrapper {
        flex-direction: column;
        align-items: stretch;
    }
    .ps-date-controls {
        flex-wrap: nowrap;
        justify-content: center;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 5px;
    }
    .ps-toggle-btn {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        height: 42px; /* Fixed height to match exactly */
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .ps-search-input {
        padding: 8px 15px !important;
        font-size: 0.85rem !important;
    }
    .ps-date-input {
        max-width: 145px !important; /* Wider to show full date */
        min-width: 145px !important;
        padding-left: 36px !important; /* Make room for icon */
        padding-right: 8px !important;
        height: 42px !important; /* Match button height */
        box-sizing: border-box;
    }
}

/* =========================================
   Custom Flatpickr Calendar Styling
   ========================================= */
.flatpickr-calendar {
    font-family: inherit;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(94, 44, 165, 0.15) !important;
    border: 1px solid rgba(94, 44, 165, 0.1) !important;
}

.flatpickr-day {
    position: relative;
    border-radius: 8px !important;
}

/* Custom Dots inside Flatpickr */
.ps-dot {
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.ps-dot.red {
    background-color: var(--ps-alert-red);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.ps-dot.green {
    background-color: var(--ps-safe-green);
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}
