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

:root {
    --primary-color: #00ffcc;
    --primary-glow: rgba(0, 255, 204, 0.4);
    --bg-dark: #0a0a1a;
    --glass-bg: rgba(16, 18, 27, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #ffffff;
    --text-muted: #8b949e;
    --row-hover: rgba(255, 255, 255, 0.03);
    --success: #3fb950;
    --error: #f85149;
    --danger: #ff4444;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', 'Noto Sans HK', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Dynamic Background Aesthetics */
.app-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: radial-gradient(circle at 15% 50%, rgba(0, 255, 204, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(138, 43, 226, 0.08), transparent 25%);
    filter: blur(60px);
}

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

/* Header */
.hero {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 2rem;
    animation: fadeInDown 0.8s ease-out;
}

.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    background: rgba(0, 255, 204, 0.1);
    color: var(--primary-color);
    border: 1px solid var(--primary-glow);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 600;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.5px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.search-box {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
}

.search-box svg {
    color: var(--text-muted);
    margin-right: 0.8rem;
    flex-shrink: 0;
}

.filters {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.glass-input-group {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.glass-input-group:focus-within {
    border-color: var(--primary-glow);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.1);
}

input,
select {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    padding: 0.8rem 1rem;
    width: 100%;
    outline: none;
}

select {
    cursor: pointer;
    appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%238b949e%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
}

select option {
    background-color: var(--bg-dark);
    color: var(--text-main);
}

/* Content Area */
.content-wrapper {
    min-height: 400px;
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.8s ease-out 0.4s both;
    padding: 1.5rem;
}

/* Cards Layout */
.cards-container {
    width: 100%;
}

.cards-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-top: 0.5rem;
}

/* Venue Cards */
.venue-card {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.venue-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 255, 204, 0.1);
}

.venue-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.venue-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.courts-count-pill {
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.venue-body {
    flex-grow: 1;
}

/* ── Horizontal Timeline ── */
.timeline-wrap {
    width: 100%;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.timeline-wrap::-webkit-scrollbar {
    display: none;
}

.tl-cells {
    display: flex;
    gap: 3px;
    min-width: max-content;
}

.tl-cell {
    flex: 1;
    min-width: 36px;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: filter 0.2s ease, transform 0.15s ease;
    position: relative;
}

.tl-cell:hover {
    filter: brightness(1.3);
    transform: scaleY(1.08);
    z-index: 1;
}

.tl-available {
    background: rgba(0, 255, 204, 0.18);
    border: 1px solid rgba(0, 255, 204, 0.35);
}

.tl-full {
    background: rgba(248, 81, 73, 0.08);
    border: 1px solid rgba(248, 81, 73, 0.2);
}

.tl-none {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.tl-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.tl-labels {
    display: flex;
    gap: 3px;
    min-width: max-content;
    margin-top: 4px;
}

.tl-label {
    flex: 1;
    min-width: 36px;
    text-align: center;
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0;
}

/* ── Facility Sections within a Card ── */
.facility-section {
    margin-bottom: 1rem;
}

.facility-section:last-child {
    margin-bottom: 0;
}

.facility-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.facility-name-text {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.facility-courts-badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
}

.facility-courts-badge.avail {
    background: rgba(0, 255, 204, 0.12);
    color: var(--primary-color);
    border: 1px solid rgba(0, 255, 204, 0.25);
}

.facility-courts-badge.full {
    background: rgba(248, 81, 73, 0.08);
    color: #f85149;
    border: 1px solid rgba(248, 81, 73, 0.2);
}

.timeline-empty {
    color: var(--text-muted);
    font-size: 0.9rem;
}


.venue-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}


/* Date Selector */
.date-tabs-container {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    width: 100%;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.date-tabs-container::-webkit-scrollbar {
    display: none;
}

.date-tabs {
    display: flex;
    gap: 0.8rem;
    padding-bottom: 0.5rem;
}

.date-tab {
    padding: 0.6rem 1.2rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.date-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.date-tab.active {
    background: var(--primary-glow);
    color: var(--primary-color);
    border-color: rgba(0, 255, 204, 0.3);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.15);
}

/* Filters Row */
.filters-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    width: 100%;
    align-items: center;
}

/* Buttons */
.btn-primary {
    background: rgba(165, 180, 252, 0.1);
    color: #a5b4fc;
    border: 1px solid rgba(165, 180, 252, 0.3);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: rgba(165, 180, 252, 0.2);
    color: #ffffff;
    border-color: rgba(165, 180, 252, 0.5);
    box-shadow: 0 0 15px rgba(165, 180, 252, 0.2);
}

/* Time Badge */
.time-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.slot-available {
    background: rgba(0, 255, 204, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(0, 255, 204, 0.2);
}

.slot-none {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0.7;
}

.slot-count {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* District & Venue */
.district-badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #a5b4fc;
}

.venue-name {
    font-weight: 500;
    color: #ffffff;
    display: block;
}

.venue-facility {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* Courts count (legacy table support) */
.courts-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: 600;
}

.courts-available {
    background: rgba(63, 185, 80, 0.2);
    color: var(--success);
    border: 1px solid rgba(63, 185, 80, 0.3);
}

.courts-none {
    background: rgba(248, 81, 73, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 81, 73, 0.2);
}

/* Action Link */
.action-link {
    color: #a5b4fc;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.action-link:hover {
    color: #ffffff;
    text-shadow: 0 0 8px rgba(165, 180, 252, 0.5);
}

/* Loading & Empty States */
.loading-state,
.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 100%;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 1rem;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 2rem;
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.btn-glass {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.btn-glass:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-glass:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

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

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

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

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

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

/* Responsive — Tablet & Desktop */
@media (min-width: 900px) {
    .controls {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
    }

    .filters-row {
        flex-wrap: nowrap;
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 2rem;
    }

    .app-container {
        padding: 1rem;
    }

    .content-wrapper {
        padding: 1rem;
    }
}