/* ==========================================================================
   1. Design System: Colors & Fonts
   ========================================================================== */
:root {
    --primary-font: 'Montserrat', sans-serif;
    --heading-font: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
    
    --primary-color: #253e85;      /* Bootstrap Blue */
    --secondary-color: #6c757d;   /* Bootstrap Gray */
    --dark-color: #212529;         /* Dark Gray for headings and text */
    --text-color: #343a40;         /* Standard body text */
    --light-text: #6c757d;         /* Lighter Gray for labels */
    --background-light: #f8f9fa;   /* Light page background */
    --border-color: #dee2e6;       /* Standard border color */
    --white: #ffffff;
}
 /* Page Loader Styles */
        #loader-wrapper {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background-color: #f7f7f7; z-index: 9999; display: flex;
            justify-content: center; align-items: center;
        }
        .loader {
            border: 8px solid #e0e0e0; border-top: 8px solid #007bff;
            border-radius: 50%; width: 60px; height: 60px;
            animation: spin 1.5s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* Table and Map Enhancements */
        #wardTable tbody tr:hover, #evictionTable tbody tr:hover {
            background-color: #f0f8ff; cursor: pointer;
            transition: background-color 0.2s ease-in-out;
        }
        .ward-label {
            background: transparent; border: none; box-shadow: none;
            font-size: 14px; font-weight: bold; color: #333;
            text-shadow: 1px 1px 2px white, -1px -1px 2px white;
            pointer-events: none;
        }

        /* Mobile Responsiveness */
        @media (max-width: 768px) {
            #map { height: 350px !important; }
            #ward-info-box { left: auto !important; right: 10px !important; top: 10px !important; }
        }
/* ==========================================================================
   2. Global Styles & Typography
   ========================================================================== */

body {
    font-family: var(--primary-font);
    background-color: var(--background-light);
    color: var(--text-color);
}

h1 {
    font-family: var(--heading-font);
    font-size: 2em;
    margin: 0 0 20px 20px;
    text-align: left;
    color: var(--dark-color);
}

/* ==========================================================================
   3. Layout & Container Styles
   ========================================================================== */

.container {
    padding-top: 10px;
}

.header-wrapper {
    position: relative;
    width: 100%;
    padding-top: 70px;
}

.logo-container {
    position: absolute;
    top: 10px;
    right: 0;
    z-index: 10;
}

.site-logo {
    max-height: 60px;
    width: auto;
    transition: max-height 0.3s ease;
}

/* ==========================================================================
   4. Component Styles
   ========================================================================== */

/* --- Page Loader --- */
#loader-wrapper {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(247, 247, 247, 0.9);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.loader {
    border: 6px solid #e0e0e0;
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- Navigation Tabs --- */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
}

.nav-tabs .nav-link {
    border: none;
    color: var(--light-text);
    font-weight: 500;
    padding: 12px 20px;
    margin-right: 4px;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color);
}

.nav-tabs .nav-link.active {
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.tab-content {
    padding-top: 20px;
}

/* --- DataTables --- */
.table-responsive {
    margin: 2rem auto;
    overflow-x: auto;
}

.table {
    width: 100% !important;
    background-color: var(--white);
}

.table thead th {
    background-color: var(--dark-color);
    color: var(--white);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 1rem;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.table-hover tbody tr:hover {
    background-color: #e3f2fd;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

/* ==========================================================================
   WARD TABLE CONTAINER
   ========================================================================== */

/* Ward table container for wider layout */
.ward-table-container {
    width: 100vw; /* Full viewport width */
    margin-left: calc(-50vw + 50%); /* Break out of container and center */
    padding: 0 2rem;
    box-sizing: border-box;
    text-align: center; /* Center all content */
}

.ward-table-container .table-responsive {
    margin: 1rem auto; /* Center the table wrapper */
    max-width: none;
    overflow-x: auto;
    display: inline-block; /* Allow centering while maintaining scroll */
}

.ward-table-container h4 {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.ward-table-container .description {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--light-text);
    padding: 0 1rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Ward table specific styling - COMPACT AND NATURAL SIZING */
#wardTable {
    font-size: 0.9rem;
    width: auto; /* Let table size to content */
    min-width: 850px; /* Much smaller minimum */
    table-layout: auto; /* Natural column sizing */
    text-align: left; /* Reset text alignment for table content */
}

#wardTable th, #wardTable td {
    padding: 0.75rem 1rem;
    white-space: nowrap;
    text-align: left;
}

#wardTable th {
    position: sticky;
    top: 0;
    background-color: var(--dark-color) !important;
    z-index: 10;
    font-size: 0.9rem;
    font-weight: 600;
}

#wardTable td a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

#wardTable td a:hover {
    color: var(--dark-color);
    text-decoration: underline;
}

