@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyN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wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0a0a0a;
    color: #ffffff;
    overflow: hidden;
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    padding: 0.75rem 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    box-shadow: 0 2px 20px rgba(0,0,0,0.5);
    border-bottom: 1px solid #333;
}

.mobile-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: bold;
    background: linear-gradient(45deg, #ffd700, #ff8c00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    color: #ffd700;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

    .mobile-menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        background: #ffd700;
        transition: 0.3s;
    }

.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #ffd700;
    cursor: pointer;
    position: absolute;
    top: 1rem;
    right: 1rem;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 400px;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 2rem;
    border-right: 1px solid #333;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
}

    .sidebar-header h1 {
        font-size: 2rem;
        background: linear-gradient(45deg, #ffd700, #ff8c00);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        margin-bottom: 0.5rem;
    }

    .sidebar-header p {
        color: #ccc;
        font-size: 0.9rem;
    }

.controls {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.control-group {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.control-label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 600;
    color: #ffd700;
}

.slider-container {
    margin-bottom: 1rem;
}

.form-range {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

    .form-range::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 20px;
        height: 20px;
        background: linear-gradient(45deg, #ffd700, #ff8c00);
        border-radius: 50%;
        cursor: pointer;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }

    .form-range::-moz-range-thumb {
        width: 20px;
        height: 20px;
        background: linear-gradient(45deg, #ffd700, #ff8c00);
        border-radius: 50%;
        cursor: pointer;
        border: none;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #ccc;
}

.selected-age-display {
    text-align: center;
    padding: 1rem;
    background: rgba(255, 215, 0, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.age-badge {
    font-size: 1.5rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.age-description {
    display: block;
    margin-top: 0.5rem;
    color: #ccc;
    font-size: 0.9rem;
}

.stats-panel {
    background: rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

    .stat-item:last-child {
        margin-bottom: 0;
    }

.stat-label {
    color: #ccc;
}

.stat-value {
    color: #ffd700;
    font-weight: bold;
}

.highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 10px -15px -15px -15px;
    padding: 15px;
    border-radius: 0 0 8px 8px;
}

    .highlight .stat-label {
        color: white;
        font-weight: bold;
        font-size: 14px;
    }

    .highlight .stat-value {
        color: white;
        font-weight: bold;
        font-size: 18px;
    }

.updating-indicator {
    color: #ffd700;
    font-size: 18px;
    margin-left: 10px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Map Container */
.map-container {
    position: relative;
    flex: 1;
    min-width: 0;
}

.map-flag-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    pointer-events: none;
}

.sweden-flag {
    width: 100px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

    .sweden-flag:hover {
        opacity: 1;
    }

.map {
    width: 100%;
    height: 100%;
    background: #1a1a1a;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid #ffd700;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    background: #1a1a2e;
    color: white;
    border-radius: 8px;
    border: 1px solid #333;
}

.leaflet-popup-tip {
    background: #1a1a2e;
}

.popup-content h3 {
    color: #ffd700;
    margin-bottom: 0.5rem;
}

.popup-content p {
    margin-bottom: 0.5rem;
}

.color-indicator {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    margin-top: 0.5rem;
}

/* Scrollbar styling */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.5);
    border-radius: 3px;
}

    .sidebar::-webkit-scrollbar-thumb:hover {
        background: rgba(255, 215, 0, 0.7);
    }

/* Legend styles */
.population-legend {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px;
    border-radius: 5px;
    color: white;
    font-size: 12px;
    line-height: 1.4;
    backdrop-filter: blur(5px);
}

    .population-legend h4 {
        margin: 0 0 8px 0;
        font-size: 14px;
        text-align: center;
        color: #ffd700;
    }

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

    .legend-item i {
        display: inline-block;
        width: 18px;
        height: 18px;
        margin-right: 8px;
        border: 1px solid #fff;
        border-radius: 2px;
    }

/* Error Overlay */
.error-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-message {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid #333;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

    .error-message h3 {
        color: #ffd700;
        margin-bottom: 1rem;
    }

.btn-retry, .btn-debug {
    padding: 0.75rem 1.5rem;
    margin: 0.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-retry {
    background: linear-gradient(45deg, #ffd700, #ff8c00);
    color: #1a1a2e;
}

.btn-debug {
    background: rgba(255, 255, 255, 0.1);
    color: #ffd700;
    border: 1px solid #ffd700;
}

    .btn-retry:hover, .btn-debug:hover {
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(255, 215, 0, 0.3);
    }

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .mobile-header {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 400px;
        transform: translateX(-100%);
        z-index: 1001;
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }

        .sidebar.mobile-open {
            transform: translateX(0);
        }

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

    .sidebar-header h1 {
        font-size: 1.5rem;
        padding-right: 2rem;
    }

    .controls {
        gap: 1.5rem;
    }

    .control-group, .stats-panel {
        padding: 1.25rem;
    }

    .age-badge {
        font-size: 1.25rem;
    }

    .map-container {
        margin-top: 3.5rem;
        height: calc(100vh - 3.5rem);
    }

    .sweden-flag {
        width: 60px;
    }

    .stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .selected-age-display {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .sidebar {
        max-width: 100%;
        padding: 1.5rem;
    }

    .sidebar-header {
        padding: 0 0 1.5rem 0;
    }

    .controls {
        padding: 0;
        gap: 1rem;
    }

    .control-group, .stats-panel {
        padding: 1rem;
    }

    .age-badge {
        font-size: 1.1rem;
    }

    .slider-labels {
        font-size: 0.75rem;
    }

    .sweden-flag {
        width: 50px;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 350px;
    }

    .sidebar-header h1 {
        font-size: 1.75rem;
    }
}

/* Large desktop */
@media (min-width: 1200px) {
    .sidebar {
        width: 450px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .form-range {
        min-height: 44px;
    }

    .btn-retry, .btn-debug {
        min-height: 44px;
        min-width: 44px;
    }

    .sidebar {
        padding-bottom: 2rem; /* Extra space for mobile browsers */
    }
}

/* High DPI screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sweden-flag {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
