/* Minimal layout CSS to support map and offcanvas layout with Bootstrap defaults */

html, body {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: #0b0f17;
}

h1 {
    color: rgb(150 249 122);
}

h5, h4 {
    color: rgb(122, 171, 249);
}



/* Header layout */
.main-header {
    height: 72px; /* fixed header height */
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    box-shadow: 0 8px 26px rgba(0,0,0,0.12);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
    backdrop-filter: blur(6px);
    background:
        radial-gradient(circle at 30% 20%, rgba(230, 236, 245, 0.14), transparent 55%),
        radial-gradient(circle at 75% 10%, rgba(148, 209, 152, 0.14), transparent 58%),
        linear-gradient(135deg, rgba(13, 20, 32, 0.9), rgba(15, 26, 43, 0.92), rgba(12, 17, 28, 0.9));
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.main-header h1 { margin: 0; font-size: 1.1rem; }
.main-header p { margin: 0 0 0 12px; opacity: 0.85; font-size: 0.95rem; }

/* Main content sits below the header and fills remaining viewport */
.main-content {
    position: absolute;
    top: 72px; /* header height */
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* Map fills the main content area */
#map {
    width: 100%;
    height: 100%;
    min-height: 320px;
}

/* Loading overlay (detailed rule appears later) - keep declaration minimal here */

/* Legend: (see detailed styles further down) */

/* Ensure offcanvas width is reasonable */
.offcanvas {
    width: 320px;
    background:
        radial-gradient(circle at 20% 10%, rgba(129, 230, 217, 0.12), transparent 42%),
        radial-gradient(circle at 80% 12%, rgba(148, 209, 152, 0.16), transparent 46%),
        linear-gradient(180deg, rgba(11, 15, 23, 0.95), rgba(13, 19, 31, 0.94) 45%, rgba(8, 12, 20, 0.96));
    color: #e5e7eb;
}

/* Keep other components simple and Bootstrap-friendly */
.header-brand { margin-left: 1rem; height: 56px; }

/* On medium+ screens show the offcanvas as a persistent left sidebar */
@media (min-width: 768px) {
    .offcanvas.offcanvas-start {
        position: fixed !important;
        top: 72px; /* below header */
        left: 0;
        width: 320px;
        height: calc(100% - 72px);
        transform: none !important;
        visibility: visible !important;
        background:
            radial-gradient(circle at 20% 10%, rgba(129, 203, 230, 0.12), transparent 42%),
            radial-gradient(circle at 80% 12%, rgba(148, 199, 209, 0.16), transparent 46%),
            linear-gradient(180deg, rgba(11, 15, 23, 0.95), rgba(13, 19, 31, 0.94) 45%, rgba(8, 12, 20, 0.96));
        border-right: 1px solid rgba(255,255,255,0.06);
        padding-top: 0.5rem;
        z-index: 1040;
        box-shadow: 8px 0 24px rgba(0,0,0,0.35);
    }

    /* Remove the backdrop on desktop since panel is persistent */
    .offcanvas-backdrop {
        display: none !important;
    }

    /* Shift main content to the right to make room for the sidebar */
    .main-content {
        left: 320px;
        top: 72px;
        right: 0;
        bottom: 0;
    }

    .offcanvas .offcanvas-body {
        padding: 1rem;
        overflow-y: auto;
        height: 100%;
    }
}

.offcanvas .offcanvas-header {
    color: #e5e7eb;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(100deg, rgba(41, 51, 67, 0.78), rgba(177, 195, 222, 0.462), rgba(58, 70, 89, 0.78));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 8px 18px rgba(0,0,0,0.25);
}

.offcanvas .offcanvas-body {
    background:
        radial-gradient(circle at 15% 15%, rgba(132, 204, 255, 0.12), transparent 50%),
        radial-gradient(circle at 80% 25%, rgba(138, 243, 255, 0.14), transparent 52%),
        linear-gradient(170deg, rgba(10, 14, 23, 0.96), rgba(12, 18, 28, 0.94));
    border-top: 1px solid rgba(255,255,255,0.03);
}

.control-section {
    position: relative;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background:
        radial-gradient(circle at 30% 20%, rgba(132, 204, 255, 0.18), transparent 55%),
        radial-gradient(circle at 78% 28%, rgba(148, 209, 152, 0.22), transparent 52%),
        linear-gradient(145deg, rgba(18, 24, 35, 0.96), rgba(12, 16, 26, 0.94));
    border: 1px solid rgb(255 255 255 / 9%);
    box-shadow: 0px 0px 20px 16px rgba(0, 0, 0, 0.30);
    margin-bottom: 1rem;
    overflow: hidden;
}

.control-section h5 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.95rem;
    letter-spacing: 0.01em;
}

