/* ===== CSS Custom Properties (Theming) ===== */

:root, [data-theme="light"] {
    --bg-primary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --table-stripe: #f1f5f9;
    --nav-bg: #ffffff;
    --league-title-bg: #1e293b;
    --league-title-text: #ffffff;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --table-stripe: #263548;
    --nav-bg: #1e293b;
    --league-title-bg: #0f172a;
    --league-title-text: #e2e8f0;
}

/* ===== Base Styles ===== */

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent);
}

/* ===== Headings ===== */

h2, h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ===== Container ===== */

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

/* ===== Navigation Bar ===== */

.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.nav-left,
.nav-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-center {
    display: flex;
    gap: 6px;
    align-items: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.nav-brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-primary);
    text-decoration: none;
    margin-right: 8px;
}

.nav-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ===== Cards and Boxes ===== */

.form-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    max-width: 480px;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.event-meta {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

/* ===== Tables ===== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.data-table th {
    background: var(--league-title-bg);
    color: var(--league-title-text);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:nth-child(even) {
    background: var(--table-stripe);
}

.data-table tbody tr:hover {
    background: var(--accent);
    color: white;
    transition: 0.15s;
}

/* ===== League Grid ===== */

.league-scroll-top {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    height: 12px;
    margin-bottom: 4px;
    border: none;
    background: transparent;
    cursor: grab;
    border-radius: 4px;
    outline: none;
}

.league-scroll-spacer {
    height: 1px;
}

.league-scroll {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    cursor: grab;
    outline: none;
}

/* Custom scrollbar styling — horizontal */
.league-scroll-top::-webkit-scrollbar,
.league-scroll::-webkit-scrollbar {
    height: 6px;
}

.league-scroll-top::-webkit-scrollbar-track,
.league-scroll::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 3px;
}

.league-scroll-top::-webkit-scrollbar-thumb,
.league-scroll::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.league-scroll-top::-webkit-scrollbar-thumb:hover,
.league-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

/* Custom scrollbar styling — vertical (league table wrappers) */
.league-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.league-table-wrapper::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 3px;
}

.league-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.league-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}

.league-table-wrapper {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-card);
}

/* Firefox scrollbar — horizontal */
.league-scroll-top,
.league-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-card);
}

.league-scroll.dragging,
.league-scroll-top.dragging {
    cursor: grabbing;
    user-select: none;
}

.league-scroll:focus,
.league-scroll-top:focus {
    outline: none;
}

.league-grid {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: max-content;
}

.league-card {
    width: 700px;
    flex: 0 0 700px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 120px);
}

