* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ========== LAYOUT: SIDEBAR (Google Maps-style) ==========
   Active when body has class "layout-sidebar".
   To restore the original layout: remove class layout-sidebar from body
   and remove the .app-sidebar element from index.html.
   ========== */

/* Layout wrapper: topbar on row 1, sidebar+map on row 2 */
.layout-sidebar .layout-topbar-wrap {
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr;
    height: 100vh;
    overflow: hidden;
}

.layout-sidebar .layout-main {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    min-height: 0;
    overflow: hidden;
}

.layout-sidebar .layout-main #map {
    min-height: 0;
    position: relative;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    max-width: none;
}

/* Top bar: full width, contains mode switcher, virus toggles, checkboxes */
.app-topbar {
    position: relative;
    width: 100%;
    min-height: 72px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    z-index: 1;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.topbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
}

.app-topbar .mode-switcher {
    margin: 0;
    padding: 0;
    padding-right: 24px;
    border-right: 1px solid #e0e0e0;
    border-bottom: none;
}

.app-topbar .mode-switcher label {
    margin-bottom: 4px;
    font-size: 11px;
}

.app-topbar .mode-toggle {
    display: flex;
    gap: 4px;
    background: #f5f5f5;
    border-radius: 6px;
    padding: 3px;
}

.app-topbar .mode-toggle button {
    padding: 6px 10px;
    font-size: 12px;
}

.app-topbar .mode-switcher img {
    position: static;
    width: 18px;
    height: auto;
    margin-right: 6px;
    vertical-align: middle;
}

.app-topbar .mode-switcher .mode-switcher-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-right: 8px;
    vertical-align: middle;
}

.topbar-title {
    font-size: 18px !important;
    margin: 0 !important;
    color: #333;
    font-weight: 600;
    min-width: 7.5em;   /* Reserve space so virus buttons don't move when title changes */
    flex-shrink: 0;
}

.app-topbar .disease-toggle {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.app-topbar .toggle-btn {
    min-width: 0;
    padding: 6px 12px;
    font-size: 12px;
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-topbar .checkboxes-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin: 0;
}

.app-topbar .checkboxes-wrapper .checkbox-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    margin: 0;
}

.app-topbar .checkboxes-wrapper input[type="checkbox"] {
    margin: 0;
}

.app-topbar .blood-donor-info {
    margin: 0;
    padding: 8px 0 0;
    border-top: 1px solid #eee;
    width: 100%;
}

.app-topbar .blood-donor-info.hidden {
    display: none !important;
}

/* Search in topbar: right-aligned, no box, no "Sök" heading */
.app-topbar .topbar-search {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.app-topbar .topbar-search .search-input-wrapper {
    display: flex;
    gap: 0;
    margin: 0;
}

.app-topbar .topbar-search input {
    width: 180px;
    max-width: 200px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
}

.app-topbar .topbar-search input:focus {
    outline: none;
    border-color: #a50f15;
}

.app-topbar .topbar-search button {
    padding: 6px 12px;
    background: #a50f15;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.app-topbar .topbar-search button:hover {
    background: #8a0d12;
}

/* Virusfall - aggregerat box (samma höjd som virusknapparna) */
.app-topbar .disease-toggle .virusfall-aggregate-box {
    padding: 0 12px;
    height: 32px;
    box-sizing: border-box;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-topbar .disease-toggle .virusfall-aggregate-box.active {
    background: #a50f15;
    color: white;
    border-color: #a50f15;
}

.app-topbar .topbar-search #virusInfo {
    max-width: 200px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: none;
}

.app-sidebar {
    position: relative;
    width: 56px;
    min-width: 56px;
    background: #fff;
    border-right: 2px solid #dee2e6;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 8px;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
}

.sidebar-btn {
    width: 48px;
    height: 48px;
    margin-bottom: 4px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.sidebar-btn:hover {
    background: #f1f3f4;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    padding: 12px 0;
    text-decoration: none;
    color: #333;
    font-size: 10px;
    gap: 2px;
}

.sidebar-item:hover {
    background: #f1f3f4;
}

.sidebar-icon {
    font-size: 20px;
}

.sidebar-label {
    line-height: 1.2;
}

/* Search is in topbar; ECDC timestamp stays absolute over the map */

.layout-sidebar #ecdcTimestamp {
    left: 10px !important;
    bottom: 10px;
}

@media (max-width: 768px) {
    .layout-sidebar .layout-main {
        grid-template-columns: 1fr;
    }
    .layout-sidebar .app-topbar {
        padding-left: 16px;
        min-height: 64px;
    }
    .layout-sidebar #ecdcTimestamp {
        left: 10px !important;
    }
    .app-topbar .topbar-row {
        gap: 10px 16px;
    }
    .topbar-title {
        font-size: 16px !important;
    }
    .app-topbar .toggle-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
    .app-topbar .topbar-search input {
        width: 140px;
        max-width: 160px;
    }
}

/* ========== ORIGINAL LAYOUT (saved for revert) ==========
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}
========== END ORIGINAL LAYOUT ========== */

