*,
*::before,
*::after {
    box-sizing: border-box;
}

/* --- Disable native pull-to-refresh & allow conditional scroll locking --- */
html,
body {
    overscroll-behavior-y: contain;
}

/* When map is active, lock the body scroll to prevent double scrollbars */
body.map-view-active {
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    overflow-x: hidden;
}

/* --- Pull to Refresh Indicator Styles --- */
#pull-to-refresh-indicator {
    position: fixed;
    top: -50px;
    left: 0;
    right: 0;
    height: 50px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 1080;
    transition: top 0.2s ease-out;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    color: #333;
    font-weight: bold;
}

.ptr-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #ced4da;
    border-top-color: #007bff;
    border-radius: 50%;
    transition: transform 0.3s;
}

#pull-to-refresh-indicator.refreshing .ptr-spinner {
    animation: spin 1s linear infinite;
}

header {
    background-color: #007bff;
    color: white;
    padding: 0 2rem;
    min-height: 64px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1010;
    flex-shrink: 0;
    /* Don't shrink header in map view */
}

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

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.desktop-user-nav .user-info {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info .header-link {
    color: #fff;
    text-decoration: underline;
}

.header-btn {
    background-color: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    text-decoration: none;
}

.header-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.notification-area {
    position: relative;
    display: inline-block;
}

.notification-btn {
    position: relative;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-indicator {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background-color: #dc3545;
    border-radius: 50%;
    border: 2px solid white;
}

.notification-panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background-color: white;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 350px;
    z-index: 1020;
    overflow: hidden;
}

.notification-panel.open {
    display: block;
}

.notification-panel-header {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.notification-actions button {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 10px;
    padding: 0;
}

.notification-actions button:hover {
    text-decoration: underline;
}

.notification-list {
    max-height: 400px;
    overflow-y: auto;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s;
}

.notification-item.unread {
    background-color: #f8f9fa;
    cursor: pointer;
}

.notification-item.unread:hover {
    background-color: #e9ecef;
}

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

.notification-item-title {
    font-weight: bold;
    margin-bottom: 5px;
    pointer-events: none;
}

.notification-item-body {
    margin-bottom: 8px;
    color: #555;
    font-size: 0.95rem;
    pointer-events: none;
}

.notification-item-time {
    font-size: 0.8rem;
    color: #888;
    align-self: flex-end;
    pointer-events: none;
}

.notification-list .no-notifications {
    padding: 2rem;
    text-align: center;
    color: #777;
}

/* Mobile Notification Styles */
.mobile-close-btn {
    display: none;
    /* Hidden by default on desktop */
}

@media (max-width: 600px) {
    .notification-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        margin-top: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        z-index: 2000;
        /* Ensure it covers everything */
        flex-direction: column;
        display: none;
        /* Hidden by default */
    }

    .notification-panel.open {
        display: flex;
        /* Override to flex for full screen layout */
    }

    .notification-list {
        flex-grow: 1;
        max-height: none;
    }

    .notification-panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding-right: 50px;
        /* Space for the close button */
        position: relative;
    }

    .notification-actions {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        gap: 20px;
    }

    .notification-actions button {
        margin-left: 0;
        font-size: 0.9rem;
    }

    .mobile-close-btn {
        display: block;
        position: absolute;
        top: 10px;
        right: 15px;
        background: transparent;
        border: none;
        font-size: 2.5rem;
        line-height: 0.8;
        color: #333;
        cursor: pointer;
        padding: 5px;
        z-index: 2001;
    }
}

.controls-bar {
    padding: 1rem;
    background-color: #f8f9fa;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
    /* Don't shrink bar in map view */
}

/* Map View Controls Toggle (Global) */
body.map-view-active .controls-bar {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 1002;
    background: #f0f2f5;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #ddd;
    transform: translateY(-200%);
    transition: transform 0.3s ease-in-out;
}

body.map-view-active .controls-bar.open {
    transform: translateY(0);
}

.view-toggle button,
.desktop-filters-btn,
#toggle-filters-btn-mobile,
.refresh-data-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    margin: 0 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.view-toggle button:hover,
.desktop-filters-btn:hover,
#toggle-filters-btn-mobile:hover,
.refresh-data-btn:hover {
    background-color: #5a6268;
}

.view-toggle button.active,
.desktop-filters-btn.active,
#toggle-filters-btn-mobile.active {
    background-color: #007bff;
    font-weight: bold;
}