.league-title {
    background: var(--league-title-bg);
    color: var(--league-title-text);
    padding: 14px 16px;
    font-weight: 700;
    min-height: 58px;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.league-title span {
    display: block;
    font-size: 12px;
    font-weight: normal;
    opacity: 0.8;
    margin-top: 4px;
}

.league-table-wrapper {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.league-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.league-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.league-table th {
    text-align: left;
    background: var(--table-stripe);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.league-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-color);
}

.league-table td.place {
    text-align: center;
    width: 42px;
    font-weight: bold;
}

.league-table td.date {
    width: 82px;
    text-align: center;
    white-space: nowrap;
}

.league-table td.name {
    min-width: 140px;
    white-space: nowrap;
}

.league-table td.club {
    min-width: 140px;
    white-space: nowrap;
}

.league-table td.value {
    width: 70px;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
}

.league-table td.remarks {
    min-width: 80px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Forms ===== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-inline {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

/* ===== Buttons ===== */

.btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
}

/* ===== Alerts ===== */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #6ee7b7;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

[data-theme="dark"] .alert-success {
    background: #064e3b;
    border-color: #065f46;
    color: #a7f3d0;
}

[data-theme="dark"] .alert-error {
    background: #450a0a;
    border-color: #991b1b;
    color: #fca5a5;
}

/* ===== Utility Classes ===== */

.hidden {
    display: none;
}

.small {
    font-size: 13px;
    color: var(--text-secondary);
}

.status-line {
    margin: 10px 0;
    font-weight: bold;
    color: var(--text-secondary);
}

/* ===== Textarea (Debug) ===== */

textarea {
    width: 100%;
    min-height: 180px;
    box-sizing: border-box;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
}

/* ===== Transitions (Theme Switching) ===== */

body,
.navbar,
.league-card,
.data-table,
.form-card {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
    /* Safety net: nothing should push the whole page sideways on mobile */
    html, body {
        overflow-x: hidden;
    }

    .container {
        padding: 12px;
        max-width: 100%;
    }

    .navbar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }

    /* Let every nav section wrap instead of overflowing the screen */
    .nav-left,
    .nav-right {
        flex-wrap: wrap;
    }

    /* Drop absolute centering on mobile so the switcher flows in normally */
    .nav-center {
        position: static;
        transform: none;
        left: auto;
        flex-wrap: wrap;
        width: 100%;
    }

    /* Keep dropdowns within the viewport */
    .nav-year-select {
        max-width: 100%;
    }

    .stats-year-form {
        flex-wrap: wrap;
        max-width: 100%;
    }

    .stats-year-form select,
    .form-inline select,
    select.nav-btn {
        max-width: 100%;
    }

    /* Long event names in the per-event dropdown must not push past the edge */
    .stats-year-form select {
        flex: 1 1 auto;
        min-width: 0;
        text-overflow: ellipsis;
    }

    .form-inline {
        flex-direction: column;
    }

    .form-card {
        max-width: 100%;
    }

    .map-header {
        flex-wrap: wrap;
    }

    .map-container {
        height: 70vh;
    }

    /* Wide tables scroll inside their own frame instead of stretching the page */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-scroll .data-table {
        min-width: 640px;
    }

    /* Home league cards: fit the screen, let the table scroll internally */
    .league-tabs .league-card {
        width: 100%;
        max-width: 100%;
    }

    .league-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .league-table {
        min-width: 640px;
    }

    /* Communications page header wraps on narrow screens */
    .comm-header {
        flex-wrap: wrap;
    }
}

/* Generic horizontal scroll wrapper for wide tables */
.table-scroll {
    width: 100%;
}

/* ===== Event Actions ===== */

.event-actions {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.edit-panel {
    display: inline-block;
}

.edit-panel summary {
    cursor: pointer;
    list-style: none;
}

.edit-panel summary::-webkit-details-marker {
    display: none;
}

.edit-panel[open] summary {
    margin-bottom: 0;
}

/* ===== Inline Edit Inputs ===== */

.edit-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    box-sizing: border-box;
}

.edit-input:focus {
    border-color: var(--accent);
    outline: none;
}

.edit-input-sm {
    width: 80px;
}

/* ===== Statistics Page ===== */

.stats-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 0;
}

.stats-hero {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 48px 64px;
    margin-bottom: 40px;
}

.stats-number {
    font-size: 96px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 12px;
}

.stats-sublabel {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-label {
    font-size: 20px;
    color: var(--text-secondary);
}

.stats-breakdown {
    width: 100%;
    max-width: 600px;
}

.stats-breakdown h3 {
    text-align: center;
    margin-bottom: 12px;
}

.stats-year-form {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.stats-year-form select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 14px;
}

/* ===== Year Selector in Navbar ===== */

.nav-year-select {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 28px 8px 14px;
    background: var(--bg-card) 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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
}

.nav-year-select:hover {
    background: var(--accent) 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='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
    color: white;
    border-color: var(--accent);
}

[data-theme="dark"] .nav-year-select {
    background: var(--bg-card) 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='%23aaa' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
}

[data-theme="dark"] .nav-year-select:hover {
    background: var(--accent) 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='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 10px center;
}

/* ===== Settings Page ===== */

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 12px;
}

.setting-info {
    flex: 1;
}

