* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.logo i {
    font-size: 2.5rem;
    color: #ffd700;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.1rem;
    font-weight: 300;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

/* Search Form */
.search-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #555;
}

.form-group label i {
    color: #667eea;
}

.form-group input {
    padding: 15px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Wider date/time field */
.form-group.wide {
    grid-column: span 2;
}

@media (max-width: 768px) {
    .form-group.wide {
        grid-column: 1 / -1;
    }
}

/* Improve datetime-local visual width */
#dateTime {
    min-width: 320px;
}

@media (max-width: 480px) {
    #dateTime {
        min-width: 100%;
    }
}

/* Station Search */
.station-search-container {
    position: relative;
}

.station-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #e1e5e9;
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: none;
}

.station-dropdown.show {
    display: block;
}

.station-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    transition: background-color 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.station-item:last-child {
    border-bottom: none;
}

.station-item:hover {
    background-color: #f8f9fa;
}

.station-item.selected {
    background-color: #e3f2fd;
    color: #1976d2;
}

.station-name {
    font-weight: 500;
    color: #333;
}

.station-id {
    font-size: 0.8rem;
    color: #666;
    font-family: 'Courier New', monospace;
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
}

.station-location {
    font-size: 0.8rem;
    color: #666;
    margin-top: 2px;
}

.station-products {
    font-size: 0.7rem;
    color: #888;
    margin-top: 2px;
    font-family: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
}

.search-btn {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 18px 30px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    font-size: 1.1rem;
}

/* Results */
.results h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 1.8rem;
}

.result-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.result-type {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 0;
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
    border-radius: 8px 8px 0 0;
}

.result-type.direct {
    border-left: 4px solid #007cba;
}

.result-type.split {
    border-left: 4px solid #ff6b35;
}

.result-type i {
    font-size: 1.3rem;
}

.result-type.direct i {
    color: #007cba;
}

.result-type.split i {
    color: #ff6b35;
}

.result-type h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.result-type .price {
    margin-left: auto;
    font-size: 1.4rem;
    font-weight: 700;
    color: #007cba;
}

.legs {
    padding: 25px;
}

.leg {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

.leg:last-child {
    margin-bottom: 0;
}

.leg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e1e5e9;
}

.leg-route {
    font-weight: 600;
    color: #333;
    font-size: 1.1rem;
}

.leg-price {
    font-weight: 700;
    color: #007cba;
    font-size: 1.2rem;
}

.leg-details {
    padding: 20px 25px;
}

/* Enhanced Leg Details - DB Style */
.leg-detail {
    background: white;
    border-radius: 0;
    padding: 0;
    margin-top: 0;
    border: none;
    position: relative;
}

.leg-detail:not(:last-child) {
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.leg-header-mini {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 0;
    border-bottom: none;
}

.leg-number {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 4px;
    color: #1976d2;
}

.train-info {
    font-size: 0.85rem;
    color: #666;
    background: #f5f5f5;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    border: 1px solid #e0e0e0;
}

.leg-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.time-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
}

.time-item i {
    color: #007cba;
    width: 16px;
    font-size: 0.9rem;
}

.time {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
    min-width: 50px;
}

.station {
    color: #555;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Stops Information - DB Style */
.stops-info {
    border-top: 1px solid #e9ecef;
    padding-top: 15px;
    background: #fafafa;
    margin: 0 -25px;
    padding: 15px 25px;
}

.stops-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 10px;
    font-weight: 500;
}

.stops-header i {
    color: #666;
    font-size: 0.8rem;
}

.stop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
}

.stop-item:last-child {
    border-bottom: none;
}

.stop-time {
    color: #333;
    font-weight: 500;
    min-width: 50px;
}

.stop-station {
    color: #666;
}