.control-section::after {
    content: "";
    position: absolute;
    inset: -10% -14%;
    background: radial-gradient(circle at 70% 50%, rgba(255,255,255,0.02), transparent 55%);
    pointer-events: none;
}

.stats-box {
    padding: 0.85rem;
    margin-top: 0.6rem;
    border-radius: 10px;
    background:
        radial-gradient(circle at 25% 25%, rgba(132, 204, 255, 0.14), transparent 50%),
        linear-gradient(160deg, rgba(13, 17, 27, 0.9), rgba(16, 21, 32, 0.92));
    border: 1px solid rgba(255,255,255,0.04);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), 0 10px 20px rgba(0,0,0,0.28);
}

.stats-title {
    font-weight: 600;
    color: #c7d2fe;
    margin-bottom: 0.25rem;
}

.mini-bar-chart {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.mini-chart-wrap {
    margin-top: 0.5rem;
    background: rgba(255,255,255,0.02);
    border-radius: 12px;
    padding: 0.4rem;
    border: 1px solid rgba(255,255,255,0.03);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.mini-bar-row {
    display: grid;
    grid-template-columns: 1fr 5fr auto;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.mini-bar-label {
    color: #e5e7eb;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.mini-bar {
    position: relative;
    height: 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.35);
}

.mini-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, rgba(148, 209, 152, 0.9), rgba(132, 204, 255, 0.95));
    border-radius: 999px;
    box-shadow: 0 0 8px rgba(148,209,152,0.35);
}

.mini-bar-value {
    color: #e5e7eb;
    font-weight: 600;
    min-width: 36px;
    text-align: right;
}

.mini-bar-empty {
    font-size: 0.85rem;
    color: #9ca3af;
}


/* Popup Styles */
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: rgba(20, 20, 20, 0.9);
    color: var(--cs-text-main);
    box-shadow: 0 3px 14px rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
}

.popup-content {
    max-width: 300px;
    font-size: 0.9rem;
}

