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

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f9f8;
    color: #2c3e3b;
}

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #2d4f4c 0%, #3a615c 100%);
    color: #ffffff;
    padding: 1.25rem 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    max-width: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    grid-column: 1;
    justify-self: start;
}

.header-center {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
    grid-column: 2;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    grid-column: 3;
    justify-self: end;
}

.about-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.about-link:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

header h1 {
    font-size: 1.75rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header h1 .icon {
    font-size: 1.5rem;
}

header p {
    font-size: 0.95rem;
    opacity: 0.9;
    margin: 0;
}

.month-label {
    font-size: 1rem;
    font-weight: 500;
}

.month-select {
    background: white;
    color: #2c3e3b;
    border: none;
    padding: 0.5rem 2rem 0.5rem 1rem;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a7d78' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    min-width: 150px;
}

.month-select:hover {
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

main {
    padding: 0;
    margin: 0;
    height: calc(100vh - 80px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.map-container-fullscreen {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1;
    overflow: hidden;
}

.map {
    width: 100%;
    height: 100%;
    background: #f5f9f8;
    position: relative;
    z-index: 1;
}

/* Climate Preferences Sidebar (left side, collapsible) */
.climate-preferences-sidebar {
    position: absolute;
    top: 20px;  /* Aligned with zoom controls */
    left: 70px;  /* Right next to zoom controls */
    background: rgba(255, 255, 255, 0.97);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 999;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.climate-preferences-sidebar.collapsed {
    width: auto;
}

.climate-preferences-sidebar:not(.collapsed) {
    width: 280px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.preferences-toggle {
    background: linear-gradient(135deg, #4a7d78 0%, #5d8f87 100%);
    color: #ffffff;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    width: 100%;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.preferences-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.toggle-icon {
    font-size: 1.2rem;
}

.preferences-content {
    display: none;
    padding: 0.75rem;
    padding-top: 0.5rem;
}

.climate-preferences-sidebar:not(.collapsed) .preferences-content {
    display: block;
}

.climate-preferences-sidebar h3 {
    font-size: 0.85rem;
    margin: 0 0 0.4rem 0;
    color: #2c3e3b;
    font-weight: 600;
}

.preference-section {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #d4e3e1;
}

.preference-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Display Mode Buttons */
.display-mode-section {
    margin-bottom: 0.5rem;
}

.mode-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.mode-btn {
    background: white;
    border: 2px solid #d4e3e1;
    border-radius: 8px;
    padding: 0.4rem 0.3rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    font-weight: 500;
    color: #2c3e3b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
}

.mode-btn .icon {
    font-size: 1.1rem;
}

.mode-btn:hover {
    border-color: #4a7d78;
    background: #e8f2f0;
}

.mode-btn.active {
    background: #4a7d78;
    border-color: #4a7d78;
    color: white;
}

.current-month {
    background: #e8f2f0;
    padding: 0.75rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 600;
    color: #4a7d78;
    margin: 0;
}

/* Dual Range Slider Styling */
.dual-slider {
    position: relative;
    height: 35px;
    margin-top: 0.4rem;
}

.dual-slider input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
}

.dual-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5d8f87;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    position: relative;
    z-index: 3;
    margin-top: -6px;
}

.dual-slider input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #5d8f87;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid white;
    margin-top: -6px;
}

.dual-slider input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: #d4e3e1;
    border-radius: 3px;
}

.dual-slider input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    background: #d4e3e1;
    border-radius: 3px;
}

.dual-slider input[type="range"]:first-child {
    z-index: 1;
}

.dual-slider input[type="range"]:last-child {
    z-index: 2;
}

/* Legend Overlay (top center) */
.legend-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 0.65rem 1.5rem;
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

#legend-content-horizontal {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.legend-colors {
    display: flex;
    gap: 0.5rem;
}

.legend-color {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    color: white;
    font-weight: 500;
}

/* Info Message Overlay (bottom center) */
.info-message-overlay {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 0.75rem 2rem;
    border-radius: 25px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    backdrop-filter: blur(10px);
    font-size: 0.95rem;
    color: #666;
}

.temp-unit-buttons-sidebar {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.temp-unit-btn {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
}

.temp-unit-btn:hover {
    border-color: #4a7d78;
    color: #4a7d78;
    transform: translateY(-1px);
}

.temp-unit-btn.active {
    background: #4a7d78;
    color: white;
    border-color: #4a7d78;
}

/* Weather Details Overlay (right side) */
.weather-details-overlay {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    backdrop-filter: blur(10px);
    max-width: 320px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.weather-details-overlay h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #4a7d78;
}

.weather-details-overlay .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.weather-details-overlay .close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

/* Leaflet overrides */
.map .leaflet-container {
    background: #e8f4f8;
}

.map .leaflet-tile-pane {
    filter: brightness(0.95) contrast(1.05);
}

.leaflet-control-attribution {
    background-color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
}

/* Remove focus outline/rectangle from province paths */
.leaflet-interactive {
    outline: none !important;
}

.leaflet-interactive:focus {
    outline: none !important;
}

svg path {
    outline: none !important;
}

/* Custom pin marker styling */
.custom-pin {
    background: transparent;
    border: none;
}

.custom-pin svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

#weatherInfo {
    font-size: 0.9rem;
    line-height: 1.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .layer-selector-overlay {
        top: 10px;
        left: 10px;
        min-width: 150px;
        padding: 0.75rem;
    }
    
    .weather-details-overlay {
        top: 10px;
        right: 10px;
        max-width: calc(100vw - 200px);
    }
    
    .info-message-overlay {
        font-size: 0.85rem;
        padding: 0.6rem 1.5rem;
    }
}