/* Journey Summary Bar */
.journey-summary {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 20px 25px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.journey-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.journey-duration {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

.journey-route {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #666;
}

.route-arrow {
    color: #007cba;
    font-size: 1.2rem;
}

/* Error */
.error {
    text-align: center;
    padding: 30px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 12px;
    color: #721c24;
}

.error i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #dc3545;
}

.error p {
    font-size: 1.1rem;
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 40px;
    color: white;
    opacity: 0.8;
}

.footer a {
    color: #ffd700;
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-content {
        padding: 25px;
    }
    
    .search-form {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .result-card {
        padding: 20px;
    }
    
    .legs {
        gap: 15px;
    }
    
    .leg {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 20px;
    }
    
    .logo {
        flex-direction: column;
        gap: 10px;
    }
    
    .logo h1 {
        font-size: 1.8rem;
    }
    
    .search-btn {
        padding: 15px 20px;
        font-size: 1rem;
    }
}

/* Responsive adjustments for leg details */
@media (max-width: 768px) {
    .leg-times {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .leg-header-mini {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .train-info {
        align-self: flex-start;
    }
    
    .journey-summary {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .journey-info {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}

/* Savings badge */
.savings-badge {
    margin-left: 10px;
    background: #e6f4ea;
    color: #1e7e34;
    border: 1px solid #c3e6cb;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
}

/* Price compare block */
.price-compare {
    display: flex;
    align-items: center;
    gap: 16px;
}

.price-compare .price-direct,
.price-compare .price-split {
    background: #fff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.95rem;
    color: #555;
}

.price-compare .price-direct span {
    font-weight: 700;
    color: #a71d2a;
}

.price-compare .price-split span {
    font-weight: 700;
    color: #0f7b0f;
}

textarea#dbPaste {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 12px;
    font-size: 0.95rem;
    background: #f8f9fa;
    resize: vertical;
}

.paste-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.search-btn.secondary {
    background: linear-gradient(135deg, #00c6ff 0%, #0072ff 100%);
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.25);
}

/* --- Compact UI overrides --- */
body {
    background: #f5f6f8;
    color: #222;
}

.header {
    margin-bottom: 24px;
}
.logo i { font-size: 2rem; }
.logo h1 { font-size: 1.8rem; text-shadow: none; }
.subtitle { font-size: 0.95rem; }

.main-content {
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.search-form { gap: 14px; }
.form-group input { padding: 10px; }
.station-item { padding: 8px 10px; }

.results h2 { font-size: 1.4rem; margin-bottom: 16px; }

.result-card { border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.result-type { padding: 12px 14px; }
.result-type h3 { font-size: 1.05rem; }
.result-type .price { font-size: 1.8rem; color: #0a7; }

.savings-badge {
    background: #e8fff3;
    color: #0a7;
    border-color: #b8f2d0;
    font-size: 0.8rem;
    padding: 3px 8px;
}

.legs { padding: 14px; }
.leg { border-radius: 6px; margin-bottom: 12px; }
.leg-header { padding: 12px 14px; }
.leg-route { font-size: 1rem; }
.leg-price { font-size: 1.2rem; color: #0a7; }
.leg-details { padding: 12px 14px; }

.journey-summary {
    background: transparent;
    border: none;
    padding: 10px 12px;
    margin-bottom: 12px;
}
.journey-duration { font-size: 1rem; }
.journey-route { gap: 8px; }
.route-arrow { font-size: 1rem; color: #888; }

.leg-header-mini { margin-bottom: 10px; }
.leg-number { font-size: 0.8rem; padding: 3px 6px; }
.train-info { font-size: 0.8rem; padding: 4px 8px; }
.leg-times { gap: 10px; margin-bottom: 10px; }
.time { font-size: 0.95rem; }
.station { font-size: 0.85rem; }

.stops-info { margin: 0 -14px; padding: 10px 14px; }
.stop-item { padding: 4px 0; font-size: 0.8rem; }

.price-compare { gap: 10px; }
.price-compare .price-direct, .price-compare .price-split { padding: 6px 8px; font-size: 0.9rem; }

.search-btn {
    background: #0b74de;
    box-shadow: none;
}
.search-btn:hover { transform: none; filter: brightness(0.95); }
.search-btn.secondary { background: #0aa06e; }

/* Compact journey meta and collapsible details */
.journey-meta {
    font-size: 0.85rem;
    color: #666;
}

.toggle-details {
    margin-left: 8px;
    font-size: 0.8rem;
    padding: 4px 8px;
    border: 1px solid #e1e5e9;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.leg .leg-details { display: none; }
.leg.expanded .leg-details { display: block; }

/* Language switch */
.lang-switch {
    margin-top: 8px;
    display: inline-flex;
    gap: 8px;
    align-items: center;
}

.lang-switch select {
    padding: 6px 8px;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    background: #fff;
}

/* Readability tweaks for light background */
body {
    background: #f2f4f7;
    color: #222;
}

.header {
    color: #222;
}

.logo i {
    color: #d00000; /* DB red accent */
}

.subtitle {
    color: #666;
}

.footer {
    color: #555;
}

.footer a {
    color: #0b74de;
}

.footer a:hover {
    text-decoration: underline;
}

/* Info button */
.info-btn {
    background: #fff;
    border: 1px solid #e1e5e9;
    color: #0b74de;
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal {
    background: #fff;
    width: min(520px, 90vw);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}

.modal-body { padding: 16px; color: #333; }

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #888;
}
.modal-close:hover { color: #333; }

/* Booking button */
.book-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    padding: 8px 12px;
    background: #d00000;
    color: #fff !important;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
}

.book-btn:hover { filter: brightness(0.95); }
