/**
 * Bus Route Page - Shared Styles
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    min-height: 100vh;
    padding: 20px;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Site Navigation */
.site-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    /* Not sticky - scrolls with page */
    margin-bottom: 20px;
}

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

.nav-logo {
    font-size: 1.4em;
    font-weight: 800;
    color: #667eea;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s ease;
}

.nav-logo:hover {
    color: #764ba2;
}

.nav-links {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-links a {
    padding: 10px 18px;
    color: #555;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95em;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.nav-links a:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
}

.nav-links a.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.container {
    max-width: 900px;
    width: 100%;
    margin: 20px auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 40px 50px;
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    animation: fadeInUp 0.6s ease-out;
}

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

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

/* Route Header - Sticky */
.route-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin: -40px -50px 24px -50px;
    padding: 20px 50px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    /* Nav bar is no longer sticky */
    z-index: 100;
    border-bottom: 3px solid #E41F1F;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.route-number {
    display: flex;
    align-items: center;
    gap: 16px;
}

.route-badge {
    background: #E41F1F;
    color: white;
    font-size: 2em;
    font-weight: 800;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(228, 31, 31, 0.3);
}

.route-info h1 {
    font-size: 1.4em;
    font-weight: 700;
    color: #1d3557;
    margin-bottom: 4px;
}

.route-info .terminus {
    font-size: 1em;
    color: #555;
    font-weight: 500;
}

/* Direction Toggle */
.direction-toggle {
    display: flex;
    background: linear-gradient(135deg, #f0f0f0 0%, #e8e8e8 100%);
    border-radius: 12px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) inset;
}

.direction-btn {
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 0.95em;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.direction-btn:hover {
    color: #E41F1F;
}

.direction-btn.active {
    background: white;
    color: #E41F1F;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Map Section */
.map-section {
    margin-bottom: 24px;
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.map-header h2 {
    font-size: 1.1em;
    color: #333;
    font-weight: 600;
}

.expand-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.expand-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

#route-map {
    width: 100%;
    height: 200px;
    border-radius: 16px;
    border: 2px solid #e8e8e8;
    transition: height 0.4s ease;
    z-index: 1;
}

#route-map.expanded {
    height: 500px;
}

/* Stops Section */
.stops-section h2 {
    font-size: 1.3em;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    margin-bottom: 20px;
}

.stops-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Stop Card - Compact Single Row */
.stop-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    border-left: 3px solid #667eea;
}

.stop-card:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    transform: translateX(2px);
}

.stop-card.highlighted {
    background: linear-gradient(135deg, #e0e7ff 0%, #f0e6ff 100%);
    border-left-color: #764ba2;
    animation: pulse 0.5s ease-out;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.01);
    }

    100% {
        transform: scale(1);
    }
}

.stop-letter {
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 700;
    font-size: 0.8em;
    border-radius: 6px;
    flex-shrink: 0;
}

.stop-letter-placeholder {
    min-width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.stop-name {
    flex: 1;
    font-size: 0.95em;
    font-weight: 600;
    color: #1d3557;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.live-arrival {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8em;
    flex-shrink: 0;
    min-width: 45px;
    justify-content: center;
}

.live-arrival.loading {
    background: #e5e7eb;
    color: #9ca3af;
}

.connecting-buses {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    flex-shrink: 1;
    min-width: 0;
}

.bus-tag {
    display: inline-block;
    background: #f1f5f9;
    color: #475569;
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid #e2e8f0;
}

.bus-tag:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

.bus-tag.night {
    background: #1e293b;
    color: #e2e8f0;
    border-color: #334155;
}

.bus-tag.night:hover {
    background: #334155;
}

/* Last Updated */
.last-updated {
    text-align: center;
    font-size: 0.85em;
    color: #888;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #e8e8e8;
}

/* Loading State */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading-spinner::after {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e8e8e8;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

/* Error State */
.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
    padding: 16px 20px;
    border-radius: 12px;
    border: 2px solid #f87171;
    font-weight: 600;
    text-align: center;
}

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    margin-bottom: 20px;
    transition: all 0.2s ease;
}

.back-link:hover {
    color: #764ba2;
    gap: 12px;
}

.back-link svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .container {
        padding: 24px 20px;
        margin: 10px;
        border-radius: 20px;
    }

    .route-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .route-badge {
        font-size: 1.6em;
        padding: 10px 20px;
    }

    .route-info h1 {
        font-size: 1.2em;
    }

    .direction-toggle {
        width: 100%;
    }

    .direction-btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.85em;
    }

    #route-map {
        height: 150px;
    }

    #route-map.expanded {
        height: 350px;
    }

    .stop-card {
        flex-wrap: wrap;
        /* Allow second row for connecting buses */
        padding: 8px 12px;
        gap: 4px 6px;
    }

    .stop-letter {
        order: 0;
        min-width: 26px;
        height: 26px;
        flex-shrink: 0;
    }

    .stop-name {
        order: 1;
        flex: 1;
        min-width: 0;
        font-size: 0.85em;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .live-arrival {
        order: 2;
        flex-shrink: 0;
    }

    .connecting-buses {
        order: 3;
        width: 100%;
        margin-top: 2px;
        /* Shows on second line */
    }

    .route-header {
        margin: -24px -20px 20px -20px;
        padding: 16px 20px;
        top: 0;
        /* Nav bar is no longer sticky */
    }

    /* Hide Journey Planner link on mobile */
    .nav-journey {
        display: none;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .nav-container {
        padding: 10px 16px;
    }

    .nav-logo {
        font-size: 1.2em;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .nav-links a {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    .stop-card {
        padding: 8px 10px;
        gap: 6px;
    }

    .stop-name {
        font-size: 0.82em;
        flex: 1;
        min-width: 0;
    }

    .stop-letter {
        min-width: 24px;
        height: 24px;
        font-size: 0.75em;
    }

    .live-arrival {
        padding: 3px 8px;
        font-size: 0.75em;
        min-width: 40px;
    }

    .bus-tag {
        padding: 2px 5px;
        font-size: 0.7em;
    }
}