* {
    box-sizing: border-box;
    font-family: 'Varela Round', sans-serif;
}

:root {
    direction: rtl;
    --primary-color: #1c3f94;
    /* Israel Railways Blue-ish */
    --accent-color: #e66a1f;
    /* Orange accent */
    --bg-gradient-start: #f0f2f5;
    --bg-gradient-end: #e0e6ed;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100vw;
    overflow: hidden;
}

.top-bar {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    z-index: 10;
}

.app-logo {
    height: 70px;
}

.app-title {
    color: #C89A45;
    font-weight: bold;
    font-size: 30px;
}

#app {
    flex: 1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 70px 20px 100px 20px;
    /* Top padding for logo, bottom for nav */
    scroll-behavior: smooth;
}

/* --- Content Placeholder Styles --- */
.page-content {
    animation: fadeIn 0.3s ease-out;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.card {
    background: white;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* --- Liquid Glass Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 70px;
    border-radius: 20px;

    /* Glassmorphism Effect */
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);

    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.nav-item .material-icons {
    font-size: 28px;
    margin-bottom: 4px;
    transition: transform 0.2s ease;
}

/* Active State */
.nav-item.active {
    color: var(--primary-color);
    font-weight: 500;
}

.nav-item.active .material-icons {
    transform: translateY(-2px);
    color: var(--accent-color);
}

/* Hover effect for desktop */
@media (hover: hover) {
    .nav-item:hover:not(.active) {
        background: rgba(255, 255, 255, 0.4);
    }
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Autocomplete Styles */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
}

.input-field {
    width: 100%;
    height: 40px;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--primary-color);
    background: white;
}

.input-field::placeholder {
    color: #aaa;
}

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    margin-top: 4px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: none;
}

.autocomplete-results.show {
    display: block;
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: #f3f4f6;
}

.select-field {
    width: 100%;
    height: 40px;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 10px 0 30px;
    /* Right 10px text, Left 30px for arrow */
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    direction: rtl;

    /* Remove default arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' 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: left 10px center;
    /* Arrow on LEFT for RTL */
    background-size: 16px;
}

.date-field {
    width: 100%;
    height: 40px;
    background: #f3f4f6;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Varela Round', sans-serif;
}

.date-field:focus {
    border-color: var(--primary-color);
    background: white;
}

/* Loading Spinner */
.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

    100% {
        transform: rotate(360deg);
    }
}

#results-container {
    max-height: calc(100vh - 450px);
    /* Adjust based on header/search height */
    overflow-y: auto;
    padding-bottom: 20px;
    margin-top: 20px;

    /* Hide scrollbar for cleaner look but keep functionality */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

#results-container::-webkit-scrollbar {
    width: 6px;
}

#results-container::-webkit-scrollbar-track {
    background: transparent;
}

#results-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
}

/* Trip Details Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;

}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    height: 80vh;
    border-radius: 16px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    transform: translateY(20px);
    transition: transform 0.3s;
}

.modal-overlay.show .modal-content {
    transform: translateY(0);
}

/* Full Screen Details Modal Override - Mobile Only */
@media (max-width: 768px) {
    #details-modal .modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        padding: 0;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

#details-modal .modal-header {
    justify-content: flex-start;
    gap: 10px;
}

#details-modal .modal-header h2 {
    flex: 1;
    text-align: center;
    margin: 0;
    font-size: 1rem;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    /* For scrollbar */
}

/* Timeline Styles */
.timeline-item {
    display: flex;
    /* align-items: stretch; (Default) */
    margin-bottom: 0;
    /* Remove gap, handle via height/padding if needed, but 0 ensures lines touch */
    padding-bottom: 8px;
    /* Compact: reduced from 15px */
    /* Move spacing to padding */
    position: relative;
    opacity: 0.5;
    line-height: 1.2;
    /* Compact line height */
}

.timeline-item.active {
    opacity: 1;
    font-weight: bold;
}