.popup-title {
    font-weight: 600;
    color: rgb(255 146 83);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.popup-field {
    margin-bottom: 0.4rem;
}

.popup-label {
    font-weight: 500;
    color: var(--cs-text-muted);
    display: inline-block;
    width: 80px;
}

.popup-value {
    color: var(--cs-text-main);
}

.popup-claim {
    background: #2a2a2a;
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem 0;
    font-style: italic;
    border-left: 3px solid var(--cs-primary);
    color: #ddd;
}

.popup-link {
    color: var(--cs-primary);
    text-decoration: none;
    font-size: 0.85rem;
}

.popup-link:hover {
    text-decoration: underline;
}

.popup-card-link {
    color: var(--cs-primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dotted var(--cs-primary);
}

.popup-card-link:hover {
    background: rgba(148,209,152,0.12);
    padding: 1px 2px;
    border-radius: 2px;
    border-bottom: 1px solid var(--cs-primary-dark);
}

.popup-review-excerpt {
    background: #2a2a2a;
    padding: 0.4rem;
    border-radius: 4px;
    margin-top: 0.2rem;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #ccc;
    border-left: 3px solid #38a169;
}

/* Legend */
.legend {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background:
        radial-gradient(circle at 30% 20%, rgba(132, 204, 255, 0.18), transparent 55%),
        radial-gradient(circle at 78% 28%, rgba(148, 209, 152, 0.22), transparent 52%),
        linear-gradient(145deg, rgba(18, 24, 35, 0.96), rgba(12, 16, 26, 0.94));
    padding: 0.9rem;
    border-radius: 10px;
    box-shadow: 0 14px 30px rgba(0,0,0,0.30);
    z-index: 1000;
    max-width: 300px;
    font-size: 0.9rem;
    border: 1px solid var(--cs-border);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.4rem;
    cursor: pointer;
    padding: 0.25rem 6px;
    border-radius: 8px;
    transition: background 0.18s, transform 0.12s;
}

.legend-item:hover {
    background: rgba(255,255,255,0.05);
    transform: translateY(-1px);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 0.6rem;
    border: none;
    box-shadow: 0 6px 14px rgba(0,0,0,0.2) inset;
}

.legend-label {
    flex: 1;
    font-size: 0.8rem;
    color: var(--cs-text-main);
}

.legend-count {
    font-size: 0.75rem;
    color: var(--cs-text-muted);
    margin-left: 0.3rem;
}

/* Cluster pie markers */
.marker-cluster.marker-cluster-custom {
    background: transparent;
    border: none;
    box-shadow: none;
}

.cluster-pie {
    /*position: relative;*/
    width: 44px;
    height: 44px;
    border-radius: 50%;
    box-shadow: 2px 1px 10px 10px rgb(106 182 255 / 26%);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.92;
}

.cluster-pie-svg {
    position: absolute;
    inset: 0;
}

.cluster-count {
    position: absolute;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* Rating Badges */
.rating-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 0.3rem;
}

.rating-not-credible {
    background: #4a1a1a;
    color: #ff6b6b;
}

.rating-credible {
    background: #1a3a2a;
    color: #68d391;
}

.rating-partially-credible {
    background: #3a2a1a;
    color: #f6ad55;
}

.rating-not-verifiable {
    background: #2d3748;
    color: #a0aec0;
}

/* Loading and Error States */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--cs-bg-panel);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    text-align: center;
    z-index: 10000;
    color: var(--cs-text-main);
}

.loading.hidden {
    display: none;
}

.spinner {
    border: 4px solid #333;
    border-top: 4px solid var(--cs-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error {
    background: #4a1a1a;
    color: #ff6b6b;
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 2rem;
}

/* Navigation */
.main-nav {
    display: flex;
    gap: 1.5rem;
    margin-left: 2rem;
}

.nav-link {
    color: var(--cs-text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

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

.nav-link.active {
    color: var(--cs-primary);
    border-bottom-color: var(--cs-primary);
}

@media (max-width: 768px) {
    .main-nav {
        display: none; /* Hide on mobile for now, or move to sidebar */
    }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        position: fixed;
        top: 20px;
        left: 20px;
        z-index: 1040;
        background: rgba(30,30,30,0.9);
        backdrop-filter: blur(10px);
        color: var(--cs-text-main);
        border: 1px solid var(--cs-border);
    }
}

/* Form Elements Dark Mode */
.form-select, .form-control {
    background-color: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

.form-select:focus, .form-control:focus {
    background-color: #2a2a2a;
    border-color: var(--cs-primary);
    color: #e0e0e0;
    box-shadow: 0 0 0 0.25rem rgba(148, 209, 152, 0.25);
}

.form-check-input {
    background-color: #2a2a2a;
    border-color: #444;
}

.form-check-input:checked {
    background-color: var(--cs-primary);
    border-color: var(--cs-primary);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--cs-bg-panel); 
}

::-webkit-scrollbar-thumb {
    background: #4b5563; 
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6b7280; 
}
