/* ============================================
   SIECIOWY ROZKŁAD JAZDY - PKS BODZENTYN
   Kolorystyka: czerwony #c8102e, żółty #ffc72c
   ============================================ */

:root {
    --primary: #c8102e;
    --primary-dark: #a00d24;
    --accent: #ffc72c;
    --accent-dark: #e6b300;
    --white: #ffffff;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.15);
    --radius: 6px;
    --radius-lg: 10px;
}

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

body {
    font-family: 'Segoe UI', -apple-system, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.4;
}

/* ============================================
   APP CONTAINER - niski z-index żeby menu strony było nad aplikacją
   ============================================ */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* ============================================
   HEADER - MINIMALISTYCZNY
   ============================================ */
.app-header {
    background: var(--primary);
    color: var(--white);
    padding: 20px 16px;
    flex-shrink: 0;
    text-align: center;
}

.app-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
    margin: 0;
    letter-spacing: 0.5px;
}

/* ============================================
   MAIN CONTENT - 3 KOLUMNY
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ============================================
   LEFT PANEL - LINIE
   ============================================ */
.left-panel,
.lines-panel {
    width: calc(320px + 1cm);
    min-width: calc(320px + 1cm);
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}

.panel-header h2 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-header h2 i { color: var(--primary); }

.panel-header .badge {
    background: var(--primary);
    color: var(--white);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
}

.lines-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.line-card {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 10px 12px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid transparent;
}

.line-card:hover { 
    background: var(--gray-100);
    transform: translateX(2px);
}

.line-card.active { 
    border-left-color: var(--primary); 
    background: var(--white);
    box-shadow: var(--shadow);
}

.line-card.inactive-today { opacity: 0.5; }

.line-number {
    min-width: 50px;
    padding: 5px 8px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--white);
}

.line-info { flex: 1; min-width: 0; }

.line-name {
    font-size: 0.7rem;
    color: var(--gray-700);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.line-type {
    font-size: 0.6rem;
    color: var(--gray-500);
}

/* Show all stops button */
.show-all-btn {
    margin: 8px;
    padding: 10px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.show-all-btn:hover {
    background: var(--primary-dark);
}

.show-all-btn.active {
    background: var(--accent);
    color: var(--gray-800);
}

/* ============================================
   CENTER - MAPA
   ============================================ */
.map-panel {
    flex: 1;
    position: relative;
    display: flex !important;
    min-width: 0;
    z-index: 1;
}

#map {
    flex: 1;
    min-height: 100%;
    z-index: 1;
}

/* Leaflet popup z-index */
.leaflet-pane {
    z-index: 1 !important;
}

.leaflet-top, .leaflet-bottom {
    z-index: 10 !important;
}

.leaflet-popup-pane {
    z-index: 50 !important;
}

/* Disable scroll zoom on map */
.leaflet-container {
    touch-action: pan-x pan-y;
}

/* Stop labels - visible only at high zoom */
.stop-label {
    background: var(--white);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    pointer-events: none;
}

.stop-label.hidden {
    display: none !important;
}

/* ============================================
   RIGHT PANEL - PRZYSTANKI/ROZKŁAD
   ============================================ */
.schedule-header {
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    flex-shrink: 0;
}

.schedule-header h3 { font-size: 0.95rem; font-weight: 700; }
.schedule-header p { font-size: 0.7rem; opacity: 0.9; margin-top: 3px; }

.schedule-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.schedule-title .line-badge {
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--white);
}

.stop-header {
    display: flex;
    align-items: center;
    gap: 12px;
}
.stop-header .fav-btn {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.4);
    border-radius: var(--radius);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}
.stop-header .fav-btn:hover { background: rgba(255,255,255,0.6); color: var(--accent-dark); }
.stop-header .fav-btn.is-favorite { color: var(--accent); }
.stop-header .fav-btn:not(.is-favorite) { color: var(--accent); opacity: 0.85; }

.back-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.back-btn:hover { background: rgba(255,255,255,0.3); }

.schedule-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px;
}

.right-panel {
    width: 420px;
    min-width: 420px;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    overflow: hidden;
}

/* Panel przystanków: nagłówek na górze, treść przewija się w jednym miejscu */
.stops-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Ukryj placeholder, gdy aplikacja wypełnia .schedule-header/.schedule-content */
.stops-panel .selected-line-header { display: none; }

