/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    padding: 2rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 3rem;
    color: white;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: end;
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 150px;
}

.control-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.control-group select,
.control-group input {
    padding: 0.75rem 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

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

#parkSelect {
    min-width: 250px;
}

#dateSelect {
    min-width: 150px;
}

#timeRange {
    min-width: 180px;
}

.park-filter-options {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.park-filter-options label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    color: #666;
    cursor: pointer;
    margin: 0;
}

.park-filter-options input[type="checkbox"] {
    margin: 0;
    padding: 0;
    width: auto;
    height: auto;
}

.date-range-options {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.date-range-options label {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.date-range-options select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
    background: white;
    min-width: 120px;
}

#refreshBtn, #todayBtn {
    padding: 0.75rem 1.5rem;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

#refreshBtn:hover, #todayBtn:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

#todayBtn {
    background: #28a745;
}

#todayBtn:hover {
    background: #1e7e34;
}

/* Available dates display */
.available-dates {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
    max-height: 120px;
    overflow-y: auto;
}

.available-dates small {
    color: #666;
    font-size: 0.8rem;
}

.date-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.date-pill {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #e9ecef;
    color: #495057;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.date-pill:hover {
    background: #007bff;
    color: white;
    transform: translateY(-1px);
}


/* Wait time category styling for date pills */
.date-pill.wait-high {
    background: #dc3545;
    color: white;
}

.date-pill.wait-high:hover {
    background: #c82333;
    color: white;
}

.date-pill.wait-medium {
    background: #ffc107;
    color: #212529;
}

.date-pill.wait-medium:hover {
    background: #e0a800;
    color: #212529;
}

.date-pill.wait-low {
    background: #28a745;
    color: white;
}

.date-pill.wait-low:hover {
    background: #218838;
    color: white;
}

/* Selected state overrides wait time colors */
.date-pill.selected {
    background: #007bff !important;
    color: white !important;
    border-color: #0056b3;
}

/* Today state overrides wait time colors but not selected */
.date-pill.today:not(.selected) {
    background: #ffc107 !important;
    color: #212529 !important;
    font-weight: 600;
}

.date-info {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-left: 0.25rem;
}

/* Stats container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card span {
    font-size: 2rem;
    font-weight: bold;
    color: #333;
}

/* Rides container */
.rides-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Filter tabs */
.filter-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    flex-wrap: wrap;
}

.filter-btn {
    flex: 1;
    min-width: 120px;
    padding: 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.filter-btn:hover {
    background: rgba(0, 123, 255, 0.1);
}

.filter-btn.active {
    background: white;
    border-bottom-color: #007bff;
    color: #007bff;
}

/* Rides grid */
.rides-grid {
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

/* Ride cards */
.ride-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
    border-left: 4px solid #dee2e6;
    cursor: pointer;
}

.ride-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ride-card.open {
    border-left-color: #28a745;
    background: linear-gradient(135deg, #f8fff9 0%, #f0f8f0 100%);
}

.ride-card.closed {
    border-left-color: #dc3545;
    background: linear-gradient(135deg, #fff8f8 0%, #f8f0f0 100%);
    opacity: 0.7;
}

/* New uptime-based status styling */
.ride-card.uptime-excellent {
    border-left-color: #28a745;
    background: linear-gradient(135deg, #f8fff9 0%, #f0f8f0 100%);
}

.ride-card.uptime-fair {
    border-left-color: #ffc107;
    background: linear-gradient(135deg, #fffef8 0%, #fefcf0 100%);
}

.ride-card.uptime-poor {
    border-left-color: #dc3545;
    background: linear-gradient(135deg, #fff8f8 0%, #f8f0f0 100%);
    opacity: 0.85;
}

.ride-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.ride-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    flex: 1;
}

.ride-status {
    font-size: 1rem;
    margin-left: 0.5rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.ride-status.uptime-excellent {
    color: #155724;
    background: rgba(40, 167, 69, 0.1);
    border-color: rgba(40, 167, 69, 0.2);
}

.ride-status.uptime-fair {
    color: #856404;
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.2);
}

.ride-status.uptime-poor {
    color: #721c24;
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.2);
}

.ride-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wait-time {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    text-align: center;
    min-width: 80px;
}

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

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

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

.ride-card.closed .wait-time {
    background: #e9ecef;
    color: #6c757d;
}

.wait-number {
    font-size: 1rem;
}

.ride-meta {
    text-align: right;
}

.ride-meta small {
    color: #666;
    font-size: 0.8rem;
}

.ride-statistics {
    margin-top: 0.25rem;
}

.ride-statistics small {
    color: #888;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Loading and error states */
.loading, .error, .no-data {
    text-align: center;
    padding: 3rem;
    color: #666;
    grid-column: 1 / -1;
}

.error {
    color: #dc3545;
}

.loading p, .error p, .no-data p {
    font-size: 1.1rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

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

    .controls {
        flex-direction: column;
    }

    #parkSelect {
        width: 100%;
    }

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

    .filter-tabs {
        flex-direction: column;
    }

    .filter-btn {
        border-bottom: none;
        border-right: 3px solid transparent;
    }

    .filter-btn.active {
        border-right-color: #007bff;
        border-bottom: none;
    }

    .rides-grid {
        grid-template-columns: 1fr;
        max-height: 500px;
    }
}

@media (max-width: 480px) {
    main {
        padding: 1rem 0.5rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-card span {
        font-size: 1.5rem;
    }

    .rides-grid {
        padding: 1rem;
    }

    .ride-card {
        padding: 0.75rem;
    }
}

/* Scrollbar styling */
.rides-grid::-webkit-scrollbar {
    width: 8px;
}

.rides-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.rides-grid::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.rides-grid::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Animation for loading */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.close {
    color: rgba(255, 255, 255, 0.8);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    line-height: 1;
    padding: 0 0.5rem;
}

.close:hover,
.close:focus {
    color: white;
    text-decoration: none;
}

.modal-body {
    padding: 2rem;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
}

.ride-info {
    margin-bottom: 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.info-item {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.info-item label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
}

.info-item span {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.chart-container {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #e9ecef;
}

.chart-container h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #333;
    text-align: center;
}

#waitTimeChart {
    width: 100%;
    height: 400px;
    border-radius: 4px;
}

/* Responsive modal */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .modal-header {
        padding: 1rem 1.5rem;
    }

    .modal-header h2 {
        font-size: 1.3rem;
    }

    .modal-body {
        padding: 1.5rem;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    #waitTimeChart {
        height: 300px;
    }
}