.setting-label {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.setting-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.toggle-label-on,
.toggle-label-off {
    font-size: 13px;
    color: var(--text-secondary);
}

.toggle-switch input:checked ~ .toggle-label-off {
    display: none;
}

.toggle-switch input:not(:checked) ~ .toggle-label-on {
    display: none;
}

.setting-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== Settings Cards ===== */

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 16px;
}

.settings-card-title {
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.settings-card .setting-row {
    border: none;
    border-radius: 0;
    padding: 12px 0;
    margin-bottom: 0;
    background: transparent;
}

.settings-card .setting-row + .setting-row {
    border-top: 1px solid var(--border-color);
}

/* ===== Settings Section Tabs ===== */

.settings-tabs {
    width: 100%;
}

.settings-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.settings-tab {
    padding: 10px 18px;
    border: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.settings-tab:hover {
    color: var(--text-primary);
    background: var(--table-stripe);
}

.settings-tab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.settings-tab-panel {
    display: none;
}

.settings-tab-panel.active {
    display: block;
}

/* Google Sheets sync links */
.sync-link-group {
    padding: 10px 0;
    border-top: 1px dashed var(--border-color);
}

.sync-link-group:first-of-type {
    border-top: none;
}

.sync-link-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin: 8px 0 2px;
}

.sync-link-input {
    width: 100%;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
}

/* ===== League Tabs ===== */

.league-tabs {
    width: 100%;
}

.league-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.league-tab {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px 8px 0 0;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.league-tab:hover {
    color: var(--text-primary);
    background: var(--table-stripe);
}

.league-tab.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    background: var(--bg-card);
}

.league-tab-panel {
    display: none;
}

.league-tab-panel.active {
    display: block;
}

.league-tabs .league-card {
    width: 100%;
    flex: none;
    max-height: none;
}

.league-table tbody tr:hover {
    background: var(--table-stripe);
    transition: background 0.15s;
}

/* ===== General Mode Bar ===== */

.nav-mode-active {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
}

/* ===== Map Page ===== */

.map-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.map-header h2 {
    margin-bottom: 0;
}

.map-container {
    width: 100%;
    height: calc(100vh - 180px);
    min-height: 60vh;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.leaflet-container {
    background: var(--bg-card);
}

/* ===== Map Assign (autocomplete) ===== */

.loc-cell {
    position: relative;
}

.loc-current {
    margin-right: 8px;
}

.loc-search {
    margin-top: 8px;
    position: relative;
}

.loc-search .loc-input {
    width: 260px;
}

.loc-results {
    position: absolute;
    z-index: 20;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
    margin-top: 2px;
}

.loc-results.loc-results-up {
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 2px;
}

.loc-result-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
}

.loc-result-item:last-child {
    border-bottom: none;
}

.loc-result-item:hover {
    background: var(--accent);
    color: white;
}

.loc-loading,
.loc-empty {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.loc-search-inline {
    position: relative;
}

.stats-map-line {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.stats-map-line:first-of-type {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ===== Stats Top (two columns: farthest / nearest) ===== */

.stats-top-grid {
    display: flex;
    gap: 32px;
    justify-content: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    text-align: left;
}

.stats-top-col {
    min-width: 180px;
}

.stats-top-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-align: center;
}

.stats-top-list {
    margin: 0;
    padding-left: 22px;
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.stats-top-list.stats-top-plain {
    list-style: none;
    padding-left: 0;
    text-align: center;
}

@media (max-width: 768px) {
    .stats-top-grid {
        gap: 20px;
    }

    .stats-top-col {
        min-width: 0;
        flex: 1 1 0;
    }
}

/* ===== Segmented Control ===== */

.segmented {
    display: inline-flex;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-primary);
}

.segmented input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.segmented label {
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    border-right: 1px solid var(--border-color);
    user-select: none;
}

.segmented label:last-of-type {
    border-right: none;
}

.segmented input[type="radio"]:checked + label {
    background: var(--accent);
    color: white;
}

.segmented input[type="radio"]:disabled + label {
    cursor: not-allowed;
}

/* ===== Fixed Footer (bottom of screen) ===== */

body {
    padding-bottom: 34px; /* room for the fixed footer */
}

.site-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    text-align: center;
    padding: 6px 16px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.site-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* ===== Content Page (privacy etc.) ===== */

.content-page {
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px 22px;
    box-shadow: var(--shadow);
    line-height: 1.5;
    font-size: 13px;
}

.content-page h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

.content-page h3 {
    margin-top: 16px;
    margin-bottom: 4px;
    font-size: 14px;
}

.content-page p {
    color: var(--text-secondary);
    margin: 0 0 8px;
}

.privacy-owner {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ===== Calendar ===== */

.calendar-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.calendar-header h2 {
    margin-bottom: 0;
}

.calendar-section-title {
    margin: 24px 0 12px;
    font-size: 18px;
    color: var(--text-primary);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

/* Blok sekcji (nagłówek + filtr lat + karuzela) */
.calendar-block {
    margin-bottom: 28px;
}

.calendar-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.calendar-block-head .calendar-section-title {
    margin: 0;
}

/* Przyciski filtra lat */
.calendar-years {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.calendar-year-btn {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: all 0.15s;
}

.calendar-year-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.calendar-year-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Karuzela: poziomy scroll ze snapowaniem (swipe na dotyku i myszce) */
/* ===== Karuzela (loop + auto + drag + strzałki + pauza) ===== */
.carousel {
    position: relative;
    padding: 0 40px; /* miejsce na strzałki po bokach */
}

.carousel-viewport {
    overflow: hidden;
    width: 100%;
    cursor: grab;
}

.carousel.carousel-dragging .carousel-viewport {
    cursor: grabbing;
}

.carousel-track {
    display: flex;
    gap: 16px;
    will-change: transform;
    user-select: none;
}

/* Karta w karuzeli — stała szerokość, nie kurczy się */
.carousel-track .calendar-card {
    flex: 0 0 260px;
}

/* Karuzela śpiąca (mało kafelków) — statyczny rząd, bez przewijania */
.carousel.carousel-static {
    padding: 0;
}
.carousel.carousel-static .carousel-viewport {
    cursor: default;
}
.carousel.carousel-static .carousel-track {
    flex-wrap: wrap;
}

/* Przyciski nawigacji */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.carousel-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.carousel-prev { left: 0; }
.carousel-next { right: 0; }

.carousel-toggle {
    position: absolute;
    top: 8px;
    right: 48px; /* w prawym górnym rogu okna, obok (nie na) strzałki next */
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
}

.carousel-toggle:hover {
    opacity: 1;
    color: var(--accent);
    border-color: var(--accent);
}

.calendar-empty {
    color: var(--text-secondary);
    font-style: italic;
    padding: 8px 0 4px;
}

/* Inline edycja nazwy minionego (admin) */
.label-edit-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.label-edit-form .edit-input {
    min-width: 140px;
}

.calendar-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.calendar-card-upcoming {
    border-left: 4px solid var(--accent);
}

.calendar-card-past {
    opacity: 0.92;
}

.calendar-card-date {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.calendar-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.calendar-card-place {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Slot bar (upcoming) */
.slot-bar {
    width: 100%;
    height: 10px;
    background: var(--table-stripe);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 8px;
}

.slot-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease, background-color 0.4s ease;
}

.slot-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

.slot-count {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
}

.slot-free {
    font-size: 13px;
    font-weight: 600;
}

/* Attendees (past) */
.calendar-attendees {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 8px;
}

.calendar-attendees-num {
    font-size: 32px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.calendar-attendees-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.calendar-card-reg {
    margin-top: 10px;
    font-size: 13px;
    text-decoration: none;
    color: var(--accent);
}

.calendar-card-reg:hover {
    text-decoration: underline;
}

.calendar-alert {
    display: inline-block;
    margin-top: 4px;
    font-size: 12px;
    color: #b45309;
    font-weight: 600;
}

[data-theme="dark"] .calendar-alert {
    color: #fbbf24;
}