.filter-modal {
    display: none;
    position: fixed;
    z-index: 1070;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

.filter-modal.open {
    display: flex;
}

.filter-panel {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
}

.filter-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

#close-filters-btn {
    background: none;
    border: none;
    font-size: 2.5rem;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    line-height: 1;
}

.filter-content {
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.filter-section {
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
}

.filter-section:not(:last-child) {
    border-bottom: 1px solid #eee;
}

.filter-section>label {
    font-weight: bold;
    color: #333;
    padding-left: 5px;
}

.filter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-start;
    width: 100%;
}

.filter-btn {
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 20px;
    background-color: #808080;
    color: #e6e6e6;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    font-size: 0.95em;
}

.filter-btn:hover {
    background-color: #707070;
}

.filter-btn.selected {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
    font-weight: bold;
}

.filter-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #dee2e6;
    text-align: right;
    flex-shrink: 0;
    background-color: #f8f9fa;
}

#apply-filters-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
}

#apply-filters-btn:hover {
    background-color: #0056b3;
}

/* --- Map Container Styles (REQUIRED for Leaflet) --- */
#map-view-container {
    width: 100%;
    /* Default height is needed for Leaflet initialization even if hidden initially */
    height: calc(100vh - 140px);
    display: none;
    z-index: 1;
    background-color: #e9ecef;
    /* Placeholder color */
}

/* When map is active, allow it to fill the flex container defined on body */
body.map-view-active #map-view-container {
    display: block;
    flex-grow: 1;
    height: auto;
    min-height: 0;
}

/* Ensure no trailing space in map view */
body.map-view-active main,
body.map-view-active footer {
    display: none;
}

main {
    padding: 0 20px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 50px;
    color: #555;
    font-size: 1.2em;
}

.loader-spinner {
    border: 8px solid #e0e0e0;
    border-top: 8px solid #007bff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
    margin-bottom: 20px;
}

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

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

.park-section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
    padding: 20px;
}

.park-section h2,
.park-table-section h2 {
    color: #0056b3;
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 20px;
    cursor: pointer;
    position: relative;
    user-select: none;
    padding-right: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.park-header-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    width: 100%;
}

.park-header-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}

.park-hours {
    font-size: 0.75rem;
    font-weight: 500;
    color: #495047;
    background-color: #e9ecef;
    padding: 4px 8px;
    border-radius: 10px;
    margin-left: 10px;
    white-space: nowrap;
}

.park-extra-info {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
    font-size: 0.9rem;
}

.park-info-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.75em;
    white-space: nowrap;
}

.park-info-badge.early-entry {
    background-color: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.park-info-badge.ticketed-event {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.park-section h2::after,
.park-table-section h2::after {
    content: '▲';
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
    transition: transform 0.2s ease-in-out;
}

.park-section.collapsed h2::after,
.park-table-section.collapsed h2::after {
    transform: translateY(-50%) rotate(180deg);
}

.park-section.collapsed .rides-grid,
.park-table-section.collapsed>table {
    display: none;
}

.rides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.ride-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    cursor: pointer;
    overflow: hidden;
}

.ride-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.ride-item-main {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.ride-item-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.ride-title {
    margin: 0;
    font-size: 1.1em;
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ride-wait-time {
    font-weight: bold;
    font-size: 1.1em;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 5px 8px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
}

.ride-wait-time .distance-info {
    font-size: 0.8em;
    font-weight: normal;
    color: #555;
    margin-top: 2px;
}

.low-wait .ride-wait-time {
    background-color: #d4edda;
    color: #155724;
}

.medium-wait .ride-wait-time {
    background-color: #fff3cd;
    color: #856404;
}

.high-wait .ride-wait-time {
    background-color: #f8d7da;
    color: #721c24;
}

.no-wait-info .ride-wait-time {
    background-color: #e2e3e5;
    color: #383d41;
}

.closed .ride-wait-time,
.down .ride-wait-time,
.refurbishment .ride-wait-time {
    background-color: transparent;
    color: inherit;
}

.show-times .ride-wait-time {
    background-color: #d1ecf1;
    color: #0c5460;
    font-size: 0.9em;
    white-space: normal;
    text-align: right;
    line-height: 1.4;
    flex-shrink: 1;
    flex-direction: row;
    flex-wrap: wrap;
}

.ride-item.operating {
    border-left: 5px solid #28a745;
}

.ride-item.closed {
    border-left: 5px solid #dc3545;
    background-color: #ffebeb;
}

.ride-item.down {
    border-left: 5px solid #ffc107;
    background-color: #fff8e1;
}

.ride-item.refurbishment {
    border-left: 5px solid #6c757d;
    background-color: #e9ecef;
}

.set-alert-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    margin-left: 10px;
}

.set-alert-btn:hover {
    background-color: #0056b3;
}

.set-alert-btn.alert-is-set {
    background-color: #ffc107;
    color: #333;
}

.set-alert-btn.alert-is-set:hover {
    background-color: #e0a800;
}

.log-visit-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    background-color: #17a2b8;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    margin-left: 10px;
}

.log-visit-btn:hover {
    background-color: #138496;
}

.log-visit-btn-table {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #17a2b8;
    background-color: white;
    color: #17a2b8;
    cursor: pointer;
    margin-left: 5px;
}

.log-visit-btn-table:hover {
    background-color: #e2f4f7;
}

/* --- Added History Button Styles --- */
.history-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    background-color: #6c757d;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    margin-left: 10px;
}