#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
}

.info-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 320px;
    width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
}

.info-panel h1 {
    font-size: 20px;
    margin-bottom: 8px;
    margin-top: 0;
    color: #333;
}


.disease-toggle {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.toggle-btn {
    flex: 1;
    min-width: 90px;
    padding: 8px 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
}

.toggle-btn:hover {
    border-color: #a50f15;
    color: #a50f15;
}

.toggle-btn.active {
    background: #a50f15;
    color: white;
    border-color: #a50f15;
}

.info-panel p {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.legend {
    margin-top: 10px;
}

.legend-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
    font-size: 12px;
}

.legend-color {
    width: 30px;
    height: 15px;
    margin-right: 8px;
    border-radius: 2px;
}

.hover-info {
    position: absolute;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1;
    min-width: 250px;
    display: none;
    pointer-events: none;
}

.hover-info.visible {
    display: block;
}

.hover-info h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #333;
}

.hover-info .stat {
    font-size: 13px;
    color: #666;
    margin: 4px 0;
}

.hover-info .stat strong {
    color: #333;
}

.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.search-box {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1;
    width: calc(100vw - 40px);
    max-width: 280px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.search-box h3 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #333;
}

.search-box .search-input-wrapper {
    display: flex;
    gap: 0;
    margin-bottom: 4px;  /* Reduced margin */
}

.search-box input {
    flex: 2;
    padding: 6px 10px;  /* Reduced padding */
    border: 2px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 14px;
    margin-bottom: 0;
}

.search-box input:focus {
    outline: none;
    border-color: #a50f15;
}

.search-box button {
    flex: 1;
    padding: 6px 10px;  /* Reduced padding */
    background: #a50f15;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    border-left: 2px solid #a50f15;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
    position: relative;
}

.search-box button:hover {
    background: #8a0d12;
}

.search-box button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.search-box #virusInfo {
    border: 1px solid #ddd;
    word-wrap: break-word;
    margin-top: 4px;  /* Reduced margin */
    padding: 6px;  /* Reduced padding */
    border-radius: 4px;
    min-height: 30px;  /* Reduced min-height */
    font-size: 13px;
    display: none;
}

.search-popup {
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    max-width: 250px;
    word-wrap: break-word;
    line-height: 1.4;
}

.search-popup .popup-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.1);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-popup .popup-close:hover {
    background: rgba(0,0,0,0.2);
}

.search-popup .popup-content {
    padding-right: 20px;
}

.mode-switcher {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
    position: relative;  /* For absolute positioning of image */
    padding-right: 40px;  /* Make room for image (reduced for smaller image) */
    padding-top: 0;  /* Ensure no top padding */
    margin-top: 0;  /* Ensure no top margin */
}

.mode-switcher label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    display: block;
    margin-bottom: 8px;
}

.mode-switcher img {
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: auto;
    margin: 0;
    padding: 0;
}

.mode-toggle {
    display: flex;
    gap: 4px;
    background: #f5f5f5;
    border-radius: 6px;
    padding: 3px;
}

.mode-toggle button {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s;
    color: #666;
}

.mode-toggle button:hover {
    background: rgba(165, 15, 21, 0.1);
    color: #a50f15;
}

.mode-toggle button.active {
    background: #a50f15;
    color: white;
}

.disease-toggle.hidden {
    display: none;
}

.virusfall-checkbox.hidden {
    display: none;
}

.cities-checkbox.hidden {
    display: none;
}

.checkboxes-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkboxes-wrapper > div {
    margin: 0;
}

.blood-donor-info {
    margin-top: 8px;
    padding: 12px;
    background: #f8f9fa;
    border-left: 3px solid #a50f15;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.6;
    color: #333;
}

.blood-donor-info.hidden {
    display: none;
}

.blood-donor-header {
    font-size: 12px;
    line-height: 1.6;
    color: #333;
    margin-bottom: 0;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.blood-donor-header:hover {
    color: #a50f15;
}

.blood-donor-header .expand-icon {
    font-size: 10px;
    color: #a50f15;
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-top: 2px;
}

.blood-donor-info.expanded .blood-donor-header .expand-icon {
    transform: rotate(180deg);
}

.blood-donor-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin-top: 0;
}

.blood-donor-content.expanded {
    max-height: 500px;
    overflow-y: auto;
    margin-top: 8px;
}

.blood-donor-content.collapsed {
    max-height: 0;
    overflow: hidden;
}

.blood-donor-info p {
    margin: 8px 0;
}

.blood-donor-info strong {
    color: #a50f15;
}