/* Lista przystanków */
.stops-list {
    display: flex;
    flex-direction: column;
}

.stop-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s;
    gap: 10px;
    border-bottom: 1px solid var(--gray-100);
}

.stop-item:hover { background: var(--gray-50); }

.stop-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

.stop-item.first .stop-dot { background: #22c55e; width: 12px; height: 12px; }
.stop-item.last .stop-dot { background: #ef4444; width: 12px; height: 12px; }

.stop-content { flex: 1; min-width: 0; }
.stop-name { font-size: 0.8rem; font-weight: 600; color: var(--gray-800); }
.stop-time { font-size: 0.7rem; color: var(--gray-500); margin-top: 2px; }

.next-badge {
    background: var(--accent);
    color: var(--gray-800);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.65rem;
}

.stop-arrow { color: var(--gray-400); font-size: 0.7rem; }

/* Przesiadki w liście przystanków */
.stop-connections {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 0.6rem;
    color: var(--gray-500);
}

.stop-connections i { font-size: 0.55rem; }

.conn-badge {
    color: #fff;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.55rem;
    font-weight: 700;
}

/* Connections block in stop detail */
.connections-block .connection-item {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.conn-line {
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
}

.conn-time {
    font-weight: 600;
    font-size: 0.65rem;
}

.conn-dest {
    font-size: 0.6rem;
    color: var(--gray-600);
}

.conn-wait {
    font-size: 0.55rem;
    color: var(--gray-500);
}

/* ============================================
   TIMETABLE (tabliczka przystankowa) - WIĘKSZA
   ============================================ */
.stop-timetable {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
}

/* Operator info */
.operator-info {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid var(--gray-200);
}

.operator-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.operator-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.operator-details {
    font-size: 0.65rem;
    color: var(--gray-600);
    line-height: 1.4;
}

.operator-details strong {
    color: var(--gray-800);
    font-size: 0.7rem;
}

/* ============================================
   PRZESIADKA NA POCIĄG (PLK API) – styl projektu
   ============================================ */
.train-connections-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 12px 4px;
    margin-bottom: 14px;
    position: relative;
    overflow-x: hidden;
}
.train-connections-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.train-connections-title i { color: var(--primary); }

/* Przesiadka na autobusy innych przewoźników */
.other-carrier-block {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 14px;
}
.other-carrier-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.other-carrier-title i { color: var(--primary); }
.other-carrier-body { display: flex; flex-direction: column; gap: 12px; }
.other-carrier-item {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.8rem;
}
.other-carrier-head { margin-bottom: 6px; }
.other-carrier-direction { color: var(--gray-600); font-weight: 500; }
.other-carrier-times { display: flex; flex-wrap: wrap; gap: 6px; }
.other-carrier-time {
    display: inline-block;
    padding: 4px 10px;
    background: var(--gray-100);
    border-radius: 4px;
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.75rem;
}
.other-carrier-time.empty { color: var(--gray-500); font-weight: 400; }

.train-connections-body .train-loading {
    font-size: 0.75rem;
    color: var(--gray-500);
}
.train-connections-body .train-error {
    font-size: 0.75rem;
    color: #b91c1c;
}
.train-connections-body .train-info {
    font-size: 0.75rem;
    color: var(--gray-600);
    padding: 12px 0;
}

/* Zakładki jak dep-arr-tabs (obok siebie) */
.train-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 3px;
}
.train-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.train-tab:hover {
    color: var(--gray-800);
    background: rgba(255,255,255,0.5);
}
.train-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.train-tab-count {
    display: inline-block;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
}
.train-tab.active .train-tab-count {
    background: var(--primary);
    color: #fff;
}
.train-tab-content {
    animation: tabFadeIn 0.2s ease;
    margin-top: 10px;
}
.train-list {
    max-height: 380px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
}

/* Tabela – pełna szerokość do krawędzi, bez przewijania, kolumna P (peron) */
.train-table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.75rem;
}
.train-table thead th {
    background: var(--primary);
    color: var(--white);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 8px 6px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1;
}
.train-table thead th.tt-time { width: 18%; }
.train-table thead th.tt-train { width: 26%; }
.train-table thead th.tt-dest { width: 52%; }
.train-table thead th.tt-plat { width: 8%; }
.train-table tbody .train-trow {
    border-bottom: 1px solid var(--gray-200);
    cursor: default;
    transition: background 0.15s;
}
.train-table tbody .train-trow[data-via] { cursor: help; }
.train-table tbody .train-trow:nth-child(odd) { background: var(--gray-50); }
.train-table tbody .train-trow:nth-child(even) { background: var(--white); }
.train-table tbody .train-trow:hover { background: #fef2f2; }

.train-table td {
    padding: 8px 6px;
    vertical-align: middle;
    text-align: center;
    line-height: 1.35;
}
.train-table td.tt-time {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.train-table td.tt-time .tt-time-main { display: block; line-height: 1.3; }
.train-table td.tt-time .train-delay { display: block; line-height: 1.2; font-size: 0.6rem; }
.train-table td.tt-train {
    font-size: 0.72rem;
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.train-table td.tt-dest {
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.78rem;
    word-break: break-word;
}
.train-table td.tt-plat {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.train-table .train-delay {
    color: #b91c1c;
    font-size: 0.6rem;
    font-weight: 700;
    white-space: nowrap;
    margin-left: 4px;
}

.train-tooltip {
    display: none;
    position: absolute;
    z-index: 20;
    background: var(--gray-800);
    color: var(--gray-100);
    font-size: 0.7rem;
    padding: 8px 12px;
    border-radius: var(--radius);
    max-width: 280px;
    line-height: 1.4;
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

.train-footer {
    margin-top: 10px;
    font-size: 0.62rem;
    color: var(--gray-500);
}
.train-footer a { color: var(--primary); }
.train-footer a:hover { text-decoration: underline; }

/* Connections */
.connections-block {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: var(--radius);
    padding: 10px;
}

.connections-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Zwinięta sekcja „Możliwe przesiadki” – domyślnie zwinięta, rozwijana po kliknięciu */
.connections-collapsible .connections-collapsible-trigger {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 0;
    margin: 0 0 0 -2px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 6px;
}
.connections-collapsible .connections-chevron {
    transition: transform 0.2s ease;
    font-size: 0.6rem;
    color: #92400e;
}
.connections-collapsible:not(.collapsed) .connections-chevron {
    transform: rotate(90deg);
}
.connections-collapsible .connections-body {
    margin-top: 8px;
}
.connections-collapsible.collapsed .connections-body {
    display: none;
}

/* Podsekcje w jednym panelu przesiadkowym (jak przesiadki kolejowe) */
.connections-subsection {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #fbbf24;
}
.connections-subsection:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.connections-subsection-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.connection-item {
    font-size: 0.65rem;
    color: #78350f;
    padding: 4px 0;
    border-bottom: 1px dashed #fbbf24;
}

.connection-item:last-child { border-bottom: none; }
.connection-item-train { color: var(--primary); }
.connection-item-train i { margin-right: 4px; }
.connection-item-lines { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.connection-item-lines i { margin-right: 4px; }
.train-connections-detail { margin-bottom: 4px; margin-top: 8px; }

/* Zakładki przesiadek kolejowych */
.train-transfer-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 6px;
    background: #fef2f2;
    border-radius: 8px;
    padding: 3px;
    border: 1px solid #fecaca;
}
.train-transfer-tab {
    flex: 1;
    padding: 7px 10px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.train-transfer-tab:hover {
    color: var(--gray-800);
    background: rgba(255,255,255,0.6);
}
.train-transfer-tab.active {
    background: #fff;
    color: #dc2626;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.train-transfer-tab .train-tab-count {
    background: #fecaca;
    color: #991b1b;
}
.train-transfer-tab.active .train-tab-count {
    background: #dc2626;
    color: #fff;
}
.train-transfer-tab i {
    font-size: 0.7rem;
}
.train-transfer-content {
    animation: tabFadeIn 0.2s ease;
}
.connection-item-bus-train { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.connection-item-bus-train .fa-train { color: var(--primary); font-size: 0.7rem; }

.transfer-nearby-wrap .transfer-nearby-blocks { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.transfer-nearby-wrap .transfer-pair-desc { font-size: 0.7rem; color: #166534; margin-bottom: 6px; }
.transfer-pair-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 0.65rem; color: #78350f; padding: 4px 0; border-bottom: 1px dashed #86efac; }
.transfer-pair-row:last-child { border-bottom: none; }
.transfer-pair-row .transfer-walk-icon { margin-right: 4px; color: #166534; font-size: 0.75rem; }
.transfer-pair-row .conn-line { padding: 1px 5px; border-radius: 3px; font-weight: 700; color: #fff; }
.transfer-pair-row .conn-line.other-carrier-badge { background: var(--gray-600); }
.transfer-pair-row .conn-time { font-weight: 600; }
.transfer-pair-row .conn-wait { color: #15803d; }
.transfer-pair-more { font-size: 0.7rem; color: #166534; padding: 4px 0; }

.transfer-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin-top: 8px;
    padding: 8px 12px;
    border: 1px dashed var(--gray-300);
    border-radius: 6px;
    background: var(--gray-50);
    color: var(--gray-600);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.transfer-expand-btn:hover {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-400);
}

.timetable-line {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 12px;
    border-left: 4px solid var(--primary);
}

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

.timetable-line-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.line-number-small {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--white);
}

.line-direction {
    font-size: 0.7rem;
    color: var(--gray-600);
    font-weight: 600;
}

.next-departure-badge {
    background: var(--accent);
    color: var(--gray-800);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
}

.timetable-type {
    font-size: 0.6rem;
    color: var(--gray-500);
    text-transform: uppercase;
    margin: 8px 0 4px;
    font-weight: 700;
}

.times-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.time-cell {
    background: var(--white);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.time-cell.past { opacity: 0.35; text-decoration: line-through; }
.time-cell.next { background: var(--accent); color: var(--gray-800); border-color: var(--accent); font-weight: 800; }
.time-cell.inactive { opacity: 0.3; }

/* ============================================
   LEAFLET POPUP - PEŁNA TABLICZKA WIĘKSZA
   ============================================ */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius-lg) !important;
    padding: 0 !important;
    box-shadow: var(--shadow-lg) !important;
}

.leaflet-popup-content {
    margin: 0 !important;
    min-width: 360px !important;
    max-width: 450px !important;
    max-height: 500px !important;
    overflow-y: auto !important;
}

.map-popup {
    padding: 14px;
}

.map-popup h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary);
}

.popup-operator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 12px;
}

.popup-operator-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
}

.popup-operator-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.popup-operator-text {
    font-size: 0.6rem;
    color: var(--gray-600);
    line-height: 1.3;
}

.popup-timetable {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.popup-line-block {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 10px;
    border-left: 4px solid var(--primary);
}

.popup-line-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.popup-line-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-line-badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--white);
}

.popup-line-name {
    font-size: 0.7rem;
    color: var(--gray-600);
    font-weight: 600;
}

.popup-next-badge {
    background: var(--accent);
    color: var(--gray-800);
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
}

.popup-times {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.popup-time {
    background: var(--white);
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}

.popup-time.past { opacity: 0.35; text-decoration: line-through; }
.popup-time.next { background: var(--accent); color: var(--gray-800); border-color: var(--accent); }

.popup-connections {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: var(--radius);
    padding: 8px 10px;
    margin-top: 10px;
}

.popup-connections-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 4px;
}

.popup-connection-item {
    font-size: 0.6rem;
    color: #78350f;
}




/* ============================================
   WELCOME – NASTĘPNY ODAJAZD, JAK DOJECHAĆ, ULUBIONE, W POBLIŻU
   ============================================ */
.welcome-next-box {
    margin-bottom: 16px;
}
.welcome-next-departure {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 14px 16px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: opacity 0.2s;
}
.welcome-next-departure:hover { opacity: 0.95; }
.welcome-next-label { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.9; margin-bottom: 4px; }
.welcome-next-stop { font-weight: 700; font-size: 0.95rem; }
.welcome-next-time { font-size: 0.85rem; margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.welcome-next-line { padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 700; color: #fff; }
.welcome-next-mins { font-size: 0.8rem; margin-top: 4px; opacity: 0.95; }
.welcome-next-placeholder {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.78rem;
    text-align: center;
}
.welcome-section {
    margin-bottom: 18px;
}
.welcome-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gray-800);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.welcome-section-title i { color: var(--primary); }
.route-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.route-select {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    background: var(--white);
}
.route-input-row { display: flex; gap: 6px; align-items: center; }
.route-autocomplete-wrap { flex: 1; position: relative; }
.route-input {
    padding: 8px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.8rem;
    width: 100%;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}
.route-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(200, 16, 46, 0.15); }
.route-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--gray-300);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.route-dropdown-item {
    padding: 6px 10px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s;
}
.route-dropdown-item:hover { background: var(--gray-100); }
.route-dropdown-item b { color: var(--primary); }
.route-dropdown-empty { padding: 8px 10px; font-size: 0.75rem; color: var(--gray-500); font-style: italic; }
.route-dropdown-hint { padding: 4px 10px; font-size: 0.7rem; color: var(--gray-400); border-top: 1px solid var(--gray-200); }
.route-map-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: var(--gray-50);
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.route-map-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.route-map-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); animation: pulse-map 1.5s infinite; }
@keyframes pulse-map { 0%,100% { box-shadow: 0 0 0 0 rgba(200,16,46,0.4); } 50% { box-shadow: 0 0 0 6px rgba(200,16,46,0); } }
#map.map-pick-mode { cursor: crosshair !important; }
#map.map-pick-mode .leaflet-marker-icon { cursor: pointer !important; }
.route-search-btn {
    padding: 10px 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.route-search-btn:hover { background: var(--primary-dark); }
.route-datetime-row {
    display: flex;
    gap: 8px;
}
.route-datetime-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 4px 8px;
    background: var(--white);
}
.route-datetime-field label {
    color: var(--gray-400);
    font-size: 0.8rem;
    flex-shrink: 0;
}
.route-date-input, .route-time-input {
    border: none;
    outline: none;
    font-size: 0.78rem;
    width: 100%;
    background: transparent;
    color: var(--gray-700);
    font-family: inherit;
}
.route-date-input::-webkit-calendar-picker-indicator,
.route-time-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.5;
}
.route-results { margin-top: 12px; min-height: 24px; }
.route-msg { font-size: 0.78rem; color: var(--gray-600); }
.route-item {
    font-size: 0.78rem;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}
.route-line { padding: 2px 6px; border-radius: 4px; font-weight: 700; font-size: 0.7rem; color: #fff; }
.route-section-title { font-size: 0.82rem; font-weight: 600; color: var(--gray-700); margin: 8px 0 4px; display: flex; align-items: center; gap: 6px; }
.route-section-title i { font-size: 0.9rem; }
.route-time { font-weight: 700; color: var(--primary); font-size: 0.82rem; }
.route-duration { font-size: 0.72rem; color: var(--gray-500); margin-left: 4px; font-style: italic; }
.route-wait { font-size: 0.72rem; color: #f59e0b; font-weight: 600; }
.route-item.route-direct { border-left-color: #22c55e; }
.route-item.route-transfer { border-left-color: #f59e0b; }
.route-item.route-transfer2 { border-left-color: #8b5cf6; }
.welcome-favorites { min-height: 40px; }
.welcome-fav-empty { font-size: 0.78rem; color: var(--gray-500); margin: 0; }
.welcome-fav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--gray-50);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}
.welcome-fav-item:hover { background: var(--gray-100); }
.welcome-fav-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.welcome-fav-remove:hover { color: var(--primary); }
.welcome-fav-name { flex: 1; font-weight: 600; font-size: 0.82rem; min-width: 0; }
.welcome-fav-next { font-size: 0.72rem; color: var(--gray-600); }
.nearby-btn {
    width: 100%;
    padding: 10px 14px;
    background: var(--gray-100);
    color: var(--gray-800);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.nearby-btn:hover { background: var(--gray-200); }
.nearby-list { margin-top: 10px; }
.nearby-loading { font-size: 0.78rem; color: var(--gray-600); margin: 0; }
.nearby-item {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: var(--gray-50);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
}
.nearby-item:hover { background: var(--gray-100); }
.nearby-dist { font-size: 0.7rem; color: var(--gray-600); font-weight: 600; }
.nearby-name { font-weight: 600; font-size: 0.82rem; min-width: 0; }
.nearby-next { font-size: 0.72rem; color: var(--gray-600); }

/* ============================================
   WELCOME INFO
   ============================================ */
.welcome-info {
    padding: 16px;
    text-align: center;
}

.welcome-info p {
    font-size: 0.8rem;
    color: var(--gray-600);
    margin-bottom: 16px;
}

.legend {
    background: var(--gray-50);
    padding: 14px;
    border-radius: var(--radius);
    text-align: left;
}

.legend h4 {
    font-size: 0.75rem;
    color: var(--gray-700);
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: var(--gray-600);
    margin-bottom: 5px;
}

.legend-badge {
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.6rem;
    min-width: 24px;
    text-align: center;
}

/* ============================================
   MOBILE
   ============================================ */
@media (max-width: 1024px) {
    .main-content { flex-direction: column; }

    .left-panel,
    .lines-panel {
        width: 100%;
        min-width: auto;
        max-height: 140px;
        border-right: none;
        border-bottom: 1px solid var(--gray-200);
    }

    .lines-list {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 8px;
        padding: 8px;
    }

    .line-card {
        flex-shrink: 0;
        margin-bottom: 0;
        min-width: 160px;
    }

    .show-all-btn {
        flex-shrink: 0;
        min-width: 140px;
    }

    .map-panel {
        height: 40vh;
        min-height: 280px;
    }

    .right-panel,
    .stops-panel {
        width: 100%;
        min-width: auto;
        flex: 1;
        border-left: none;
        border-top: 1px solid var(--gray-200);
    }

    .leaflet-popup-content {
        min-width: 300px !important;
        max-width: 350px !important;
    }
}

/* ============================================
   ZAKŁADKI ODJAZDY / PRZYJAZDY
   ============================================ */

/* Panel boczny - zakładki */
.dep-arr-tabs {
    display: flex;
    gap: 0;
    margin: 12px 0;
    background: var(--gray-100);
    border-radius: 8px;
    padding: 3px;
}

.dep-arr-tab {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.dep-arr-tab:hover {
    color: var(--gray-800);
    background: rgba(255,255,255,0.5);
}

.dep-arr-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.dep-arr-tab .tab-count {
    display: inline-block;
    background: var(--gray-200);
    color: var(--gray-600);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
}

.dep-arr-tab.active .tab-count {
    background: var(--primary);
    color: #fff;
}

.dep-arr-tab i {
    font-size: 0.75rem;
}

/* Popup na mapie - zakładki */
.popup-dep-arr-tabs {
    display: flex;
    gap: 0;
    margin: 8px 0;
    background: #f1f5f9;
    border-radius: 6px;
    padding: 2px;
}

.popup-tab {
    flex: 1;
    padding: 5px 8px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.popup-tab:hover {
    color: #334155;
    background: rgba(255,255,255,0.5);
}

.popup-tab.active {
    background: #fff;
    color: #c8102e;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.popup-tab i {
    margin-right: 3px;
    font-size: 0.6rem;
}

/* Tab content transition */
.tab-content {
    animation: tabFadeIn 0.2s ease;
}

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

/* ============================================
   MODAL PRZYSYSTANKU (szczegóły) – zawsze widoczny footer
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
}
.modal-content .modal-header { flex-shrink: 0; }
.modal-content .modal-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
}
.modal-content .modal-footer {
    flex-shrink: 0;
    padding: 16px;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ============================================
   EMTRACK - Markery autobusów na żywo
   ============================================ */

.bus-marker-container {
    background: transparent !important;
    border: none !important;
    text-align: center;
}

.bus-marker {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
    border: 3px solid #fff;
    transition: transform 0.5s ease;
}

.bus-marker i {
    transform: rotate(-var(--rotation, 0deg));
}

.bus-marker.bus-pulse {
    animation: busPulse 2s ease-in-out infinite;
}

@keyframes busPulse {
    0%, 100% { box-shadow: 0 2px 8px rgba(34,197,94,0.35); }
    50% { box-shadow: 0 2px 16px rgba(34,197,94,0.7), 0 0 20px rgba(34,197,94,0.3); }
}

.bus-marker-label {
    margin-top: 2px;
    font-size: 9px;
    font-weight: 800;
    color: #1e293b;
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
    white-space: nowrap;
    text-align: center;
    line-height: 1.1;
}

/* Popup autobusu */
.bus-popup {
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-width: 180px;
}

.bus-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e2e8f0;
}

.bus-popup-header i {
    font-size: 1.1rem;
}

.bus-popup-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.bus-popup-status i {
    font-size: 0.5rem;
}

.bus-popup-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    font-size: 0.75rem;
    color: #475569;
}

.bus-popup-details div {
    display: flex;
    align-items: center;
    gap: 5px;
}

.bus-popup-details i {
    color: #94a3b8;
    width: 12px;
    text-align: center;
    font-size: 0.7rem;
}

/* Przycisk toggle na mapie */
.bus-toggle-btn a {
    transition: color 0.2s ease;
}

.bus-toggle-btn a:hover {
    color: #16a34a !important;
}