.history-btn:hover {
    background-color: #5a6268;
}

.details-btn {
    background-color: #6f42c1;
    color: white;
}

.details-btn:hover {
    background-color: #5a32a3;
}

/* Card main Info button styling */
.ride-item-main .details-btn {
    font-size: 0.75em;
    padding: 3px 8px;
    margin-left: 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* Table specific override for history button */
.park-table-section .history-btn {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #6c757d;
    background-color: white;
    color: #6c757d;
    margin-left: 5px;
}

.park-table-section .history-btn:hover {
    background-color: #e2e6ea;
}

/* --- Ride Logo Styles --- */

/* Shared inline logo - sits beside the ride title text */
.ride-logo-inline {
    height: 24px;
    width: auto;
    max-width: 72px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 6px;
    border-radius: 3px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
    flex-shrink: 0;
    display: inline-block;
}

/* Map popup: slightly taller since the popup h4 is larger */
.ride-logo-popup {
    height: 28px;
    max-width: 80px;
}

/* Table view: same inline class, slight tweak for table context */
.ride-logo-table {
    height: 30px;
    width: auto;
    max-width: 72px;
    object-fit: contain;
    vertical-align: middle;
    margin-right: 8px;
    border-radius: 3px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.12));
    flex-shrink: 0;
}

/* Make the table name cell a flex container so logo + text line up */
td[data-label="Attraction"] {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

td[data-label="Attraction"] span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* Mobile: shrink logos slightly */
@media (max-width: 600px) {
    .ride-logo-inline {
        height: 20px;
        max-width: 60px;
    }

    td[data-label="Attraction"] {
        flex-wrap: wrap;
        gap: 4px;
    }

    .ride-logo-table {
        height: 24px;
        max-width: 56px;
    }
}


.park-summary-marker {
    background: none !important;
    border: none !important;
}

.park-marker-pill {
    background-color: #007bff;
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    border: 2px solid white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    width: max-content;
    max-width: 220px;
    transform: translate(-50%, -50%);
}

.park-marker-pill:hover {
    transform: translate(-50%, -50%) scale(1.05);
    background-color: #0056b3;
}

.park-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.park-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: bold;
    font-family: sans-serif;
    font-size: 13px;
}

.park-section h2 .log-park-visit-btn,
.park-table-section h2 .log-park-visit-btn {
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
    background-color: #17a2b8;
    padding: 4px 10px;
    border-radius: 10px;
    margin-left: 10px;
    white-space: nowrap;
    border: none;
    cursor: pointer;
}

.park-section h2 .log-park-visit-btn:hover,
.park-table-section h2 .log-park-visit-btn:hover {
    background-color: #138496;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1090;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    -webkit-tap-highlight-color: transparent;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
    text-align: center;
    position: relative;
}

#log-visit-form {
    text-align: left;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#log-visit-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

#log-visit-form label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #555;
    font-size: 0.9em;
}

#log-visit-form input,
#log-visit-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}

#log-visit-form .status-message {
    text-align: center;
    margin-top: 0.5rem;
    font-weight: bold;
    min-height: 1.2em;
}

#pwa-install-modal .modal-content {
    text-align: left;
    padding: 30px;
}

#pwa-install-modal h2 {
    text-align: center;
    margin-top: 0;
}