.timeline-time {
    width: 75px;
    /* Compact width */
    font-size: 0.8rem;
    /* Compact font */
    color: var(--text-muted);
    /* Center text vertically */
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Or flex-start? */
    padding-left: 5px;
}

.timeline-marker {
    width: 20px;
    position: relative;
    /* For absolute line */
    display: flex;
    flex-direction: column;
    justify-content: center;
    /* Center Dot */
    align-items: center;
    margin: 0 10px;
    /* No padding-top */
}

.dot {
    width: 10px;
    height: 10px;
    background: #cbd5e1;
    border-radius: 50%;
    z-index: 1;
    flex-shrink: 0;
    /* Prevent squash */
}

.timeline-item.active .dot {
    background: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(28, 63, 148, 0.2);
}

.line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #cbd5e1;
    z-index: 0;
}

/* First item: Line starts at center (dot) going down */
.timeline-item:first-child .line {
    top: 50%;
}

/* Last item: Line ends at center (dot) coming from up */
.timeline-item:last-child .line {
    display: block;
    bottom: 50%;
}

.timeline-content {
    flex: 1;
    font-size: 0.9rem;
    /* Compact font */
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* Space for platform badge */
}

.platform-badge {
    background: #e0e0e0;
    color: #333;
    font-size: 0.75rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: bold;
    margin-right: 8px;
    flex-shrink: 0;
}

.platform-badge.dark {
    background: #444;
    color: white;
}

/* Collapsible Station Sections */
.timeline-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    /* Compact: reduced from 10px 14px */
    margin-bottom: 5px;
    /* Compact: reduced from 10px */
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    /* Slightly tighter radius */
    cursor: pointer;
    font-size: 0.8rem;
    /* Slightly smaller */
    color: var(--text-muted);
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.timeline-section-toggle:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: #ced4da;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.08);
}

.timeline-section-toggle .toggle-arrow {
    font-size: 18px;
    color: var(--primary-color);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-section-toggle.expanded .toggle-arrow {
    transform: rotate(180deg);
}

.timeline-section-toggle .toggle-text {
    flex: 1;
    font-weight: 500;
}

.timeline-section-toggle .toggle-count {
    background: var(--primary-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
}

.timeline-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.timeline-section-content.expanded {
    max-height: 3000px;
    /* Increased from 600px to support long lists */
}

/* Responsive Search Form */
.search-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 480px) {
    .search-row {
        grid-template-columns: 1fr;
    }
}

/* Mobile Compacting for screens < 768px */
@media (max-width: 768px) {

    /* Compact Header */
    .app-logo {
        height: 40px;
    }

    .app-title {
        font-size: 1.2rem;
        margin-right: 6px;
    }

    /* Reduce Padding */
    #app {
        padding: 55px 15px 70px 15px;
    }

    /* Compact Page Title */
    h1 {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }

    /* Compact Cards */
    .card {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 12px;
    }

    /* Flush Bottom Nav */
    .bottom-nav {
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        border-radius: 0;
        background: rgba(255, 255, 255, 0.95);
        border: none;
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .nav-item {
        font-size: 0.7rem;
        border-radius: 0;
    }

    .nav-item .material-icons {
        font-size: 24px;
        margin-bottom: 2px;
    }

    /* Slightly smaller inputs */
    .input-field,
    .select-field,
    .date-field {
        height: 38px;
        font-size: 0.95rem;
    }
}

/* History & Favorites UI */
.history-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--primary-color);
    color: var(--primary-color);
    transition: all 0.2s;
}

.history-pill {
    height: 40px;
    border-radius: 20px;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0 12px;
    cursor: pointer;
    color: var(--primary-color);
    transition: all 0.2s;
}

.history-pill:active {
    transform: scale(0.95);
    background: #f0f0f0;
}

.history-btn:active {
    transform: scale(0.95);
    background: #f0f0f0;
}

.history-section-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 15px 0 8px 0;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f9fafb;
    margin-bottom: 8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:active {
    background: #e5e7eb;
}

.history-info {
    flex: 1;
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--text-main);
}

.history-arrow {
    margin: 0 8px;
    color: var(--accent-color);
    font-size: 1.1rem;
}

