/**
 * Public Stylesheet
 * InfraWatch
 */

:root {
    --deep-navy: #0B1320;
    --slate-blue: #1E293B;
    --steel-gray: #334155;
    --infra-orange: #FF6A00;
    --alert-red: #E63946;
    --teal: #00B894;
    --blue: #3B82F6;
    --text-headings: #FFFFFF;
    --text-body: #E2E8F0;
}

body, html {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--deep-navy);
    color: var(--text-body);
}

h1, h2, h3, h4 {
    font-family: 'Poppins', sans-serif;
    color: var(--text-headings);
    margin-top: 0;
}

/* Navbar */
.navbar {
    height: 80px;
    background-color: var(--slate-blue);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 1000;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-brand h1 {
    font-size: 1.6rem;
    margin: 0;
    letter-spacing: -0.02em;
}

.navbar-brand h1 span {
    color: var(--infra-orange);
}

.logo {
    height: 48px;
    width: auto;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.navbar-links a {
    color: var(--text-body);
    text-decoration: none;
    margin-left: 2rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: color 0.2s;
}

.navbar-links a:hover {
    color: var(--infra-orange);
}

.admin-link {
    background: rgba(255, 106, 0, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--infra-orange);
}

.mobile-menu-btn {
    display: none;
    background: var(--infra-orange);
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 106, 0, 0.3);
}

/* Dashboard Totals */
.totals-panel {
    background-color: var(--slate-blue);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--steel-gray);
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
    z-index: 100;
}

.secondary-totals {
    display: grid;
}

.total-card {
    background-color: var(--deep-navy);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--steel-gray);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.total-card .label {
    font-size: 0.65rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.total-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-headings);
}

.total-card.small-card {
    padding: 0.5rem 0.8rem;
}

.total-card.small-card .value {
    font-size: 1.1rem;
}

.total-card.small-card .label {
    font-size: 0.55rem;
}

.card-orange { border-left-color: var(--infra-orange); }
.card-red { border-left-color: var(--alert-red); }
.card-teal { border-left-color: var(--teal); }
.card-blue { border-left-color: var(--blue); }

