/* Plánek depa – Čerčany */
html, body { background: #0b0f16; color: #cfd8e3; }

.planek-wrap {
    padding: 10px;
    max-width: calc((100vh - 120px) * 16 / 9);
    margin: 0 auto;
}

.depo {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #dbeafe url("planek-back.png") center/cover no-repeat;
    border: 2px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    color: #1e293b;
    user-select: none;
}
.depo::before {
    content: "";
    position: absolute; inset: 0;
    background: rgba(255, 255, 255, 0.55);
    pointer-events: none;
    z-index: 0;
}

.kolej {
    position: absolute;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 4px;
    margin-top: -3px;
    border: 2px solid transparent;
    border-radius: 20px;
    cursor: pointer;
    transition: border-color 100ms, background 100ms;
}
.kolej:hover        { border-color: rgba(0, 128, 0, 0.6); background: rgba(255, 255, 255, 0.25); }
.kolej.drag-target  { border-color: #16a34a; background: rgba(34, 197, 94, 0.28); }
.kolej::after {
    content: attr(data-nazev-cz);
    position: absolute;
    left: 6px; bottom: calc(100% + 2px);
    font-size: 10px; color: #334155;
    opacity: 0.5;
    white-space: nowrap;
    pointer-events: none;
}
.kolej:hover::after { opacity: 1; }

.vozidlo {
    position: relative;
    z-index: 2;
    background: #e0e7ef;
    border: 2px solid #2563eb;
    border-radius: 6px;
    padding: 1px 6px 2px;
    font-size: 12px;
    line-height: 1.05;
    min-width: 70px;
    text-align: center;
    box-shadow: 1px 2px 4px #0002;
    cursor: grab;
    white-space: nowrap;
    color: #1e293b;
}
.vozidlo:active { cursor: grabbing; }
.vozidlo.dragging { opacity: 0.4; }
.vozidlo .hv_cislo {
    font-weight: 700;
    font-size: 12px;
}
.vozidlo .hv_poznamka {
    font-size: 11px;
    color: #475569;
    margin-top: 1px;
}

/* Popup (add / edit) */
.planek-modal {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.planek-modal.open { display: flex; }
.planek-modal .box {
    background: #101826;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 16px 20px;
    max-width: 560px;
    width: 92vw;
    max-height: 88vh;
    overflow: auto;
    box-shadow: 0 10px 40px #000a;
}
.planek-modal h2 {
    margin: 0 0 10px; font-size: 1.1rem;
    border-bottom: 1px solid #1e293b; padding-bottom: 8px;
}
.planek-modal label {
    display: block; font-size: 0.85rem;
    color: #94a3b8; margin-top: 10px;
}
.planek-modal input[type="text"],
.planek-modal input[type="color"] {
    width: 100%;
    padding: 6px 8px;
    margin-top: 2px;
    background: #0b1220;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 5px;
    font: inherit;
    box-sizing: border-box;
}
.planek-modal .colors {
    display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.planek-modal .colors button {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid #334155;
    cursor: pointer; padding: 0;
}
.planek-modal .colors button.sel {
    border-color: #fbbf24;
    box-shadow: 0 0 0 2px #fbbf24 inset;
}
.planek-modal .actions {
    display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;
    flex-wrap: wrap;
}
.planek-modal button.btn {
    padding: 7px 14px; border-radius: 6px;
    border: 1px solid #334155; background: #1e293b;
    color: #e2e8f0; cursor: pointer; font-weight: 600;
}
.planek-modal button.btn.primary { background: #2563eb; border-color: #3b82f6; }
.planek-modal button.btn.danger  { background: #991b1b; border-color: #dc2626; }
.planek-modal button.btn:hover { filter: brightness(1.15); }

.cand-list {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 300px; overflow-y: auto;
    margin-top: 4px;
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding: 4px;
}
.cand-item {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    background: #0b1220;
    cursor: pointer;
    font-size: 0.92rem;
}
.cand-item:hover { background: #1e3a5f; }
.cand-item .cand-voz { font-weight: 700; color: #e2e8f0; font-variant-numeric: tabular-nums; }
.cand-item .cand-info { color: #94a3b8; font-size: 0.85rem; }

.planek-msg { padding: 10px; color: #94a3b8; text-align: center; }
.planek-err { color: #f87171; }

/* Informační lišta – verze / stav */
.planek-topinfo {
    font-size: 0.85rem;
    color: #64748b;
    padding: 0 10px 4px;
    display: flex;
    gap: 12px;
    align-items: center;
}
.planek-topinfo .dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #16a34a;
    margin-right: 4px;
}
.planek-topinfo .dot.err { background: #ef4444; }

/* Řazení vozidel podle strany vjezdu */
.kolej.strany-L  { justify-content: flex-end; }   /* vjezd zleva → vozidla se hromadí vpravo */
.kolej.strany-R  { justify-content: flex-start; } /* vjezd zprava → vozidla se hromadí vlevo */
.kolej.strany-LR { justify-content: center; }     /* obě strany → střed */

.side-toggle {
    margin-left: 8px;
    padding: 3px 10px;
    border: 1px solid #475569;
    border-radius: 14px;
    background: #334155;
    color: #e2e8f0;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    vertical-align: middle;
}
.side-toggle:hover { background: #475569; border-color: #64748b; }

/* Režim úprav kolejí */
body.edit-mode .kolej { outline: 2px dashed #f59e0b; outline-offset: 2px; }
#edit-mode.active { background: #f59e0b; color: #1e293b; border-color: #f59e0b; }

/* Režim úprav - skrytí vozidel */
body.edit-mode .vozidlo { display: none; }

/* Tlačítka pro strany vjezdu (skutečné DOM elementy) */
.side-btn {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid #1e293b;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    display: none; /* viditelné jen v edit-mode */
    transition: background 0.15s, transform 0.1s;
}
.side-btn-L { order: -1; }
.side-btn-R { order: 999; }
.side-btn.on  { background: #22c55e; } /* zelená = lze */
.side-btn.off { background: #ef4444; } /* červená = nelze */
.side-btn:hover { transform: scale(1.15); box-shadow: 0 0 6px rgba(0,0,0,.4); }

body.edit-mode .side-btn { display: block; }

/* Mobil – plánek na výšku obrazovky, horizontální scroll */
@media (max-width: 900px) and (orientation: portrait) {
    html, body { overflow-x: hidden; }
    .planek-topinfo { display: none; }
    .planek-wrap {
        padding: 0;
        max-width: none;
        width: 100vw;
        height: calc(100vh - 70px); /* pod topbar */
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
    .depo {
        /* šířka 16:9 podle výšky viewportu */
        height: calc(100vh - 70px);
        width: calc((100vh - 70px) * 16 / 9);
        aspect-ratio: auto;
        border-radius: 0;
        border-left: none; border-right: none;
    }
}