.star-icon {
    padding: 5px;
    color: #cbd5e1;
    transition: color 0.2s;
}

.star-icon.active {
    color: #f59e0b;
}

.delay-badge {
    display: inline-block;
    padding: 2px 8px;
    background-color: #e53935;
    color: white;
    font-weight: bold;
    font-size: 0.75rem;
    border-radius: 12px;
    text-transform: uppercase;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
    animation: pulse 1.5s 5;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(229, 57, 53, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(229, 57, 53, 0);
    }
}

/* Train Pulse Icon */
.train-pulse-container {
    position: absolute;
    left: 50%;
    top: -20px;
    /* Between stations (roughly mid-distance if gap is small) */
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    color: var(--primary-color, #1976d2);
    z-index: 5;
    box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.7);
    animation: pulse-train 2s infinite;
    border: 1px solid rgba(25, 118, 210, 0.3);
}

@keyframes pulse-train {
    0% {
        transform: translateX(-50%) scale(0.95);
        box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.7);
    }

    70% {
        transform: translateX(-50%) scale(1.1);
        box-shadow: 0 0 0 8px rgba(25, 118, 210, 0);
    }

    100% {
        transform: translateX(-50%) scale(0.95);
        box-shadow: 0 0 0 0 rgba(25, 118, 210, 0);
    }
}

/* Real-Time Age Indicator */
.realtime-age-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.15) 0%, rgba(40, 167, 69, 0.08) 100%);
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-radius: 16px;
    font-size: 0.72rem;
    color: #28a745;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.realtime-age-indicator.stale {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15) 0%, rgba(255, 152, 0, 0.08) 100%);
    border-color: rgba(255, 152, 0, 0.4);
    color: #e67c00;
}

.realtime-age-indicator.very-stale {
    background: linear-gradient(135deg, rgba(229, 57, 53, 0.12) 0%, rgba(229, 57, 53, 0.06) 100%);
    border-color: rgba(229, 57, 53, 0.3);
    color: #d32f2f;
}

.realtime-age-indicator .material-icons {
    animation: subtle-spin 2s linear infinite;
}

.realtime-age-indicator.stale .material-icons,
.realtime-age-indicator.very-stale .material-icons {
    animation: none;
}

/* Modal age indicator - positioned on left in header */
.realtime-age-indicator.modal-age {
    position: static;
    margin: 0;
    font-size: 0.68rem;
    padding: 3px 8px;
    flex-shrink: 0;
}

/* Modal Bottom Navigation */
.modal-bottom-nav {
    display: flex;
    border-top: 1px solid #eee;
    background: white;
    flex-shrink: 0;
}

.modal-nav-item {
    flex: 1;
    padding: 8px 4px;
    /* Reduced padding */
    text-align: center;
    cursor: pointer;
    font-size: 0.75rem;
    /* Smaller font for text */
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.modal-nav-item .material-icons {
    font-size: 24px;
}

.modal-nav-item:hover {
    background: #f5f5f5;
}

.modal-nav-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--accent-color);
    font-weight: 600;
}

/* Tab Content Panels */
.modal-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.modal-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Map Tab Container */
#modal-map-container {
    flex: 1;
    min-height: 300px;
}

@keyframes subtle-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Map Train Icon */
.train-map-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    color: #1976d2;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: pulse-map 2s infinite;
    border: 2px solid white;
}

@keyframes pulse-map {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(25, 118, 210, 0.7);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(25, 118, 210, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(25, 118, 210, 0);
    }
}

/* --- New styles for Transfer Routes --- */

/* Click effect for cards and legs */
.click-effect {
    transition: transform 0.1s;
}

.click-effect:active {
    transform: scale(0.98);
    background-color: #f1f5f9 !important;
    /* Slight darken on click */
}

/* Animation for expanding details */
@keyframes expandFade {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

/* Style for the leg item hover */
.leg-item {
    transition: background-color 0.2s;
}

.leg-item:hover {
    background-color: #f1f5f9 !important;
}