.info-panel input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.info-panel label:has(input[type="checkbox"]:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Tablet styles */
@media (max-width: 1024px) {
    .info-panel {
        top: 10px;
        left: 10px;
        padding: 15px;
        max-width: calc(50vw - 15px);
        font-size: 14px;
    }
    
    .info-panel h1 {
        font-size: 18px;
    }
    
    .search-box {
        top: 10px;
        right: 10px;
        padding: 12px;
        max-width: calc(50vw - 15px);
    }
    
    .toggle-btn {
        min-width: 80px;
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .hover-info {
        max-width: calc(50vw - 20px);
    }
    
    .loading {
        padding: 15px 30px;
        font-size: 14px;
    }
}

/* Mobile styles for hover-info */
@media (max-width: 768px) {
    .hover-info {
        max-width: calc(100vw - 40px);
        min-width: 200px;
        padding: 12px;
        font-size: 12px;
    }
    
    .hover-info h3 {
        font-size: 14px;
    }
    
    .hover-info .stat {
        font-size: 11px;
    }
    
    /* Hide map title on mobile */
    .info-panel h1#mapTitle {
        display: none;
    }
}

/* Mobile styles */
@media (max-width: 768px) {
    .info-panel {
        top: 10px;
        left: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        padding: 12px;
        font-size: 13px;
        max-height: calc(50vh - 10px);
    }
    
    .info-panel h1 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    /* Hide map title on mobile */
    .info-panel h1#mapTitle {
        display: none;
    }
    
    .search-box {
        top: auto;
        /* bottom will be set dynamically by JavaScript */
        left: 10px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: calc(100vw - 20px);
        padding: 6px 8px;  /* Reduced padding: 6px top/bottom, 8px left/right */
        max-height: calc(50vh - 10px);
        margin-bottom: 0;
    }
    
    /* Position ecdcTimestamp above OpenStreetMap attribution (no gap) */
    /* Note: JavaScript will set exact position dynamically */
    #ecdcTimestamp {
        /* bottom will be set dynamically by JavaScript */
        margin-bottom: 0 !important;
    }
    
    .search-box h3 {
        font-size: 14px;
        display: none;  /* Hide "Sök" heading on mobile */
    }
    
    .search-box .search-input-wrapper {
        display: flex;
        gap: 0;
        margin-bottom: 4px;  /* Reduced margin */
    }
    
    .search-box input {
        flex: 2;
        font-size: 13px;
        padding: 6px 8px;  /* Reduced padding */
        border-radius: 4px 0 0 4px;
    }
    
    .search-box button {
        flex: 1;
        font-size: 13px;
        padding: 6px 8px;  /* Reduced padding */
        border-radius: 0 4px 4px 0;
        border-left: 2px solid #a50f15;
        z-index: 10;
        position: relative;
    }
    
    .toggle-btn {
        min-width: 70px;
        font-size: 10px;
        padding: 6px 6px;
    }
    
    .mode-toggle button {
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .legend-item {
        font-size: 11px;
    }
    
    .info-panel p {
        font-size: 12px;
    }
    
    .checkboxes-wrapper {
        flex-direction: row;
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .checkboxes-wrapper > div {
        flex: 1;
        min-width: 0;
    }
    
    .checkboxes-wrapper label {
        font-size: 11px !important;
        white-space: nowrap;
    }
    
    .hover-info {
        min-width: 200px;
        max-width: calc(100vw - 40px);
        padding: 12px;
        font-size: 12px;
    }
    
    .hover-info h3 {
        font-size: 14px;
    }
    
    .loading {
        padding: 15px 30px;
        font-size: 14px;
        max-width: calc(100vw - 40px);
    }
}

/* Hide compass/rotation button on all screen sizes and make zoom control shorter */
/* Hide compass button */
.maplibregl-ctrl-compass {
    display: none !important;
}

/* Make zoom control shorter by removing space for compass */
.maplibregl-ctrl-group {
    height: auto !important;
    min-height: auto !important;
}

/* Remove border from last button (zoom out) since compass is hidden */
.maplibregl-ctrl-group button:last-of-type {
    border-bottom: none !important;
}

/* Ensure zoom buttons take up less space */
.maplibregl-ctrl-zoom-in,
.maplibregl-ctrl-zoom-out {
    height: 29px !important;
}

/* Small mobile styles */
@media (max-width: 480px) {
    .info-panel {
        padding: 10px;
        font-size: 12px;
    }
    
    .info-panel h1 {
        font-size: 14px;
    }
    
    .search-box {
        padding: 4px 6px;  /* Reduced padding significantly */
    }
    
    .search-box .search-input-wrapper {
        display: flex;
        gap: 0;
        margin-bottom: 3px;  /* Reduced margin */
    }
    
    .search-box input {
        flex: 2;
        font-size: 12px;
        padding: 6px 8px;  /* Reduced padding */
        border-radius: 4px 0 0 4px;
    }
    
    .search-box button {
        flex: 1;
        font-size: 12px;
        padding: 6px 8px;  /* Reduced padding */
        border-radius: 0 4px 4px 0;
        border-left: 2px solid #a50f15;
        z-index: 10;
        position: relative;
    }
    
    .toggle-btn {
        min-width: 60px;
        font-size: 9px;
        padding: 5px 4px;
    }
    
    .mode-toggle button {
        font-size: 10px;
        padding: 5px 6px;
    }
    
    .disease-toggle {
        gap: 6px;
    }
}

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

#lastChangeText:hover {
    color: #1565c0 !important;
}
