:root {
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-hero: #4f46e5;
    --accent-hero-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    
    --border-color: #e2e8f0;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 9999px;
    
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 700;
}

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

/* Navbar */
.navbar {
    background-color: var(--bg-card);
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
    position: relative;
    z-index: 10;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--accent-primary);
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--accent-primary);
}

.admin-link {
    background-color: #f1f5f9;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
}

.admin-link:hover {
    background-color: #e2e8f0;
}

/* Hero Section */
.hero {
    background: var(--accent-hero-gradient);
    padding: 5rem 1.5rem;
    text-align: center;
    color: white;
}

.hero-content h1 {
    font-size: 2.5rem;
    color: white;
    margin-bottom: 1rem;
}

.hero-content p {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-bottom: 3rem;
    font-weight: 300;
}

/* Search Widget */
.search-widget {
    background-color: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    max-width: 900px;
    margin: 0 auto;
    transform: translateY(2rem); /* Pulls it slightly out of hero */
    color: var(--text-primary);
}

#search-form {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}

.search-inputs {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

#search-time {
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: #f8fafc;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
    cursor: pointer;
}

#search-time:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-group {
    flex: 1;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-group select {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: #f8fafc;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
}

.input-group select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.swap-icon {
    width: 48px;
    height: 48px;
    background-color: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 0.25rem;
}

.swap-icon:hover {
    background-color: #e2e8f0;
    color: var(--accent-primary);
}

.btn-search {
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 0 2rem;
    height: 54px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-search:hover {
    background-color: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

/* Results Section */
.results-section {
    flex: 1;
    padding: 6rem 0 4rem 0; /* extra top padding for overlapping widget */
}

.results-header {
    margin-bottom: 2rem;
    text-align: center;
}

.results-header.hidden {
    display: none;
}

.results-header p {
    color: var(--text-secondary);
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
}

.section-title {
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    border-left: 4px solid var(--accent-primary);
    padding-left: 1rem;
}

.section-title i {
    color: var(--accent-primary);
}

/* Bus Card */
.bus-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    animation: slideUp 0.3s ease forwards;
}

.bus-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: rgba(99, 102, 241, 0.3);
}

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

.bus-title {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.bus-enumber {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background-color: #f1f5f9;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.bus-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.bus-type.badge {
    background-color: var(--accent-primary-alpha-10);
    color: var(--accent-primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

.bus-duration {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-primary);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--success);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    background: rgba(16, 185, 129, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.pulse {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    position: relative;
}

.pulse::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: var(--success);
    border-radius: 50%;
    animation: pulse-ring 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes pulse-ring {
    0% { transform: scale(0.5); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

.bus-card-body {
    padding: 1.5rem;
}

.route-timeline {
    position: relative;
    padding-left: 2rem;
}

.route-timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-point {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-point:last-child {
    margin-bottom: 0;
}

.timeline-point::before {
    content: '';
    position: absolute;
    left: -2rem;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: white;
    border: 2px solid var(--accent-primary);
}

.timeline-point.end::before {
    background-color: var(--accent-hero);
}

.point-time {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.point-location {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.live-status-bar {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: var(--radius-md);
}

.status-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}

.status-label {
    font-size: 0.875rem;
}

.status-speed {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.875rem;
}

.status-update {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.bus-card-footer {
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.btn-select {
    width: 100%;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-select:hover {
    background-color: var(--accent-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.loading-spinner, .error-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem;
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.loading-spinner i {
    font-size: 2rem;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    display: block;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
}

.empty-state.hidden {
    display: none;
}

.empty-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Footer */
footer {
    background-color: var(--bg-card);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* Trip Plan Timeline */
.plan-timeline {
    padding: 1rem 2rem;
    position: relative;
}

.timeline-item {
    display: flex;
    gap: 1.5rem;
    padding-bottom: 2rem;
    position: relative;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 81px;
    top: 24px;
    bottom: -4px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item:last-child::before {
    display: none;
}

.item-time {
    width: 70px;
    text-align: right;
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text-primary);
    padding-top: 2px;
}

.item-dot {
    width: 14px;
    height: 14px;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    z-index: 2;
    margin-top: 4px;
    transition: var(--transition);
}

.timeline-item.highlight .item-dot {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-primary-alpha-20);
}

.item-info {
    flex: 1;
}

.suggestion-group-header {
    background-color: var(--background-secondary);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.suggestion-item .item-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.station-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.timeline-item.highlight .station-name {
    color: var(--accent-primary);
    font-size: 1.125rem;
}

.stop-label {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 0.125rem 0.375rem;
    background-color: #f1f5f9;
    color: var(--text-secondary);
    border-radius: 4px;
    letter-spacing: 0.05em;
}

/* Autocomplete & Geolocation Styling */
.autocomplete-group {
    position: relative;
}

.input-with-action {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-with-action input {
    flex: 1;
}

.action-btn {
    width: 48px;
    height: 48px;
    background-color: #f1f5f9;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    cursor: pointer;
    transition: var(--transition);
}

.action-btn:hover {
    background-color: var(--accent-primary-alpha-10);
    border-color: var(--accent-primary);
}

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

.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 0.5rem;
    padding: 0.5rem;
    animation: fadeIn 0.2s ease;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.suggestion-item:hover, .suggestion-item.active {
    background-color: var(--accent-primary-alpha-10);
    color: var(--accent-primary);
}

.suggestion-item .stat-name {
    font-weight: 700;
    font-size: 0.9375rem;
}

.suggestion-item .stat-meta {
    font-size: 0.75rem;
    opacity: 0.7;
}

.suggestion-item.connected-highlight {
    border-left: 3px solid var(--success);
}

.suggestion-item.connected-highlight .stat-meta::after {
    content: ' • Reachable';
    color: var(--success);
    font-weight: 700;
}

.route-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    animation: fadeIn 0.3s ease;
}

.route-badge {
    background-color: var(--accent-primary-alpha-10);
    color: var(--accent-primary);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--accent-primary-alpha-10);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Responsive */
@media (max-width: 768px) {
    #search-form {
        flex-direction: column;
        align-items: stretch;
    }
    .search-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    .swap-icon {
        transform: rotate(90deg);
        align-self: stretch;
        margin: -0.5rem auto;
        z-index: 2;
    }
    .hero {
        padding: 2.5rem 1rem;
    }
    .search-widget {
        padding: 1rem;
    }
    .hero-content h1 {
        font-size: 2rem;
    }
    .results-grid {
        grid-template-columns: 1fr;
    }
    .nav-container {
        padding: 0 1rem;
    }
    .results-section {
        padding-top: 4rem;
    }
}