#pwa-install-modal p {
    line-height: 1.6;
    margin-bottom: 20px;
}

#install-instructions {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    margin: 20px 0;
}

#install-instructions p {
    margin: 0 0 10px 0;
}

#install-instructions strong {
    color: #0056b3;
}

.close-btn {
    color: #6c757d;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 2.5rem;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover,
.close-btn:focus {
    color: black;
}

.wait-time-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
}

.wait-time-btn {
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    background-color: #e0e0e0;
    color: #000000;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

.wait-time-btn:hover {
    background-color: #474849;
    border-color: #999;
}

.wait-time-btn:disabled {
    background-color: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
    text-decoration: line-through;
}

.wait-time-btn.selected {
    background-color: #007bff;
    color: white;
    border-color: #0056b3;
    font-weight: bold;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.modal-content button,
.danger-btn,
.modal-action-btn {
    padding: 12px 25px;
    font-size: 1.1em;
    border: none;
    border-radius: 5px;
    color: white;
    cursor: pointer;
}

.modal-content form button[type="submit"] {
    background-color: #28a745;
}

.modal-content form button[type="submit"]:disabled {
    background-color: #999;
    cursor: not-allowed;
}

.danger-btn {
    background-color: #dc3545;
}

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

.modal-action-btn {
    background-color: #007bff;
}

.modal-action-btn:hover {
    background-color: #0056b3;
}

.filter-action-btn {
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-action-btn:hover {
    background-color: #dee2e6;
    border-color: #adb5bd;
}

.filter-action-btn.reset-btn {
    background-color: #6c757d;
    color: white;
}

.filter-action-btn.reset-btn:hover {
    background-color: #5a6268;
}

.modal-divider {
    border: 0;
    border-top: 1px solid #eee;
    margin: 25px 0;
}

.alert-option-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

#table-parks-container {
    max-width: 1200px;
    margin: 0 auto 20px;
}

.park-table-section {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    margin-bottom: 15px;
    padding: 20px;
    overflow-x: auto;
}

.park-table-section table {
    width: 100%;
    border-collapse: collapse;
}

.park-table-section th,
.park-table-section td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.park-table-section th {
    background-color: #007bff;
    color: white;
    font-weight: bold;
    cursor: pointer;
    position: relative;
}

.park-table-section th:hover {
    background-color: #0056b3;
}

.park-table-section th .sort-arrow {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
}

.park-table-section tbody tr:nth-child(even) {
    background-color: #f8f8f8;
}

.park-table-section tbody tr:hover {
    background-color: #eef;
}

.set-alert-btn-table {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #007bff;
    background-color: white;
    color: #007bff;
    cursor: pointer;
}

.set-alert-btn-table.alert-is-set {
    background-color: #ffc107;
    border-color: #e0a800;
    color: #333;
}

.table-actions-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

#all-alerts-list {
    margin-top: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.alert-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #eee;
}

.alert-list-item.global-alert-item {
    background-color: #f8f9fa;
    border-left: 4px solid #17a2b8;
}

.alert-list-item:last-child {
    border-bottom: none;
}

.alert-item-name {
    font-weight: bold;
}

.alert-item-condition {
    color: #555;
}

.alert-item-controls button {
    margin-left: 8px;
    padding: 4px 8px;
    font-size: 0.9em;
    border-radius: 4px;
    cursor: pointer;
}

.alert-item-controls .edit-btn {
    border: 1px solid #007bff;
    background: #fff;
    color: #007bff;
}

.alert-item-controls .delete-btn {
    border: 1px solid #dc3545;
    background: #fff;
    color: #dc3545;
}

#settings-content {
    margin-top: 20px;
    text-align: left;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
}

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

.setting-item label {
    font-size: 1.1em;
    color: #333;
}

.setting-item input[type="checkbox"] {
    transform: scale(1.5);
    cursor: pointer;
}

.setting-item-child {
    padding-left: 25px;
    padding-top: 15px;
}

.setting-item-child>label {
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
}

footer {
    text-align: center;
    color: #777;
    font-size: 0.9em;
}

.refresh-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.last-updated-display {
    font-size: 0.85em;
    color: #6c757d;
    text-align: center;
    line-height: 1.2;
}

.refresh-data-btn svg {
    transition: transform 0.3s ease;
}

.refresh-data-btn.refreshing svg {
    animation: spin 1s linear infinite;
}