@media (max-width: 1200px) {
    .totals-panel {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .navbar {
        height: 65px;
        padding: 0 1.5rem;
    }

    .navbar-links {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .logo {
        height: 36px;
    }

    .navbar-brand h1 {
        font-size: 1.3rem;
    }

    .totals-panel {
        grid-template-columns: repeat(2, 1fr);
        padding: 0.8rem;
        gap: 10px;
    }

    .secondary-totals {
        display: none; /* Hide secondary totals on mobile to prioritize map */
    }

    .total-card {
        padding: 0.6rem 0.8rem;
    }

    .total-card .value {
        font-size: 1.2rem;
    }

    .total-card .label {
        font-size: 0.6rem;
    }
}

/* Sidebar */
.sidebar {
    width: 320px;
    background-color: var(--deep-navy);
    border-right: 1px solid var(--steel-gray);
    display: flex;
    flex-direction: column;
    z-index: 1001;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--steel-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-sidebar {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 85%;
        max-width: 320px;
        transform: translateX(-100%);
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar.active + .sidebar-backdrop {
        display: block;
    }

    .close-sidebar {
        display: block;
    }

    .content-wrapper {
        flex-direction: column !important;
    }

    #map {
        min-height: 60vh !important;
    }

    .mobile-only {
        display: block !important;
    }
}

.mobile-only {
    display: none;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--steel-gray);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-footer a {
    color: var(--text-body);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-footer .admin-link {
    margin-top: 5px;
    justify-content: center;
}

.filter-group {
    padding: 1.2rem 2rem;
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-group .filter-type-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: normal;
    font-size: 0.85rem !important;
    color: var(--text-body) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

@media (max-width: 480px) {
    .filter-group {
        padding: 1rem 1.5rem;
    }
}

select, input[type="date"] {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--slate-blue);
    border: 1px solid var(--steel-gray);
    border-radius: 8px;
    color: white;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

select:focus, input[type="date"]:focus {
    outline: none;
    border-color: var(--infra-orange);
    box-shadow: 0 0 0 2px rgba(255, 106, 0, 0.2);
}

.filter-actions {
    padding: 1.5rem 2rem;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    border-bottom: 1px solid var(--steel-gray);
}

.btn {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.btn-primary { background-color: var(--infra-orange); color: white; }
.btn-secondary { background-color: var(--steel-gray); color: white; }
.btn:hover { opacity: 0.9; }

.recent-incidents {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.recent-incidents h4 {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: #888;
}

.incident-item {
    background-color: var(--slate-blue);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.incident-item:hover {
    background-color: var(--steel-gray);
    transform: translateY(-2px);
}

.incident-item h5 {
    margin: 0 0 0.5rem 0;
    color: var(--text-headings);
    font-size: 0.95rem;
}

.incident-meta {
    font-size: 0.75rem;
    color: #aaa;
    display: flex;
    justify-content: space-between;
}

/* Map Overrides */
.leaflet-container {
    background: var(--deep-navy) !important;
}

.leaflet-popup-content-wrapper {
    background-color: var(--slate-blue) !important;
    color: var(--text-body) !important;
    border-radius: 8px !important;
}

.leaflet-popup-tip {
    background-color: var(--slate-blue) !important;
}

/* Incident Panel */
.incident-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 420px;
    max-height: calc(100% - 40px);
    background-color: var(--slate-blue);
    z-index: 1000;
    border-radius: 12px;
    box-shadow: -10px 0 30px rgba(0,0,0,0.6);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--steel-gray);
    transform: translateX(110%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.incident-panel.active {
    display: flex;
    transform: translateX(0);
}

/* Marker Enhancements */
.marker-glow {
    filter: drop-shadow(0 0 5px var(--marker-color, var(--infra-orange)));
    transition: transform 0.2s ease, filter 0.2s ease;
}

.marker-glow:hover {
    filter: drop-shadow(0 0 8px var(--marker-color, var(--infra-orange)));
    z-index: 1000 !important;
}

/* Verification Badges */
.v-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}
.v-high { background: rgba(0, 184, 148, 0.2); color: var(--teal); border: 1px solid var(--teal); }
.v-mid { background: rgba(255, 106, 0, 0.2); color: var(--infra-orange); border: 1px solid var(--infra-orange); }
.btn-secondary { background-color: transparent; border: 1px solid var(--steel-gray); color: var(--text-body); }
.btn-secondary:hover { background-color: var(--steel-gray); }

.close-panel {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

#panel-content {
    padding: 1.5rem;
    overflow-y: auto;
}

.panel-header h3 {
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.panel-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.panel-meta-item {
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}

.panel-meta-item i {
    width: 20px;
    color: var(--infra-orange);
    margin-right: 5px;
}

.panel-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    margin: 1.5rem 0 0.8rem 0;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--steel-gray);
}

.timeline-item {
    position: relative;
    padding-left: 20px;
    padding-bottom: 1rem;
    border-left: 1px solid var(--steel-gray);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 0;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: var(--infra-orange);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--infra-orange);
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.source-item {
    display: block;
    background: rgba(255,255,255,0.03);
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    text-decoration: none;
    color: var(--text-body);
    transition: background 0.2s;
}

/* Welcome Popup */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.welcome-modal {
    background-color: var(--slate-blue);
    padding: 3rem;
    border-radius: 15px;
    max-width: 550px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--steel-gray);
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
}

.welcome-logo {
    height: 80px;
    margin-bottom: 2rem;
}

.welcome-modal h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.welcome-modal h2 span {
    color: var(--infra-orange);
}

.welcome-modal p {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: #ccc;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--steel-gray);
        position: relative;
        max-height: none;
    }

    .main-container {
        flex-direction: column;
        height: auto;
        overflow: auto;
    }

    #map {
        height: 50vh;
    }

    .incident-panel {
        width: 100%;
        right: 0;
        top: auto;
        bottom: 0;
        border-radius: 12px 12px 0 0;
        max-height: 80%;
    }

    .navbar-brand h1 {
        font-size: 1.2rem;
    }

    .logo {
        height: 30px;
    }
}


