/* --- Global Layout Update for Sticky Footer --- */

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow-x: hidden; /* Prevents horizontal "ghost" scrolling */
}

.main-wrapper {
    flex: 1 0 auto; /* This allows the body content to push the footer down */
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

footer {
    flex-shrink: 0; /* Prevents the footer from shrinking */
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    background-color: #FFF;
    color: #333;
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    width: 100%; 
}

/* Central Wrapper to keep content centered but fluid */
.main-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Dashboard Grid Layout --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 40px;
}

/* --- Card Component Styling --- */
.card {
    background-color: #F5F5F5;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 0; 
    overflow: hidden; 
}

/* --- Collapsible Header Logic (Mobile Optimized) --- */
.card-header {
    background-color: #13294b; /* ISWS Navy */
    color: white;
    cursor: pointer;
    
    /* Touch Target Optimization */
    padding: 20px; /* Generous padding */
    min-height: 60px; /* Ensure strictly valid touch target size */
    width: 100%;
    
    border: none;
    text-align: left;
    outline: none;
    font-size: 1.25rem; /* Larger font for readability */
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    /* Mobile UX Improvements */
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease;
}

.card-header:hover {
    background-color: #1e3f72;
}

.card-header:active {
    background-color: #0d1f3a;
}

/* The visual + / - sign using CSS pseudo-elements */
.card-header::after {
    content: '\002B'; /* Plus sign */
    font-weight: bold;
    float: right;
    margin-left: 15px;
    font-size: 2rem;
    line-height: 1rem;
}

.card-header.active::after {
    content: "\2212"; /* Minus sign */
}

.card-content {
    padding: 0 20px; /* Keep horizontal padding */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, padding 0.3s ease; /* Transition padding too */
    background-color: #F5F5F5;
}

/* --- NEW RULE: Add breathing room ONLY when expanded --- */
/* This ensures the bottom doesn't feel abrupt, while keeping the closed state flush */
.card-header.active + .card-content {
    padding-top: 20px;    /* Adds space at the top */
    padding-bottom: 25px; /* Adds the requested space at the bottom */
}

/* --- Specific Panel Styles --- */

/* 1. Metadata Panel (Minimalist Table) */
.metadata-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 1rem;
	background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08); 
    border-radius: 4px;
}


.metadata-table td {
    padding: 16px 15px; 
    border-bottom: 1px solid #e0e0e0;
}

.metadata-table tr:last-child td {
    border-bottom: none;
}

.meta-label {
    font-weight: 600;
    color: #13294b; 
    width: 35%; 
    vertical-align: top;
}

.meta-value {
    color: #444;
}

/* 2. Map Panel */
#mapid {
    height: 500px;
    width: 100%;
    margin: 20px 0; 
    border-radius: 4px;
}

/* 3. Chart Panel */
.chart-panel {
    padding: 20px; 
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.chart-controls {
    display: flex;
    justify-content: space-between; 
    align-items: center;            
    width: 100%;
    flex-wrap: wrap;                
    gap: 15px;                      
}

#hydrograph {
    width: 100%;
    height: 500px;
    margin: 0 0 10px 0;
    border-radius: 4px;
}

/* --- UI Elements --- */

/* Modern Action Button */
.action-btn {
    background-color: #ffffff;
    color: #13294b;
    border: 2px solid #13294b;
    padding: 12px 24px;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 30px; 
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start; 
    
    touch-action: manipulation;
	margin-bottom: 5px;
}

.action-btn:hover {
    background-color: #13294b;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(19, 41, 75, 0.2);
}

.action-btn:active {
    transform: translateY(0);
}

/* Breadcrumbs */
.breadcrumb {
    font-size: 0.9rem;
    color: #666;
    margin: 20px 0;
}

