:root {
    --primary-blue: #003366;
    --secondary-blue: #0056b3;
    --accent-color: #e30613;
    --text-dark: #2c3e50;
    --text-light: #6c757d;
    --bg-light: #f8f9fa;
    --white: #ffffff;
    --sidebar-width: 400px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-light);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
}

.leaflet-container {
    background-color: #C6E1F8 !important; 
}

.leaflet-tile-container img {
    mix-blend-mode: normal !important; 
    filter: inherit;
    -webkit-transform: translate3d(0,0,0);
    transform: translate3d(0,0,0);
    will-change: transform;
}

.leaflet-tile {
    width: 256.5px !important;
    height: 256.5px !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: modalPop 0.3s ease-out;
}

@keyframes modalPop {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    color: var(--primary-blue);
    margin-top: 0;
    margin-bottom: 15px;
}

.modal-content p {
    color: var(--text-dark);
    line-height: 1.5;
    margin-bottom: 8px;
}

.disclaimer-text {
    text-align: left;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.disclaimer-text p {
    margin-bottom: 12px;
}

.app-version-info {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 20px;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.contact-info-box {
    margin-top: 0;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    text-align: left;
    font-size: 0.9rem;
}

.contact-info-box p {
    margin-bottom: 8px;
    color: #2c3e50;
    display: flex;
    align-items: center;
}

.contact-info-box p:last-child {
    margin-bottom: 0;
}

.contact-link {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
}

.contact-link:hover {
    text-decoration: underline;
    color: var(--accent-color);
}

.contact-info-box .icon {
    width: 25px;
    display: inline-block;
    text-align: center;
    margin-right: 5px;
    font-size: 1.1rem;
}

.btn-primary {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: var(--secondary-blue);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-light);
    border: 1px solid #ddd;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-secondary:hover {
    border-color: var(--text-light);
    color: var(--text-dark);
    background-color: #f8f9fa;
}

.app-header {
    height: var(--header-height);
    background-color: var(--primary-blue);
    color: var(--white);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 2000;
    position: relative;
    flex-shrink: 0;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin: 0;
}

.search-container {
    flex: 1;
    max-width: 400px;
    position: relative;
    margin: 0 20px;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
}

#train-search {
    width: 100%;
    padding: 8px 35px 8px 35px;
    border-radius: 20px;
    border: none;
    background-color: rgba(255, 255, 255, 0.9);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-dark);
    transition: all 0.2s;
    outline: none;
}

#train-search:focus {
    background-color: #fff;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}

.search-icon {
    position: absolute;
    left: 10px;
    color: #999;
    font-size: 0.9rem;
    pointer-events: none;
}

#clear-search {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: #999;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

#clear-search.hidden {
    display: none;
}

#clear-search:hover {
    color: var(--accent-color);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    margin-top: 5px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 3000;
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover, .search-result-item.selected {
    background-color: #f8f9fa;
}

.res-train-name {
    font-weight: 600;
    color: var(--primary-blue);
    font-size: 0.95rem;
}

.res-train-route {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-left: 10px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.menu-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.menu-btn .bar {
    width: 20px;
    height: 2px;
    background-color: white;
    border-radius: 2px;
    display: block;
}

.countdown-badge {
    background: rgba(255, 255, 255, 0.15);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #fff;
    flex-shrink: 0;
}

.separator {
    opacity: 0.5;
    margin: 0 2px;
}

.refresh-icon {
    font-size: 1rem;
    line-height: 1;
}

#map-container {
    flex: 1;
    position: relative;
    width: 100%;
    height: calc(100vh - var(--header-height));
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.map-overlay-controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--white);
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.filter-group {
    display: flex;
    gap: 5px;
}

.filter-btn {
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background-color: #f0f0f0;
    color: var(--text-dark);
}

.filter-btn.active {
    background-color: var(--primary-blue);
    color: var(--white);
}