#manual-refresh-btn-mobile,
#manual-refresh-btn-desktop {
    width: 38px;
    height: 38px;
    padding: 8px;
    margin: 0;
}

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.auth-form {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.auth-form h2 {
    text-align: center;
    color: #0056b3;
    margin-top: 0;
    margin-bottom: 25px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #007bff;
}

.auth-form button[type="submit"] {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

.auth-form button[type="submit"]:hover {
    background-color: #0056b3;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9em;
}

.form-footer a {
    color: #007bff;
    text-decoration: none;
}

.form-footer a:hover {
    text-decoration: underline;
}

.message-area {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: bold;
}

.message-area.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-area.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.session-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid #007bff;
    border-radius: 5px;
    background-color: white;
    color: #007bff;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    margin-top: 15px;
    transition: background-color 0.3s;
}

.session-btn:hover {
    background-color: #f0f8ff;
}

.auth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.auth-divider span {
    background-color: white;
    padding: 0 10px;
    position: relative;
    z-index: 1;
    color: #6c757d;
    font-weight: bold;
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: #dee2e6;
    z-index: 0;
}

.google-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 100%;
    padding: 10px;
    border: 1px solid #dadce0;
    border-radius: 5px;
    background-color: #fff;
    color: #3c4043;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s;
    font-family: 'Roboto', sans-serif;
}

.google-login-btn:hover {
    background-color: #f8f9fa;
    border-color: #c6c9ce;
}

.google-login-btn svg {
    flex-shrink: 0;
}

.hamburger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1100;
}

.hamburger-menu span {
    width: 30px;
    height: 3px;
    background: white;
    border-radius: 10px;
    transition: all 0.3s linear;
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    background: #0056b3;
    height: 100%;
    padding: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1050;
    transition: transform 0.3s ease-in-out;
    transform: translateX(-100%);
    width: 80%;
    max-width: 300px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
}

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

.mobile-user-info {
    padding-bottom: 1rem;
    text-align: center;
}

.user-email-mobile {
    display: block;
    margin-bottom: 1rem;
    font-weight: bold;
    color: #fff;
    word-wrap: break-word;
}

.mobile-nav-link {
    font-size: 1.2rem;
    padding: 1rem 0.5rem;
    font-weight: bold;
    color: #FFF;
    text-decoration: none;
    transition: color 0.3s linear;
    display: block;
}

.mobile-nav-link:hover {
    color: #00c040;
}

.mobile-nav-divider {
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin: 0;
}

#mobile-install-link {
    display: none;
}

.close-nav-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    background: transparent;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
}

.mobile-sort-controls {
    display: none;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.mobile-sort-controls .sort-label {
    font-size: 0.9em;
    color: #555;
    font-weight: bold;
    margin-right: 5px;
}

.mobile-sort-controls .sort-btn,
.desktop-controls .sort-btn {
    background-color: #e9ecef;
    color: #495057;
    border: 1px solid #ced4da;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease, color 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.mobile-sort-controls .sort-btn.active,
.desktop-controls .sort-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.mobile-sort-controls .sort-direction-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    line-height: 1;
}

.mobile-top-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.mobile-bottom-bar {
    display: flex;
    justify-content: center;
    width: 100%;
    gap: 10px;
    align-items: center;
}

#toggle-filters-btn-mobile {
    flex-grow: 1;
    max-width: 170px;
}

.mobile-bottom-bar .refresh-container {
    flex: 1;
    display: flex;
    justify-content: center;
}

.mobile-bottom-bar #toggle-filters-btn-mobile {
    flex: 1;
}

.refresh-location-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    line-height: 1;
}

.refresh-location-btn:hover {
    background-color: #0056b3;
}

.sort-btn .refresh-icon {
    display: none;
    width: 14px;
    height: 14px;
    margin-left: 6px;
}

.sort-btn.active[data-sort="nearest"] .refresh-icon {
    display: inline-block;
}

.sort-btn.locating .refresh-icon {
    display: inline-block;
    animation: spin 1s linear infinite;
}

.mobile-controls-wrapper {
    display: none;
    align-items: center;
    flex-direction: column;
    width: 100%;
    gap: 10px;
}

.desktop-controls {
    display: none;
    align-items: center;
    gap: 10px;
}

