/* ZTM Board CSS Style Sheets */

/* Zmienne globalne */
:root {
    --bg-gradient-start: #090D1A;
    --bg-gradient-end: #111827;
    --card-bg: rgba(30, 41, 59, 0.6);
    --card-border: rgba(51, 65, 85, 0.5);
    --card-border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #FFFFFF;
    --text-secondary: #94A3B8;
    --accent-blue: #3B82F6;
    --accent-sky: #38BDF8;
    --success-green: #10B981;
    --error-red: #EF4444;
    --tram-color: #B91C1C;
    --bus-color: #1D4ED8;
}

/* Reset stylów */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    padding: 20px;
    overflow-x: hidden;
}

/* Główny kontener aplikacji */
.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.5s ease-out;
}

/* 1. NAGŁÓWEK (Header) */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
    margin-bottom: 5px;
}

.header-left .metropolis-label {
    color: var(--accent-sky);
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 1.5px;
    display: block;
    margin-bottom: 2px;
}

.header-left h1 {
    font-size: 26px;
    font-weight: 700;
    background: linear-gradient(to right, #FFFFFF, #E2E8F0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.status-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online {
    background-color: var(--success-green);
    box-shadow: 0 0 8px var(--success-green);
}

.status-dot.offline {
    background-color: var(--error-red);
    box-shadow: 0 0 8px var(--error-red);
}

.status-text {
    font-size: 12px;
    font-weight: 700;
}

.status-text.online {
    color: var(--success-green);
}

.status-text.offline {
    color: var(--error-red);
}

.clock {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-secondary);
}

/* 2. PANEL STEROWANIA (Wyszukiwarka i Filtry) */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 14px 45px 14px 18px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.search-box input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-box input::placeholder {
    color: #64748B;
}

.clear-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #64748B;
    font-size: 22px;
    cursor: pointer;
    display: none;
    outline: none;
    padding: 5px;
    line-height: 1;
}

.clear-btn:hover {
    color: var(--text-primary);
}

