:root {
    --go-color: #3b82f6; /* Blue for Go */
    --back-color: #ef4444; /* Red for Back */
}

body {
    font-family: 'Inter', 'Noto Sans TC', sans-serif;
    background-color: #f1f5f9;
    color: #1e293b;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    transition: background-color 0.3s ease, color 0.3s ease;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
}

body.is-dragging-item {
    overflow: hidden;
}

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

.loading-spinner {
    border: 4px solid #e2e8f0;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1.2s linear infinite;
}

.page {
    display: none;
    height: 100%;
    flex-direction: column;
}

.page.active {
    display: flex;
}

::-webkit-scrollbar {
    width: 0px;
    height: 0px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: transparent;
}

.material-icons-outlined {
    font-size: 24px;
}

#homePage .container {
    padding-bottom: 100px;
}

@media (min-width: 768px) {
    #homePage .container {
        padding-bottom: 110px;
    }
}

#settingsPage .container {
    padding-bottom: 90px;
}
#settingsPage {
    overflow-y: auto;
}

/* Main Navigation Bar */
#mainNav {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: calc(100% - 24px);
    max-width: 500px;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 24px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    padding: 8px 8px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#mainNav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    flex-basis: 0;
    padding: 4px 4px;
    font-size: 0.75rem;
    color: #64748b;
    background-color: transparent;
    border: none;
    cursor: pointer;
    border-radius: 16px;
    transition: color 0.2s, background-color 0.2s, transform 0.1s;
}

#mainNav button:active {
    transform: scale(0.95);
}

#mainNav button .material-icons-outlined {
    font-size: 26px;
    margin-bottom: 2px;
}

#mainNav button:hover {
    color: #3b82f6;
    background-color: rgba(59, 130, 246, 0.1);
}

#mainNav button.active-nav {
    color: #3b82f6;
    font-weight: 600;
    background-color: rgba(59, 130, 246, 0.1);
}

body.dark-mode #mainNav {
    background-color: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
}

body.dark-mode #mainNav button { color: #94a3b8; }
body.dark-mode #mainNav button:hover { color: #93c5fd; background-color: rgba(147, 197, 253, 0.1); }
body.dark-mode #mainNav button.active-nav { color: #93c5fd; background-color: rgba(147, 197, 253, 0.15); }

/* Toast */
.toast-message {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 0.9em;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none;
}
.toast-message.show {
    opacity: 1;
}

