/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #475569;
    --primary-hover: #334155;
    --secondary-color: #94a3b8;
    --success-color: #059669;
    --error-color: #dc2626;
    --background: #fafafa;
    --surface: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-md: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 1px 4px 0 rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 40px 20px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
        font-size: 2.5em;
        width: auto;
        height: auto;
    gap: 12px;
}

    font-size: 5rem;
}

/* Reduce layout shift for icon font: reserve space and provide safe fallbacks */
.material-symbols-outlined {
    font-family: 'Material Symbols Outlined', 'Segoe UI Symbol', 'Arial', sans-serif;
    display: inline-block;
    vertical-align: middle;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

    width: 3.5rem;
    height: 3.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 48px; /* Reserve space to prevent layout shift */
    min-width: 320px; /* Match dropdown min width for stability */
    box-sizing: border-box;
}

.filter-group label {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: fit-content;
}

select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

select:hover {
    border-color: var(--primary-color);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Custom Dropdown with Checkboxes */
.custom-dropdown {
    position: relative;
    width: 100%;
    min-width: 280px;
}

.dropdown-toggle {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.dropdown-toggle:hover {
    border-color: var(--primary-color);
}

.dropdown-toggle:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(71, 85, 105, 0.1);
}

.dropdown-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    line-height: 1.4;
}

/* Special handling for very long kommun names */
.dropdown-text:not(:has(+ .dropdown-arrow)):contains("Malung-Sälen") {
    white-space: normal;
}

.dropdown-arrow {
    margin-left: 8px;
    font-size: 0.75rem;
    transition: transform 0.2s;
}

.dropdown-toggle.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
}

.dropdown-menu.open {
    display: block;
}

.dropdown-search {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.dropdown-search input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
}

.dropdown-search input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.dropdown-options {
    max-height: 250px;
    overflow-y: auto;
}

.dropdown-option {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.15s;
}

.dropdown-option:hover {
    background: var(--background);
}

.dropdown-option input[type="checkbox"] {
    margin-right: 10px;
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.dropdown-option label {
    flex: 1;
    cursor: pointer;
    margin: 0;
    font-size: 0.95rem;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-primary:active {
    transform: none;
}

.btn-primary:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    background: var(--surface);
    border-radius: 4px;
    box-shadow: var(--shadow-md);
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error */
.error {
    padding: 15px 20px;
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: 4px;
    margin-bottom: 20px;
}

/* Warnings */
.warnings {
    margin-bottom: 20px;
}

.warning-message {
    padding: 12px 16px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-left: 4px solid #f59e0b;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.warning-message a {
    color: #1d4ed8;
    text-decoration: underline;
}

.warning-message a:hover {
    color: #1e40af;
}

.warning-message:last-child {
    margin-bottom: 0;
}

/* Info Messages */
.info-message {
    padding: 15px 20px;
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
    border-left: 4px solid #3b82f6;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Calendar View */
.calendar-view {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 20px;
    box-shadow: var(--shadow-md);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.calendar-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    text-align: center;
    flex: 1;
}

.week-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.week-dates {
    font-size: 0.95rem;
    font-weight: 400;
    color: var(--text-secondary);
}

.nav-btn {
    padding: 8px 16px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-btn:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--background);
    color: var(--text-secondary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
}

.day-column {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--background);
    transition: box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.day-column.today {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.day-header {
    background: var(--surface);
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.day-column.today .day-header {
    background: var(--primary-color);
    color: white;
}

.day-name {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.day-date {
    font-size: 0.9rem;
    margin-top: 2px;
    opacity: 0.8;
}

.day-events {
    padding: 8px;
}

.event-card {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 8px;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: default;
    position: relative;
    z-index: 1;
}

.event-card.dropdown-active {
    z-index: 1002;
}

.event-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.event-card:last-child {
    margin-bottom: 0;
}

.event-content {
    margin-bottom: 8px;
}

.event-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.share-event-btn,
.add-to-calendar-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    text-decoration: none;
}

.share-event-btn .material-symbols-outlined,
.add-to-calendar-btn .material-symbols-outlined {
    font-size: 20px;
}

.share-event-btn:hover,
.add-to-calendar-btn:hover {
    background: var(--background);
}

.share-notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    font-size: 0.9rem;
}

.share-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.calendar-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: 1001;
}

.calendar-dropdown a {
    display: block;
    padding: 10px 14px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.calendar-dropdown a:last-child {
    border-bottom: none;
}

.calendar-dropdown a:hover {
    background: var(--background);
    color: var(--primary-color);
}

.event-time {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.event-facility {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-bottom: 3px;
}

.event-facility-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 4px;
    font-weight: 500;
}

.event-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--background);
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    margin-top: 4px;
}

.event-kommun {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 4px;
}

.no-events {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.no-events.past-notice {
    font-style: italic;
    opacity: 0.7;
}

.day-column.past-day {
    opacity: 0.6;
}

/* Footer */
footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.last-updated {
    margin-top: 5px;
    font-size: 0.85rem;
}

/* Cookie Consent Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1f2937;
    color: #ffffff;
    padding: 20px;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.cookie-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cookie-content p {
    margin: 0;
    line-height: 1.5;
}

.cookie-content strong {
    color: #ffffff;
    font-weight: 600;
}

.cookie-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.cookie-banner .btn-primary,
.cookie-banner .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cookie-banner .btn-primary {
    background: var(--success-color);
    color: white;
}

.cookie-banner .btn-primary:hover {
    background: #047857;
}

.cookie-banner .btn-secondary {
    background: #374151;
    color: white;
}

.cookie-banner .btn-secondary:hover {
    background: #4b5563;
}

@media (min-width: 768px) {
    .cookie-content {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
    
    .cookie-buttons {
        flex-shrink: 0;
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .calendar-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .calendar-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group label {
        text-align: left;
    }

    .calendar-header {
        flex-direction: column;
        gap: 15px;
    }

    .calendar-header h2 {
        font-size: 1.2rem;
    }

    .list-event-item {
        flex-direction: column;
        gap: 8px;
    }

    .list-event-time {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .calendar-grid {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }
}