/* Podpowiedzi wyszukiwania (Search Results Dropdown) */
.search-results-list {
    position: absolute;
    top: 56px;
    left: 0;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    z-index: 100;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.search-result-item {
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    transition: background-color 0.15s;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.search-result-sub {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 26px;
    transition: color 0.15s;
}

.search-result-item:hover .search-result-sub {
    color: rgba(255, 255, 255, 0.6);
}

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

.search-result-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

/* Chipsy filtrujące */
.filter-chips {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
}

.chip {
    padding: 8px 16px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.1s;
    outline: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.chip:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.chip:active {
    transform: scale(0.97);
}

.chip.active {
    background-color: var(--accent-blue);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

/* Nagłówek sekcji odjazdów */
.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 1.2px;
    margin-top: 5px;
}

/* 3. TABLICA ODJAZDÓW */
.departures-board-container {
    width: 100%;
    flex: 1;
}

.departures-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Karta odjazdu (Departure Card) */
.departure-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 15px;
    display: grid;
    grid-template-columns: 80px 1fr 95px;
    align-items: center;
    column-gap: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.departure-card:hover {
    transform: translateY(-2px);
    border-color: var(--card-border-hover);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.4);
}

/* Plakietka numeru linii */
.route-badge {
    justify-self: start;
    width: 55px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 15px;
    color: #FFFFFF;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}

.route-badge.tram {
    background-color: var(--tram-color);
}

.route-badge.bus {
    background-color: var(--bus-color);
}

/* Kierunek */
.headsign {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Czas odjazdu i opóźnienie */
.time-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.time-info .time {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.time-info .delay {
    font-size: 12px;
    font-weight: 700;
}

.time-info .delay.delayed {
    color: var(--error-red);
}

.time-info .delay.on-time {
    color: var(--success-green);
}

.time-info .delay.offline-badge {
    color: var(--text-secondary);
    opacity: 0.85;
}

/* Stany puste i ładowanie */
.empty-state, .loading-state, .error-state {
    padding: 40px 20px;
    text-align: center;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.error-state {
    color: var(--error-red);
    border-color: rgba(239, 68, 68, 0.2);
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--accent-blue);
    display: inline-block;
    animation: spin 0.8s linear infinite;
    margin-bottom: 10px;
}

/* Animacje */
@keyframes spin {
    to { transform: rotate(360deg); }
}

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

/* Customowy scrollbar dla podpowiedzi */
.search-results-list::-webkit-scrollbar {
    width: 6px;
}

.search-results-list::-webkit-scrollbar-track {
    background: transparent;
}

.search-results-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.search-results-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Responsywność dla małych ekranów */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .app-header h1 {
        font-size: 22px;
    }
    
    .search-box input {
        padding: 12px 40px 12px 14px;
        font-size: 14px;
    }
    
    .departure-card {
        padding: 12px;
        grid-template-columns: 65px 1fr 85px;
        column-gap: 10px;
    }
    
    .route-badge {
        width: 48px;
        height: 32px;
        font-size: 14px;
    }
    
    .headsign {
        font-size: 14px;
    }
    
    .time-info .time {
        font-size: 18px;
    }
}

/* 4. MODAL DIALOG (Trasa linii & Rozkład jazdy) */
dialog#route-dialog, dialog#timetable-dialog {
    border: none;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--card-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    padding: 0;
    color: var(--text-primary);
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    overflow: hidden;
}

dialog#route-dialog::backdrop, dialog#timetable-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.dialog-content {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.dialog-title-group h3 {
    font-size: 18px;
    font-weight: 700;
}

.close-dialog-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    outline: none;
    padding: 5px;
    line-height: 1;
}

.close-dialog-btn:hover {
    color: var(--text-primary);
}

.dialog-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Oś czasu trasy (Timeline) */
.timeline {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-left: 20px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background-color: var(--card-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    border: 2px solid var(--bg-gradient-start);
    z-index: 2;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.timeline-item.active .timeline-dot {
    background-color: var(--accent-sky);
    box-shadow: 0 0 8px var(--accent-sky);
}

.timeline-item.passed .timeline-dot {
    background-color: rgba(255, 255, 255, 0.2);
}

.timeline-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.timeline-stop-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.timeline-item.passed .timeline-stop-name {
    color: var(--text-secondary);
    text-decoration: line-through;
    opacity: 0.6;
}

.timeline-item.active .timeline-stop-name {
    color: var(--accent-sky);
    font-weight: 700;
}

.timeline-time {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.timeline-item.passed .timeline-time {
    opacity: 0.5;
}

/* Customowy scrollbar dla modala */
.dialog-body::-webkit-scrollbar {
    width: 6px;
}

.dialog-body::-webkit-scrollbar-track {
    background: transparent;
}

.dialog-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.dialog-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Stylizacja tabeli/siatki rozkładu jazdy */
.timetable-stop-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.timetable-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 14px;
    max-height: 50vh;
    overflow-y: auto;
}
.timetable-row {
    display: flex;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.timetable-row:last-child {
    border-bottom: none;
}
.timetable-hour {
    font-weight: 700;
    font-size: 16px;
    color: var(--accent-blue);
    width: 32px;
    text-align: right;
    margin-right: 12px;
    flex-shrink: 0;
}
.timetable-minutes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}
.timetable-minute-item {
    background: rgba(255, 255, 255, 0.04);
    padding: 2px 6px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

/* Sekcja przycisków rozkładów jazdy na tablicy odjazdów */
.departures-timetable-pills {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    text-align: center;
}
.departures-timetable-pills h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}
.timetable-pills-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}
.timetable-pill {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}
.timetable-pill:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-blue);
    transform: translateY(-1px);
}
.timetable-pill.tram-pill:hover {
    border-color: #ff3b30;
}

/* ====================================================
   PANEL DEBUGOWANIA
   ==================================================== */

#debug-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99999;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    background: #0d0d0d;
    border-top: 2px solid #1a1a1a;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.6);
    transition: transform 0.25s ease;
    max-height: 280px;
    display: flex;
    flex-direction: column;
}

#debug-panel.collapsed #debug-box {
    display: none;
}

#debug-panel.collapsed {
    max-height: unset;
}

#debug-panel.hidden {
    display: none;
}

/* Pasek narzędzi */
#debug-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: #111;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
    flex-wrap: wrap;
}

#debug-title {
    color: #4af;
    font-weight: bold;
    font-size: 11px;
    letter-spacing: 0.04em;
    user-select: none;
    cursor: pointer;
}

#debug-entry-count {
    color: #555;
    font-size: 10px;
    flex-shrink: 0;
}