.breadcrumb a {
    color: #13294b;
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb a:hover {
    color: #d93a17; /* ISWS Orange */
    text-decoration: underline;
}

/* Popup Styling fixes for Leaflet */
.leaflet-popup-content-wrapper {
    background-color: #ffffff;
    color: #333;
    font-size: 14px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Helper Utilities */
.hidden { display: none; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile-Specific Tweaks */
@media (max-width: 600px) {
    .main-wrapper {
        padding: 0 10px; /* Slightly tighter margins for mobile */
    }
    
    /* Increase spacing between stacked cards to fill more vertical space */
    .dashboard-grid {
        gap: 25px;
        margin-top: 10px;
    }
	
	/* --- FIX: Relax Chart Padding on Mobile --- */
    .chart-panel {
        /* Reduce horizontal padding from 20px to 5px to widen the chart */
        padding: 15px 2px; 
    }
    /* ------------------------------------------ */

    /* Expand the card headers to be more prominent touch targets */
    .card-header {
        min-height: 80px;
        padding: 20px 15px;
        font-size: 1.3rem;
    }

    .card-header::after {
        font-size: 2.5rem;     /* Larger +/- icons */
    }

    /* --- FIX FOR PARTIALLY OPEN CARDS --- */
    /* 1. Default state (Collapsed): No vertical padding */
    .card-content {
        padding: 0 20px; 
    }

    /* 2. Active state (Expanded): Apply the comfortable mobile padding */
    /* This targets the content div immediately following an active header */
    .card-header.active + .card-content {
        padding: 10px 20px 30px 20px; 
    }
    /* ------------------------------------ */

    /* Ensure the executive summary paragraphs are distinct */
    .summary-text-wrapper {
        padding: 20px 10px; /* Reduce horizontal padding inside the card */
        font-size: 1.15rem;
    }

    .meta-label {
        font-size: 1.1rem;
        margin-top: 15px;
    }
    
    .meta-value {
        font-size: 1.15rem;
        padding-bottom: 5px;
    }
}



/* --- Executive Summary Styles --- */
.summary-text-wrapper {
    padding: 25px;
    font-size: 1.05rem;
    line-height: 1.8;
    color: #333;
}

.summary-highlight {
    font-weight: 700;
    color: #13294b; /* Navy Blue */
}

.condition-tag {
    font-weight: 700;
    color: #d93a17; /* Orange Accent */
}

.summary-paragraph {
    margin-bottom: 1.5rem;
}

.summary-paragraph:last-child {
    margin-bottom: 0;
}

/* Executive Summary Header Override */
.summary-panel .card-header {
    background-color: #FF5F05; /* Illini Orange */
    color: #13294b; /* Illini Blue */
    font-style: italic;
}

.summary-panel .card-header:hover {
    background-color: #e04e00; /* Slightly darker orange */
}

/* Ensure the plus/minus icon inherits the blue text color */
.summary-panel .card-header::after {
    color: #13294b;
}

/* --- Statistics Panel Styles --- */
.stats-wrapper {
    padding: 20px 0;
}

.stats-placeholder {
    padding: 20px;
    font-style: italic;
    color: #666;
    text-align: center;
}

.table-responsive {
    overflow-x: auto;
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
    background-color: white; /* Ensure shadow is visible against card bg */
}

.stats-header-title {
    margin-top: 0;
    margin-bottom: 15px;
    color: #13294b;
    font-size: 1.1rem;
    font-weight: 700;
    border-left: 4px solid #d93a17; /* Orange accent */
    padding-left: 10px;
}

.stats-table {
    width: 100%;
    border-collapse: separate; /* Required for border-radius on tables */
    border-spacing: 0;
    font-size: 0.9rem;
    background-color: white;
    min-width: 600px; 
}

.stats-table th, 
.stats-table td {
    padding: 12px 6px;
    text-align: left;
    border-bottom: 1px solid #ddd; 
}

.stats-table th {
    background-color: #FF5F05;
    color: #13294b;
    font-weight: 600;
    border-bottom: 2px solid #13294b;
    white-space: nowrap;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    position: relative; /* Ensure it sits "above" the rows z-index wise */
    z-index: 10;
}

/* Alternating Row Shading */
.stats-table tr:nth-child(even) {
    background-color: #C8C6C7;
}

/* Hover Effect (Pastel Orange, skipping current month) */
.stats-table tr:not(.current-month-row):hover {
    background-color: #ffe0b2; 
    transition: background-color 0.1s ease-in-out;
}

.stats-table td:not(:first-child), 
.stats-table th:not(:first-child) {
    text-align: center;
}

.stats-footer {
    text-align: right;
    font-size: 0.8rem;
    color: #666;
    margin-top: -20px;
    margin-bottom: 30px;
    font-style: italic;
}

/* Highlight for the Current Month Row */
.stats-table tr.current-month-row td {
    font-weight: 700;         
    background-color: #e3f2fd; 
    color: #0d1f3a;           
    border-top: 2px solid #13294b; 
    border-bottom: 2px solid #13294b;
}

/* --- Header Animation Styles (Revised) --- */

/* 1. Group wrapper: Added 'overflow: hidden' to clip the text when it moves down */
.header-text-group {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden; /* <--- KEY FIX: Clips the text so it can't be seen "at the bottom" */
    position: relative;
    padding-right: 2px; /* Slight buffer for the text */
}

/* 2. The Well Name Subtitle */
.header-subtitle {
    font-weight: 800;
    font-size: 0.9em;
    color: #13294b;
    display: inline-block; /* Required for consistent transform behavior */
    
    /* VISIBLE STATE (Closed Card) */
    opacity: 1;
    transform: translateY(0);
    
    /* WAIT 0.3s for the card to close, THEN slide up and fade in */
    transition: transform 0.3s ease 0.3s, opacity 0.3s ease 0.3s;
}

/* 3. The "Wipe Down" State (Open Card) */
.card-header.active .header-subtitle {
    /* HIDDEN STATE */
    opacity: 0;
    transform: translateY(100%); /* Move 100% down (completely out of the wrapper) */
    
    /* Vanish IMMEDIATELY when clicking open (No delay) */
    transition: none; 
}