/* Fix the "Scheduled Evictions" column (2nd column) width */
#wardTable th:nth-child(2), #wardTable th:nth-child(4), 
#wardTable td:nth-child(2) {
    width: 155px; /* Fixed width for Total/Scheduled Evictions */
    max-width: 155px;
}

/* Eviction table styling */
#evictionTable th:nth-child(1),
#evictionTable td:nth-child(1) {
    width: 15%;
}

#evictionTable th:nth-child(2),
#evictionTable td:nth-child(2) {
    width: 25%;
}

/* Table loading state */
.table-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.table-loading::after {
    content: "Updating data...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255,255,255,0.9);
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 500;
    z-index: 10;
}

/* Summary stats styling */
#summary-stats {
    background-color: rgba(13, 110, 253, 0.1);
    padding: 8px 12px;
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

/* --- Map Components --- */


.ward-label {
    background: transparent;
    border: none;
    box-shadow: none;
    font-weight: 600;
    font-size: 12px;
    color: #000000; /* black */
    text-shadow: none; /* Explicitly remove any text shadow */
    pointer-events: none;
    font-family: var(--primary-font);
}

/* Ward info box */
#ward-info-box {
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

#ward-info-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

/* Leaflet tooltip styling */
.leaflet-tooltip {
    background-color: rgba(0,0,0,0.8);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 500;
}

/* --- Leaflet Legend Styles --- */
.info.legend  {
    background: white;
    padding: 12px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    line-height: 1.4;
    color: #333;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border-radius: 4px;
    border: 1px solid #ccc;
    min-width: 120px;
}

.legend-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    color: #555;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 3px;
}

.legend-color {
    width: 20px;
    height: 16px;
    display: inline-block;
    margin-right: 8px;
    border: 1px solid #999;
    flex-shrink: 0;
}

.legend-label {
    font-size: 12px;
    color: #333;
}

/* --- Form Components --- */
.form-control {
    transition: all 0.2s ease;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-text {
    font-size: 0.85rem;
    color: var(--light-text);
}

/* Date picker enhancements */
.datepicker {
    transition: border-color 0.2s ease;
}

.datepicker:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* --- Button Enhancements --- */
.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

/* --- Card Components --- */
.card {
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Filter status styling */
#filter-status {
    border-left: 4px solid #17a2b8;
    transition: all 0.3s ease;
}

/* --- Census Info Cards for Detail Page --- */

.census-card {
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2rem;
    margin: 2rem auto;
    max-width: 960px; 
    width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.census-card h3 {
    color: var(--dark-color);
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.75rem;
    text-align: center;
}

.census-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.census-section {
    background-color: var(--background-light);
    border-radius: 6px;
    padding: 1.5rem;
    border-left: 4px solid var(--primary-color);
}


.census-section h4 {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.census-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.census-section li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
}


.census-section li:last-child {
    border-bottom: none;
}

.census-section li strong {
    font-weight: 500;
    color: var(--text-color);
    flex: 1;
}

.census-section li span {
    font-weight: 700;
    color: var(--dark-color);
    font-size: 1.1rem;
    text-align: right;
    min-width: 80px;
}

/* --- jQuery UI Datepicker --- */
.ui-datepicker {
    z-index: 1001 !important;
    background: var(--white);
    padding: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    border: 1px solid #ddd;
}

.ui-datepicker-header {
    background: var(--background-light);
    border: none;
}

.ui-datepicker-calendar .ui-state-active {
    background: var(--primary-color);
    color: var(--white);
}

/* --- Tooltip Enhancements --- */
.tooltip {
    font-size: 12px;
}

.tooltip .tooltip-inner {
    background-color: var(--dark-color);
    color: white;
    border-radius: 4px;
    padding: 6px 10px;
}

.tooltip .arrow::before {
    border-top-color: var(--dark-color);
}

/* ==========================================================================
   5. Animation & Transition Effects
   ========================================================================== */

.ward-data-updating {
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.updating-indicator {
    animation: pulse 1.5s infinite;
}

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

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* ==========================================================================
   6. Responsive Design
   ========================================================================== */

/* Large desktop screens - 4 columns for census */
@media (min-width: 1400px) {
    /* Ward table on large screens */
    .ward-table-container {
        padding: 0 3rem;
    }
    
    #wardTable {
        min-width: 1000px; /* Slightly larger on big screens */
        font-size: 1rem;
    }
    
    #wardTable th, #wardTable td {
        padding: 0.8rem 1.2rem;
    }
}

/* Desktop screens */
@media (min-width: 992px) and (max-width: 1399px) {
    
    /* Ward table on desktop */
    .ward-table-container {
        padding: 0 2rem;
    }
    
    #wardTable {
        min-width: 850px;
        font-size: 0.9rem;
    }
    
    #wardTable th, #wardTable td {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 992px) {
    .header-wrapper {
        padding-top: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .logo-container {
        position: relative;
        margin-bottom: 15px;
    }
    
    .site-logo {
        max-height: 45px;
    }

    h1 {
        margin-left: 0;
    }
    
    #ward-info-box {
        font-size: 11px;
        min-width: 160px;
        padding: 10px;
    }
    
    .table th, .table td {
        padding: 0.5rem;
        font-size: 0.85rem;
    }
    
    /* Ward table container adjustments for tablets */
    .ward-table-container {
        padding: 0 1rem;
    }
    
    #wardTable {
        min-width: 800px;
        font-size: 0.85rem;
    }
    
    #wardTable th, #wardTable td {
        padding: 0.7rem 0.8rem;
    }
}

