:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

/* Dark Mode */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --danger-color: #f87171;
    --success-color: #4ade80;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.7);
}

[data-theme="dark"] .calendar-day-header {
    background-color: #0f172a;
}

[data-theme="dark"] .day-number.today {
    background: #1e3a8a;
}

[data-theme="dark"] .event-item {
    background-color: #1e3a8a;
}

[data-theme="dark"] .event-item:hover {
    background-color: #1e40af;
}

[data-theme="dark"] .list-event-date {
    background: #1e3a8a;
}

[data-theme="dark"] .btn-secondary {
    background-color: var(--surface-color);
}

.calendar-day.empty {
    background-color: #f8fafc;
}

[data-theme="dark"] .calendar-day.empty {
    background-color: #0a0f1e;
}

[data-theme="dark"] .list-event-item {
    background: var(--surface-color);
    border-color: var(--border-color);
}


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

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 3rem; /* Space for fixed footer */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-color);
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    border: none;
    font-size: 0.875rem;
}

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

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

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

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

/* Calendar Grid */
.calendar-container {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
}

.calendar-day-header {
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--background-color);
}

.calendar-day {
    min-height: 120px;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    position: relative;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.day-number {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
    color: var(--text-muted);
}

.day-number.today {
    color: var(--primary-color);
    background: #eff6ff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-item {
    background-color: #eff6ff;
    color: var(--primary-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-left: 3px solid var(--primary-color);
}

.event-item:hover {
    background-color: #dbeafe;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    flex: 1;
    text-align: left;
}

.modal-header .close-modal {
    margin-left: auto;
    flex-shrink: 0;
}

.modal-header:has(.day-nav-header) {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.modal-header .day-nav-header {
    width: 100%;
    margin-bottom: 1rem;
    position: relative;
    z-index: 10;
}

.modal-header .day-nav-header .btn {
    position: relative;
    z-index: 11;
    pointer-events: auto;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.modal-header .day-nav-header .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-header .day-nav-header .btn:not(.disabled) {
    cursor: pointer;
}

.modal-header .modal-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.modal-header .modal-title-row h3 {
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
}

.close-modal,
.close-delete-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.close-modal:hover,
.close-delete-modal:hover {
    color: var(--text-color);
}

/* Admin menu (cog button) */
.modal-admin-menu {
    position: relative;
}

.admin-menu-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
}

.admin-menu-toggle:hover {
    background-color: var(--primary-hover);
    transform: scale(1.1);
}

.admin-menu-toggle.active {
    background-color: var(--primary-hover);
}

.admin-menu-items {
    position: fixed;
    bottom: 70px;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 1001;
    animation: slideUp 0.2s ease-out;
}

.admin-menu-items .btn {
    pointer-events: auto;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    min-width: 44px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-menu-items .btn {
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

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

/* Form Styling */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
    background-color: var(--surface-color);
    color: var(--text-color);
}

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

[data-theme="dark"] .form-control {
    background-color: var(--surface-color);
    color: var(--text-color);
    border-color: var(--border-color);
    color-scheme: dark;
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

[data-theme="dark"] .form-control:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Make date and time input icons white in dark mode */
[data-theme="dark"] input[type="date"].form-control,
[data-theme="dark"] input[type="time"].form-control,
[data-theme="dark"] input[type="datetime-local"].form-control {
    color-scheme: dark;
}

/* Webkit browsers (Chrome, Safari, Edge) */
[data-theme="dark"] input[type="date"].form-control::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"].form-control::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"].form-control::-webkit-calendar-picker-indicator {
    filter: invert(1) brightness(1.5);
    cursor: pointer;
    opacity: 1 !important;
}

/* Firefox date/time input styling */
[data-theme="dark"] input[type="date"].form-control::-moz-calendar-picker-indicator,
[data-theme="dark"] input[type="time"].form-control::-moz-calendar-picker-indicator {
    filter: invert(1) brightness(1.5);
    cursor: pointer;
}

/* Ensure the input itself uses dark color scheme */
[data-theme="dark"] .form-control[type="date"],
[data-theme="dark"] .form-control[type="time"],
[data-theme="dark"] .form-control[type="datetime-local"] {
    color-scheme: dark;
}

[data-theme="dark"] small.text-muted {
    color: var(--text-muted);
}

#map-picker {
    height: 300px;
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
}

#event-map {
    height: 300px;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    border: 1px solid var(--border-color);
}

/* Utilities */
.text-muted {
    color: var(--text-muted);
}

.mb-4 {
    margin-bottom: 1rem;
}

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.items-center {
    align-items: center;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
    align-items: flex-start;
}

/* Footer */
footer.page-footer,
.page-footer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    text-align: center !important;
    padding: 0.75rem 1rem !important;
    border-top: 1px solid var(--border-color) !important;
    background-color: var(--surface-color) !important;
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
    z-index: 1000 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

footer.page-footer p,
.page-footer p {
    margin: 0 !important;
    padding: 0 !important;
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
}

footer.page-footer .heart,
.page-footer .heart {
    display: inline-block !important;
    color: var(--text-muted) !important;
    filter: grayscale(100%) brightness(0.8) !important;
    animation: heartbeat 1.5s ease-in-out infinite !important;
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    10%, 30% {
        transform: scale(1.1);
    }
    20%, 40% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
}

    .calendar-header {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-controls h2 {
        font-size: 1.25rem;
    }

    .calendar-day {
        min-height: 60px;
        padding: 0.25rem;
    }

    .calendar-day-header {
        font-size: 0.7rem;
        padding: 0.25rem;
    }

    .day-number {
        font-size: 0.875rem;
        margin-bottom: 0.25rem;
    }

    /* Mobile: show event count badge instead of individual dots */
    .event-item {
        display: none;
    }

    .calendar-day.has-events::after {
        content: attr(data-event-count);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: var(--primary-color);
        color: white;
        border-radius: 50%;
        width: 26px;
        height: 26px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.75rem;
        font-weight: 700;
        cursor: pointer;
    }

    [data-theme="dark"] .calendar-day.has-events::after {
        background: #3b82f6;
        box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
    }

    /* Stack date/time fields vertically on mobile */
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
    }

    div[style*="grid-template-columns: 1fr 1fr 1fr"] .form-group {
        margin-bottom: 1.5rem !important;
    }
}

/* Header Controls */
.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.view-controls {
    display: flex;
    gap: 0.5rem;
}

/* List View */
.list-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
}

.list-event-item {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: box-shadow 0.2s;
    cursor: pointer;
}

.list-event-item:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

/* Day modal event list (mobile) */
.day-events-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.day-events-list .list-event-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    gap: 0.25rem;
}

.day-events-list .list-event-time {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.day-events-list .list-event-address {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-color);
}

.day-events-list .list-event-notes {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.list-event-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    margin-right: 1.5rem;
    min-width: 80px;
}

.list-event-day {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.list-event-month {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
}

.list-event-details {
    flex: 1;
}

.list-event-time {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.list-event-address {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-color);
}

.list-event-notes {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* Prevent map scroll hijacking */
#map-picker,
#event-map {
    cursor: pointer;
    position: relative;
}

#map-picker::before,
#event-map::before {
    content: 'Click to interact with map';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    z-index: 400;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.leaflet-container:not(.leaflet-scroll-zoomed)#map-picker::before,
.leaflet-container:not(.leaflet-scroll-zoomed)#event-map::before {
    opacity: 1;
}