@media (max-width: 600px) {
    main {
        padding-left: 0;
        padding-right: 0;
    }

    .park-section {
        border-radius: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .park-section h2,
    .park-table-section h2 {
        padding-left: 15px;
        padding-right: 30px;
    }

    /* Full-screen filter modal on mobile */
    .filter-modal {
        background-color: white;
        /* No overlay, just full screen */
    }

    .filter-panel {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

    .filter-content {
        padding: 1.5rem;
    }

    #apply-filters-btn {
        width: 100%;
    }

    .rides-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .ride-item {
        padding: 12px;
    }

    .ride-title {
        font-size: 1.05em;
    }

    .ride-wait-time {
        font-size: 1.05em;
    }

    .ride-item .ride-item-details {
        display: none;
    }

    .ride-item.expanded .ride-title {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .ride-item.expanded .ride-item-details {
        display: flex;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        box-sizing: border-box;
        padding: 2rem;
        overflow-y: auto;
    }
}

@media (max-width: 820px) {
    .hamburger-menu {
        display: flex;
    }

    .desktop-user-nav {
        display: none;
    }

    /* Only hide desktop-specific controls, allow view-toggle to show */
    .desktop-controls {
        display: none;
    }

    /* Style view toggle for mobile */
    .view-toggle {
        display: flex;
        width: 100%;
        justify-content: center;
        gap: 5px;
        margin-bottom: 5px;
    }

    #table-view-btn {
        display: none;
    }

    .view-toggle button {
        flex: 1;
        padding: 8px 0;
        /* optimize padding for small screens */
        font-size: 0.9rem;
        white-space: nowrap;
    }

    .mobile-controls-wrapper {
        display: flex;
    }

    .mobile-sort-controls {
        display: flex;
    }

    .controls-bar {
        padding: 0.75rem 1rem;
        gap: 1rem;
        justify-content: space-between;
    }

    header {
        padding: 0 1rem;
    }

    .header-left {
        flex-grow: 1;
        min-width: 0;
    }

    .header-content-wrapper {
        flex-grow: 1;
        text-align: center;
    }

    header h1 {
        font-size: 1.2rem;
        white-space: normal;
        display: inline-block;
    }

    .park-table-section {
        overflow-x: hidden;
    }

    .park-table-section thead {
        display: none;
    }

    .park-table-section tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
    }

    .park-table-section td {
        display: block;
        text-align: right;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
    }

    .park-table-section td:last-child {
        border-bottom: 0;
    }

    .park-table-section td::before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        font-weight: bold;
        text-align: left;
    }

    .park-table-section td .table-actions-wrapper {
        justify-content: flex-end;
        flex-wrap: wrap;
    }


    body.map-view-active #map-view-container {
        height: calc(100vh - 60px) !important;
        margin-top: 0;
    }

    body.map-view-active #mobile-sort-controls {
        display: none;
    }

    .map-controls-toggle {
        background: rgba(255, 255, 255, 0.2);
        border: 1px solid rgba(255, 255, 255, 0.5);
        color: white;
        font-size: 0.85rem;
        padding: 6px 12px;
        margin-left: 8px;
        border-radius: 4px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .map-controls-toggle:hover {
        background: rgba(255, 255, 255, 0.3);
    }
}

@media (min-width: 821px) {
    .hamburger-menu {
        display: flex;
    }

    .mobile-controls-wrapper {
        display: none !important;
    }

    .desktop-controls {
        display: flex;
    }

    .desktop-controls .sort-btn {
        padding: 10px 20px;
    }

    .mobile-nav {
        transform: none;
        display: none;
        position: absolute;
        top: 60px;
        left: 1rem;
        width: 280px;
        height: auto;
        background: white;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border-radius: 8px;
        padding: 0.5rem;
    }

    .mobile-nav.open {
        display: block;
        transform: none;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    .mobile-nav .mobile-nav-link,
    .mobile-nav .user-email-mobile,
    .mobile-nav .user-info a {
        color: #333;
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }

    .mobile-nav .mobile-nav-link:hover {
        color: #007bff;
        background-color: #f0f0f0;
        border-radius: 4px;
    }

    .mobile-nav .mobile-nav-divider {
        border-color: #eee;
    }

    .mobile-nav .close-nav-btn {
        display: none;
    }
}

/* --- Visit History Panel (Synchronized with challenges.css) --- */
.log-history-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 480px;
    height: 100%;
    background-color: #f0f2f5;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.2);
    z-index: 1060;
    transition: right 0.4s ease-in-out;
    display: flex;
    flex-direction: column;
}