/* Tablet screens */
@media (min-width: 768px) and (max-width: 991px) {
    .census-card {
        padding: 1.5rem;
        margin: 1.5rem auto;
    }
    
    .census-sections {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .census-section {
        padding: 1.25rem;
    }
    
    .census-section h4 {
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    #ward-info-box {
        right: 10px !important; 
        left: 10px !important; 
        top: 10px !important; 
        width: auto !important;
        min-width: auto !important;
        font-size: 10px;
    }

    #map { height: 350px !important; }
    
    .info.legend {
        font-size: 11px;
        padding: 8px;
        min-width: 100px;
    }
    
    .legend-color {
        width: 16px;
        height: 14px;
        margin-right: 6px;
    }
    
    .legend-label {
        font-size: 10px;
    }
    
    .table-responsive {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    .table thead th {
        font-size: 0.8rem;
        padding: 0.75rem;
    }
    
    .card .row > div {
        margin-bottom: 15px;
    }
    
    .btn {
        margin-bottom: 5px;
    }
    
    /* Ward table mobile adjustments */
    .ward-table-container {
        padding: 0 0.5rem;
    }
    
    #wardTable {
        min-width: 700px;
        font-size: 0.8rem;
    }
    
    #wardTable th, #wardTable td {
        padding: 0.6rem 0.7rem;
    }
    
    .ward-table-container h4 {
        font-size: 1.3rem;
        padding: 0 0.5rem;
    }
    
    .ward-table-container .description {
        font-size: 0.9rem;
        padding: 0 0.5rem;
    }
    
    /* Census mobile styles */
    .census-card {
        padding: 1rem;
        margin: 1rem;
        border-radius: 6px;
    }
    
    .census-card h3 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }
    
    .census-sections {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-top: 1rem;
    }
    
    .census-section {
        padding: 1rem;
        border-left-width: 3px;
    }
    
    .census-section h4 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .census-section li {
        padding: 0.5rem 0;
        font-size: 0.9rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .census-section li strong {
        font-size: 0.9rem;
    }
    
    .census-section li span {
        font-size: 1.1rem;
        font-weight: 800;
        color: var(--primary-color);
        align-self: flex-end;
        min-width: auto;
    }
}

@media (max-width: 576px) {
    .site-logo {
        max-height: 40px;
    }
    
    .header-wrapper h1 {
        font-size: 1.5em;
    }
    
    #filter-status {
        font-size: 0.8rem;
        padding: 6px;
    }
    
    .table th, .table td {
        padding: 0.4rem;
        font-size: 0.75rem;
    }
    
    #map {
        height: 300px !important;
    }
    
    /* Ward table extra small screens */
    .ward-table-container {
        padding: 0 0.25rem;
    }
    
    #wardTable {
        min-width: 600px;
        font-size: 0.75rem;
    }
    
    #wardTable th, #wardTable td {
        padding: 0.5rem 0.6rem;
    }
    
    .ward-table-container h4 {
        font-size: 1.2rem;
    }
    
    .ward-table-container .description {
        font-size: 0.85rem;
    }
    
    /* Census extra small screens */
    .census-card {
        margin: 0.5rem;
        padding: 0.75rem;
    }
    
    .census-card h3 {
        font-size: 1.3rem;
    }
    
    .census-section {
        padding: 0.75rem;
    }
    
    .census-section h4 {
        font-size: 0.95rem;
    }
    
    .census-section li {
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   7. Accessibility & Performance
   ========================================================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0056b3;
        --border-color: #495057;
        --text-color: #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loader {
        animation: none;
        border: 8px solid var(--primary-color);
    }
}