/* ============================================
   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 {
    width: 240px;
    min-width: 240px;
    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
   ============================================ */
.right-panel {
    width: 320px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-left: 1px solid var(--gray-200);
    overflow: hidden;
}

.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;
}

.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;
    overflow-y: auto;
    padding: 10px;
}

/* 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: 14px;
}

/* 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;
}

/* 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;
}

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

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

.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;
}

.popup-no-service {
    font-size: 0.75rem;
    color: var(--gray-400);
    font-style: italic;
    text-align: center;
    padding: 15px;
}



/* ============================================
   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 {
        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 {
        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); }
}

/* 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); }
