/**
 * CDRRMO Barangay Flood Tracker Widget Styles
 * Inspired by Bulacan PDRRMO municipality flood monitoring design
 *
 * @version 1.0.0
 */

/* ============================================================
   CONTAINER
   ============================================================ */

.barangay-flood-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.95), rgba(15, 23, 42, 0.98));
    border-radius: 12px;
    border: 1px solid rgba(0, 168, 232, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.flood-tracker-section {
    background: rgba(30, 41, 59, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.flood-tracker-section .section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.flood-tracker-section .section-icon {
    font-size: 1.5rem;
}

.flood-tracker-section .header-text {
    flex: 1;
}

.flood-tracker-section .header-text h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #f1f5f9;
}

.flood-tracker-section .subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
}

.flood-tracker-section .live-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    background: #22c55e;
    color: white;
    border-radius: 4px;
    animation: pulse-live 2s infinite;
}

/* ============================================================
   SUMMARY BAR
   ============================================================ */

.flood-summary-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    min-width: 80px;
}

.summary-item .summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
}

.summary-item .summary-label {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-item.normal .summary-value { color: #22c55e; }
.summary-item.monitoring .summary-value { color: #3b82f6; }
.summary-item.flooded .summary-value { color: #f97316; }
.summary-item.severe .summary-value { color: #dc2626; }
.summary-item.affected .summary-value { color: #eab308; }
.summary-item.evacuated .summary-value { color: #a855f7; }

.summary-divider {
    width: 1px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 0.5rem;
}

/* ============================================================
   CONTROLS
   ============================================================ */

.flood-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(15, 23, 42, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.view-toggle {
    display: flex;
    gap: 0.25rem;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 6px;
    padding: 0.25rem;
}

.view-btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    background: transparent;
    color: #94a3b8;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e2e8f0;
}

.view-btn.active {
    background: rgba(59, 130, 246, 0.3);
    color: #3b82f6;
}

.filter-controls {
    display: flex;
    gap: 0.5rem;
}

.filter-controls select,
.filter-controls input {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    background: rgba(30, 41, 59, 0.8);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    outline: none;
}

.filter-controls select:focus,
.filter-controls input:focus {
    border-color: rgba(59, 130, 246, 0.5);
}

.filter-controls input {
    width: 200px;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */

.flood-content {
    padding: 1rem;
}

.barangay-list-view {
    display: none;
}

.barangay-list-view.active {
    display: block;
}

.barangay-map-view {
    display: none;
}

.barangay-map-view.active {
    display: block;
}

.flood-map {
    height: 400px;
    border-radius: 8px;
    overflow: hidden;
}

/* ============================================================
   BARANGAY GRID
   ============================================================ */

.barangay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.barangay-grid::-webkit-scrollbar {
    width: 6px;
}

.barangay-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.barangay-grid::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 3px;
}

/* ============================================================
   BARANGAY CARD
   ============================================================ */

.barangay-card {
    background: rgba(15, 23, 42, 0.7);
    border-radius: 8px;
    padding: 0.75rem;
    border-left: 4px solid #22c55e;
    transition: all 0.3s ease;
}

.barangay-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.barangay-card.normal { border-left-color: #22c55e; }
.barangay-card.monitoring { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.barangay-card.flooded { border-left-color: #f97316; background: rgba(249, 115, 22, 0.1); }
.barangay-card.severe {
    border-left-color: #dc2626;
    background: rgba(220, 38, 38, 0.15);
    animation: pulse-severe 2s infinite;
}

@keyframes pulse-severe {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

.barangay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.barangay-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #f1f5f9;
}

.status-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    border: 1px solid;
}

/* ============================================================
   WATER DEPTH INDICATOR
   ============================================================ */

.water-depth-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.depth-bar {
    flex: 1;
    height: 6px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 3px;
    overflow: hidden;
}

.depth-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #f97316);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.depth-value {
    font-size: 0.75rem;
    font-weight: 600;
    color: #3b82f6;
    min-width: 50px;
    text-align: right;
}

/* ============================================================
   BARANGAY STATS
   ============================================================ */

.barangay-stats {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.barangay-stats .stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
    color: #94a3b8;
}

.barangay-stats .stat-icon {
    font-size: 1rem;
    margin-bottom: 0.15rem;
}

.barangay-stats .stat-value {
    font-weight: 600;
    color: #e2e8f0;
}

.barangay-stats .stat-label {
    font-size: 0.6rem;
    text-align: center;
}

.barangay-stats .stat.trend.rising .stat-value { color: #f97316; }
.barangay-stats .stat.trend.falling .stat-value { color: #22c55e; }
.barangay-stats .stat.trend.stable .stat-value { color: #3b82f6; }
.barangay-stats .stat.trend.rapid_rise .stat-value { color: #dc2626; }

/* ============================================================
   BARANGAY META
   ============================================================ */

.barangay-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.risk-badge {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.population {
    font-size: 0.7rem;
    color: #64748b;
}

/* ============================================================
   ROADS AFFECTED
   ============================================================ */

.roads-affected {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
    padding: 0.4rem;
    background: rgba(249, 115, 22, 0.1);
    border-radius: 4px;
}

.roads-label {
    font-weight: 600;
}

.roads-list {
    color: #fb923c;
}

/* ============================================================
   BARANGAY NOTES
   ============================================================ */

.barangay-notes {
    display: flex;
    align-items: flex-start;
    gap: 0.3rem;
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    padding: 0.3rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 4px;
}

.note-icon {
    flex-shrink: 0;
}

.note-text {
    line-height: 1.3;
}

/* ============================================================
   LAST REPORT
   ============================================================ */

.last-report {
    font-size: 0.65rem;
    color: #64748b;
    text-align: right;
}

/* ============================================================
   EVACUATION SECTION
   ============================================================ */

.evacuation-section {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.evacuation-section h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    color: #e2e8f0;
}

.evacuation-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
}

.evacuation-card {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 0.75rem;
    border-left: 3px solid #22c55e;
}

.evacuation-card.occupied { border-left-color: #eab308; }
.evacuation-card.full { border-left-color: #dc2626; }

.evac-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.evac-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
}

.evac-status {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-transform: uppercase;
}

.evac-status.available { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.evac-status.occupied { background: rgba(234, 179, 8, 0.2); color: #eab308; }
.evac-status.full { background: rgba(220, 38, 38, 0.2); color: #dc2626; }

.evac-capacity {
    margin-bottom: 0.5rem;
}

.capacity-bar {
    height: 6px;
    background: rgba(30, 41, 59, 0.8);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.capacity-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #eab308);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.capacity-text {
    font-size: 0.7rem;
    color: #94a3b8;
}

.evac-facilities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.facility-tag {
    font-size: 0.6rem;
    padding: 0.1rem 0.3rem;
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
    border-radius: 2px;
}

/* ============================================================
   FOOTER
   ============================================================ */

.flood-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.4);
}

.flood-footer .last-update {
    font-size: 0.75rem;
    color: #64748b;
}

.flood-footer .refresh-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.8rem;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.flood-footer .refresh-btn:hover {
    background: rgba(59, 130, 246, 0.3);
}

.flood-footer .refresh-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================
   MAP MARKERS
   ============================================================ */

.evac-marker {
    background: transparent;
    border: none;
    font-size: 20px;
    text-align: center;
}

/* ============================================================
   NO DATA
   ============================================================ */

.no-data {
    text-align: center;
    padding: 2rem;
    color: #64748b;
    font-size: 0.9rem;
}

/* ============================================================
   ERROR STATE
   ============================================================ */

.flood-tracker-section.error .error-content {
    text-align: center;
    padding: 2rem;
}

.flood-tracker-section.error .error-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.flood-tracker-section.error p {
    color: #94a3b8;
    margin-bottom: 1rem;
}

.flood-tracker-section.error .retry-btn {
    padding: 0.5rem 1rem;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 4px;
    cursor: pointer;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
    .barangay-flood-container {
        padding: 0.5rem;
        border-radius: 8px;
    }

    .flood-summary-bar {
        justify-content: center;
    }

    .summary-item {
        min-width: 60px;
        padding: 0.4rem 0.6rem;
    }

    .summary-item .summary-value {
        font-size: 1.2rem;
    }

    .summary-divider {
        display: none;
    }

    .flood-controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .filter-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .filter-controls select,
    .filter-controls input {
        flex: 1;
        min-width: 120px;
    }

    .barangay-grid {
        grid-template-columns: 1fr;
        max-height: 400px;
    }

    .flood-map {
        height: 300px;
    }

    .evacuation-grid {
        grid-template-columns: 1fr;
    }

    .flood-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .barangay-card,
    .depth-fill,
    .capacity-fill {
        transition: none;
    }

    .barangay-card.severe,
    .live-badge {
        animation: none;
    }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */

@media print {
    .barangay-flood-container {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .barangay-card {
        background: white;
        border: 1px solid #ddd;
    }

    .flood-controls,
    .flood-footer .refresh-btn {
        display: none;
    }
}