/* Filtry poziomów */
#debug-filters {
    display: flex;
    gap: 4px;
    margin-left: 4px;
}

.dbg-filter {
    padding: 1px 7px;
    border-radius: 3px;
    border: 1px solid #333;
    background: transparent;
    color: #666;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 600;
}

.dbg-filter:hover {
    border-color: #555;
    color: #aaa;
}

.dbg-filter.active[data-level="ALL"]   { background: #1c2d3a; border-color: #4af; color: #4af; }
.dbg-filter.active[data-level="INFO"]  { background: #1a2b1a; border-color: #4f4; color: #4f4; }
.dbg-filter.active[data-level="WARN"]  { background: #2b2510; border-color: #fa4; color: #fa4; }
.dbg-filter.active[data-level="ERROR"] { background: #2b1010; border-color: #f44; color: #f44; }

/* Przyciski akcji */
#debug-actions {
    margin-left: auto;
    display: flex;
    gap: 2px;
}

#debug-actions button {
    background: transparent;
    border: 1px solid #2a2a2a;
    color: #666;
    border-radius: 4px;
    padding: 2px 7px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
}

#debug-actions button:hover {
    border-color: #555;
    color: #ccc;
    background: #1a1a1a;
}

/* Obszar logów */
#debug-box {
    overflow-y: auto;
    flex: 1;
    padding: 6px 10px;
    scroll-behavior: smooth;
}

#debug-box::-webkit-scrollbar { width: 5px; }
#debug-box::-webkit-scrollbar-track { background: #111; }
#debug-box::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
#debug-box::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* Wpisy logów */
.dbg-entry {
    display: flex;
    gap: 6px;
    padding: 1.5px 0;
    border-bottom: 1px solid #151515;
    line-height: 1.5;
    align-items: baseline;
}

.dbg-entry.hidden { display: none; }

.dbg-time {
    color: #444;
    flex-shrink: 0;
    font-size: 10px;
}

.dbg-badge {
    flex-shrink: 0;
    font-size: 9px;
    font-weight: bold;
    padding: 0 4px;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dbg-entry.lvl-info .dbg-badge  { background: #0a2a0a; color: #4f4; border: 1px solid #1a4a1a; }
.dbg-entry.lvl-warn .dbg-badge  { background: #2a1f00; color: #fa4; border: 1px solid #4a3a00; }
.dbg-entry.lvl-error .dbg-badge { background: #2a0000; color: #f55; border: 1px solid #5a0000; }

.dbg-entry.lvl-info  .dbg-msg { color: #8dc; }
.dbg-entry.lvl-warn  .dbg-msg { color: #fa4; }
.dbg-entry.lvl-error .dbg-msg { color: #f55; font-weight: bold; }

.dbg-msg {
    color: #8dc;
    word-break: break-all;
    font-size: 11px;
}

/* Licznik błędów w tytule */
#debug-error-badge {
    background: #f44;
    color: #fff;
    border-radius: 10px;
    font-size: 9px;
    font-weight: bold;
    padding: 0 5px;
    margin-left: 2px;
    display: none;
}

/* ====================================================
   PRZYCISK POWROTU DO STRONY GŁÓWNEJ
   ==================================================== */
.back-home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.back-home-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
    transform: translateX(-2px);
}

/* ── Pasek filtrów odjazdów ──────────────────────────────── */
#departure-filter-bar {
    padding: 8px 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: none;
}

.filter-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.time-filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 4px 10px;
    transition: border-color 0.2s, background 0.2s;
}

.time-filter-group.active {
    border-color: rgba(96,165,250,0.45);
    background: rgba(59,130,246,0.09);
}

.time-filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
}

#time-filter-input {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    outline: none;
    width: 76px;
    cursor: pointer;
}

#time-filter-input::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(0.35);
    cursor: pointer;
}

#time-filter-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
    display: none;
}

#time-filter-clear:hover { color: #fff; }
#time-filter-clear.visible { display: inline; }

.show-more-btn {
    width: 100%;
    padding: 12px;
    margin-top: 6px;
    background: rgba(255,255,255,0.03);
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.show-more-btn:hover {
    background: rgba(255,255,255,0.07);
    border-color: rgba(255,255,255,0.22);
    color: #fff;
}