.sidebar {
    position: absolute;
    top: var(--header-height);
    right: 0;
    width: var(--sidebar-width);
    height: calc(100% - var(--header-height));
    background: var(--white);
    z-index: 1500;
    box-shadow: -2px 0 20px rgba(0,0,0,0.15);
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sidebar.hidden {
    transform: translateX(100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background-color: var(--white);
    flex-shrink: 0;
}

.train-title-container {
    display: flex;
    flex-direction: column;
    gap: 8px; 
    width: 100%;
}

.train-title h2 {
    font-size: 1.5rem;
    color: var(--primary-blue);
    margin: 0;
}

.train-route-info {
    font-size: 0.9rem;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.route-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    line-height: 1.4;
}

.route-stop {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
}

.route-time {
    font-weight: 700;
    color: var(--primary-blue);
}

.route-arrow {
    font-size: 0.8rem;
    color: #888;
    margin: 0 2px;
}

.train-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    background: #eee;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark);
}

.badge.delay-ok { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.badge.delay-small { background-color: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.badge.delay-big { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.station-badge { background-color: #e8f0fe; color: #0d6efd; border: 1px solid #b6d4fe; }

.composition-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background-color: #e8f0fe;
    color: var(--secondary-blue);
    border: 1px solid #d2e3fc;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.composition-badge:hover {
    background-color: #d2e3fc;
    color: var(--primary-blue);
    border-color: #c0d5f8;
}

.composition-badge.hidden {
    display: none;
}

.tracking-badge {
    background-color: #fff3e0;
    color: #e67e22;
    border: 1px solid #ffe0b2;
}

.tracking-badge:hover {
    background-color: #ffe0b2;
    color: #d35400;
    border-color: #ffcc80;
}

.tcp-badge {
    background-color: #fce4ec;
    color: #c2185b;
    border: 1px solid #f8bbd0;
}

.tcp-badge:hover {
    background-color: #f8bbd0;
    color: #880e4f;
    border-color: #f48fb1;
}

.composition-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0 10px;
    margin-left: 10px;
}

.close-btn:hover {
    color: var(--accent-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.timeline-section h3, .raw-details-section h3 {
    font-size: 1rem;
    color: var(--text-light);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

.timeline-header-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0 10px 0;
    font-size: 0.75rem;
    color: #999;
    font-weight: 600;
    text-transform: uppercase;
}

.col-real { width: 25%; text-align: left; }
.col-station { width: 50%; text-align: center; }
.col-plan { width: 25%; text-align: right; }

.timeline {
    position: relative;
    margin-bottom: 10px;
}

.timeline.has-data::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background-color: #e0e0e0;
    transform: translateX(-50%);
    z-index: 0;
}

.timeline-item {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    z-index: 1;
    min-height: 24px;
}

.timeline-item::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #ccc;
    z-index: 1;
}

.timeline-item.active::after {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.2);
    width: 12px;
    height: 12px;
}

.timeline-item.past::after {
    background: #ccc;
    border-color: #ccc;
}

.t-real {
    width: 25%;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-dark);
}

.t-station {
    width: 40%; 
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    background: #fff;
    padding: 2px 5px;
    z-index: 10;
    position: relative;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.t-station.current-station-text {
    font-weight: 800;
    color: var(--primary-blue);
    transform: scale(1.05);
    display: inline-block;
}

.t-plan {
    width: 25%;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-light);
}

.delay-green { color: #28a745 !important; }
.delay-orange { color: #ffc107 !important; }
.delay-red { color: #dc3545 !important; }

.raw-details-section {
    margin-top: 30px;
}

.raw-details-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.raw-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 4px;
}

.raw-label {
    font-weight: 600;
    color: var(--text-light);
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-right: 10px;
}

.raw-value {
    color: var(--text-dark);
    font-size: 0.85rem;
    text-align: right;
    word-break: break-word;
}

.sidebar-footer {
    padding-top: 20px;
    text-align: center;
    font-size: 0.8rem;
    color: #aaa;
}

.vlak-marker { background: none; border: none; }
.marker-pin {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--white); border: 2px solid var(--text-dark);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3); position: relative;
    transition: transform 0.2s ease;
}
.marker-pin:hover { transform: scale(1.1); z-index: 1000 !important; }
.marker-pin.delay-ok { border-color: #28a745; color: #28a745; }
.marker-pin.delay-small { border-color: #ffc107; color: #b88b00; }
.marker-pin.delay-big { border-color: #dc3545; color: #dc3545; }

.marker-content {
    display: flex; flex-direction: column; align-items: center; line-height: 1;
}
.train-type { font-size: 9px; font-weight: 700; text-transform: uppercase; }
.train-arrow { font-size: 10px; margin-top: 1px; }

.custom-leaflet-tooltip {
    background: white;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    padding: 10px 14px;
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
    font-size: 0.9rem;
    opacity: 1 !important;
    min-width: 150px;
    text-align: center;
}

.custom-leaflet-tooltip::before {
    border-top-color: white;
}

.tooltip-header {
    font-weight: 800;
    color: var(--primary-blue);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-size: 1rem;
    line-height: 1.2;
}

.tooltip-route {
    font-size: 0.85rem;
    color: var(--text-dark);
    margin-bottom: 6px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.tooltip-delay {
    font-weight: 700;
    font-size: 0.9rem;
    padding-top: 4px;
    border-top: 1px solid #eee;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%; height: 80vh; top: auto; bottom: 0;
        transform: translateY(100%); border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15); z-index: 2100;
    }
    .sidebar.hidden { transform: translateY(100%); }
    .sidebar.visible { transform: translateY(0); }
    .map-overlay-controls { bottom: 30px; top: auto; width: 90%; display: flex; justify-content: center; }
    .filter-btn { padding: 10px 15px; font-size: 0.85rem; }
    .logo { display: none; }
}