/* Shared Time Pills */
.station-content .time-pill, .favorite-time-display .time-pill {
    flex-shrink: 0;
    min-width: 90px;
    text-align: center;
    padding: 6px 8px;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.9em;
}
.time-pill.bg-slate-200 { background-color: #e2e8f0; color: #1e293b; }
.time-pill.bg-red-200 { background-color: #fee2e2; color: #b91c1c; }
.time-pill.bg-green-200 { background-color: #dcfce7; color: #166534; }
.time-pill.bg-blue-200 { background-color: #dbeafe; color: #1e40af; }
.favorite-time-display .time-pill.bg-yellow-200 { background-color: #fef9c3; color: #854d0e; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transform: scale(0.95);
    transition: transform 0.3s ease;
}
.modal-overlay.show .modal-content {
    transform: scale(1);
}
body.dark-mode .modal-content {
    background-color: #1e293b;
}

.custom-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3001;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.custom-modal.show {
    opacity: 1;
    visibility: visible;
}
.custom-modal-content {
    background-color: #ffffff;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 180px;
}
.custom-modal.show .custom-modal-content {
    transform: scale(1);
}
body.dark-mode .custom-modal-content {
    background-color: #1e293b;
}
#customPromptMessage, #customConfirmMessage {
    flex-grow: 1;
}
.custom-modal-content input {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 20px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background-color: #f8fafc;
    color: #1e293b;
}
body.dark-mode .custom-modal-content input {
    background-color: #334155;
    border-color: #475569;
    color: #e2e8f0;
}
.custom-modal-content input::placeholder {
    color: #94a3b8;
}
.custom-modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}
.custom-modal-buttons button {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: background-color 0.2s;
}
.custom-modal-buttons .btn-primary {
    background-color: #3b82f6;
    color: white;
}
.custom-modal-buttons .btn-primary:hover {
    background-color: #2563eb;
}
.btn-secondary {
    background-color: #e2e8f0;
    color: #1e293b;
}
body.dark-mode .btn-secondary {
    background-color: #334155;
    color: #e2e8f0;
}
.btn-secondary:hover {
    background-color: #cbd5e1;
    color: #1e293b;
}
body.dark-mode .btn-secondary:hover {
    background-color: #475569;
}

/* Marquee */
@keyframes marquee-scroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
.marquee-container { overflow: hidden; white-space: nowrap; }
.marquee-text.is-overflowing > * {
    display: inline-block;
    white-space: nowrap;
    animation-name: marquee-scroll;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}
.marquee-inner { display: inline-block; padding-right: 2.5rem; }

/* Global Dark Mode Overrides */
body.dark-mode {
    background-color: #0f172a;
    color: #e2e8f0;
}
body.dark-mode .text-slate-800 { color: #e2e8f0; }
body.dark-mode .text-slate-700 { color: #cbd5e1; }
body.dark-mode .text-slate-600 { color: #94a3b8; }
body.dark-mode .text-slate-500 { color: #64748b; }
body.dark-mode .bg-white { background-color: #1e293b; }
body.dark-mode .border-slate-200 { border-color: #334155; }
body.dark-mode .border-slate-300 { border-color: #475569; }
body.dark-mode .loading-spinner {
    border: 4px solid #334155;
    border-top: 4px solid #60a5fa;
}
body.dark-mode #noResultsMessage, body.dark-mode #noFavoritesMessage { color: #94a3b8; }
body.dark-mode .time-pill.bg-slate-200 { background-color: #475569; color: #f1f5f9; }
body.dark-mode .time-pill.bg-red-200 { background-color: #991b1b; color: #fecaca; }
body.dark-mode .time-pill.bg-green-200 { background-color: #166534; color: #dcfce7; }
body.dark-mode .time-pill.bg-blue-200 { background-color: #1e40af; color: #dbeafe; }
body.dark-mode .favorite-time-display .time-pill.bg-yellow-200 { background-color: #854d0e; color: #fef9c3; }

body.dark-mode .dark\:bg-slate-800 { background-color: #1e293b !important; }
body.dark-mode .dark\:text-slate-200 { color: #e2e8f0; }
body.dark-mode .dark\:text-slate-300 { color: #cbd5e1; }
body.dark-mode .dark\:text-slate-400 { color: #94a3b8; }
body.dark-mode .dark\:border-slate-700 { border-color: #334155; }
body.dark-mode .dark\:hover\:bg-slate-700:hover { background-color: #334155; }
body.dark-mode .dark\:bg-slate-700 { background-color: #334155; }
body.dark-mode .dark\:border-slate-600 { border-color: #475569; }
body.dark-mode .dark\:peer-focus\:ring-blue-800:focus { --tw-ring-color: rgba(30, 64, 175, 0.5); }
body.dark-mode #languageSelect,
body.dark-mode #defaultStartPageSelect,
body.dark-mode #updateIntervalSelect {
    background-color: #334155;
    color: #e2e8f0;
    border-color: #475569;
}

/* Landscape Layout (Shared Nav & Page Containers) */
@media (orientation: landscape) {
    #mainNav {
        top: 50%;
        left: 12px;
        transform: translateY(-50%);
        bottom: auto;
        right: auto;
        width: 80px;
        min-width: 80px;
        height: auto;
        max-height: 85vh;
        flex-direction: column;
        justify-content: space-evenly;
        gap: 0;
        overflow-y: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding: 10px 0;
        border-radius: 24px;
        border: 1px solid rgba(148, 163, 184, 0.3);
        box-shadow: 5px 0 25px rgba(0,0,0,0.1);
    }
    #mainNav::-webkit-scrollbar {
        display: none;
    }
    body.dark-mode #mainNav {
        border: 1px solid rgba(255, 255, 255, 0.15);
    }
    #mainNav button {
        flex: 0 0 auto;
        flex-shrink: 0;
        width: 60px;
        margin: 0 auto;
        padding: 10px 0;
        border-bottom: none;
    }

    #routeSelectionPage .container,
    #homePage .container,
    #settingsPage .container,
    #busTrackerPage .container,
    #favoriteStationsPage .container {
        padding-bottom: 20px !important;
        padding-left: 120px !important;
        max-width: 100% !important;
    }

    #toastContainer {
        left: 50%;
    }
}