.log-history-panel.open {
    right: 0;
}

.log-panel-header {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* Prevent header from shrinking */
}

.log-panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #111;
}

.log-panel-header button {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #444;
}

/* === MODIFIED: Log Filters with consistent sizing === */
.log-filters {
    display: flex;
    overflow-x: auto;
    padding: 10px 15px;
    background-color: #e2e8f0;
    gap: 8px;
    scrollbar-width: none;
    flex-shrink: 0;
    /* Critical: prevents filters from being crushed */
    align-items: center;
    -webkit-overflow-scrolling: touch;
}

.log-filters::-webkit-scrollbar {
    display: none;
}

.log-filters button {
    flex: 0 0 auto;
    /* Prevent growing/shrinking */
    white-space: nowrap;
    padding: 8px 15px;
    font-size: 0.85rem;
    font-weight: 600;
    /* Consistent weight */
    border-radius: 20px;
    border: 1px solid #ccc;
    background-color: white;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.log-filters button.active {
    background-color: #0056b3;
    color: white;
    border-color: #0056b3;
    font-weight: 600;
    /* Keep weight consistent */
}

/* === ADDED: Date Filter Styles === */
.log-date-filters {
    padding: 10px 15px;
    background-color: #fff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.9rem;
    flex-shrink: 0;
    /* Prevent date filters from shrinking */
}

.log-date-filters input[type="date"] {
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.85rem;
    background: #f9f9f9;
    color: #333;
    max-width: 130px;
}

.log-date-filters button {
    padding: 6px 10px;
    font-size: 0.8rem;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    color: #555;
    font-weight: 600;
}

.log-date-filters button:hover {
    background-color: #dde2e6;
}

.log-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 0;
    /* Important for flex scrolling */
}

.log-date-group h4 {
    margin: 20px 0 10px;
    font-size: 0.9rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #ddd;
    padding-bottom: 5px;
}

.log-entry-item {
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
}

.log-icon {
    font-size: 2rem;
    width: 45px;
    height: 45px;
    background: #f8f9fa;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.log-details {
    flex: 1;
    min-width: 200px;
}

.log-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: #111;
    margin-bottom: 2px;
}

.log-meta {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 8px;
}

.log-notes {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #444;
    background: #f1f3f5;
    padding: 10px;
    border-radius: 6px;
    border-left: 4px solid #adb5bd;
    font-style: italic;
}

.log-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    opacity: 0.6;
}

.log-actions button:hover {
    opacity: 1;
}

.edit-form-container {
    width: 100%;
    margin-top: 15px;
}

.inline-edit-form {
    background: #fff;
    padding: 1.5rem;
    border: 2px solid #007bff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.inline-edit-form label {
    font-weight: 700;
    font-size: 0.85rem;
    color: #555;
}

.inline-edit-form input,
.inline-edit-form textarea,
.inline-edit-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
}

.inline-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.inline-actions button {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    border: none;
}

.inline-actions .save-btn {
    background: #28a745;
    color: white;
}

.inline-actions button[type="button"] {
    background: #6c757d;
    color: white;
}

/* Map Popup Content Styles */
.map-popup-content h4 {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    color: #333;
}

.map-popup-content p {
    margin: 4px 0;
    font-size: 0.9em;
    color: #555;
    line-height: 1.4;
}

.popup-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.popup-actions button {
    padding: 6px 12px;
    font-size: 0.8em;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    color: white;
    font-weight: bold;
}

.log-visit-btn-map {
    background-color: #17a2b8;
}

.set-alert-btn-map {
    background-color: #28a745;
}

.view-history-btn-map {
    background-color: #6c757d;
}

.view-details-btn-map {
    background-color: #6f42c1;
}

/* Trend Arrow Styles */
.trend-arrow {
    display: inline-block;
    margin-right: 4px;
    font-size: 1.2em;
    font-weight: bold;
    line-height: 1;
    vertical-align: text-bottom;
    /* Better alignment for arrows next to text */
    position: relative;
    top: -1px;
}

.trend-up {
    color: #dc3545;
}

.trend-down {
    color: #28a745;
}

/* Radar Control Styles */
.radar-control-container {
    background-color: white;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.4);
}

.radar-control-container:hover {
    background-color: #f4f4f4;
}

.radar-toggle-label {
    margin: 0;
    font-weight: bold;
    font-size: 12px;
    color: #333;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 5px;
}