/* Debug control panel. Palette follows the ramp display and payment kiosk. */
:root {
    --bg: #12131f;
    --surface: #1a1c2e;
    --surface-2: #232640;
    --border: #2e3252;
    --text: #eceef7;
    --muted: #9aa0bd;
    --accent: #e94560;
    --accent-hover: #ff5f78;
    --ok: #4caf50;
    --warn: #ff9800;
    --err: #f44336;
    --info: #2196f3;
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.45;
}

h1 { font-size: 1.25rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 600; }
.hint { color: var(--muted); font-size: 0.85rem; }
.hint-foot { margin-top: 10px; }
.subtitle { color: var(--muted); font-size: 0.8rem; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 12px 24px;
    background: rgba(18, 19, 31, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-id { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-id h1 { overflow-wrap: anywhere; }
.topbar-side { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

.kind-badge {
    flex: none;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.kind-entry { color: #7ddc82; border-color: rgba(76, 175, 80, 0.5); background: rgba(76, 175, 80, 0.12); }
.kind-exit { color: #ffb74d; border-color: rgba(255, 152, 0, 0.5); background: rgba(255, 152, 0, 0.12); }
.kind-payment { color: #64b5f6; border-color: rgba(33, 150, 243, 0.5); background: rgba(33, 150, 243, 0.12); }

.modules { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.module {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.module[data-state="up"] { color: var(--text); }
.module[data-state="up"] .dot { background: var(--ok); }
.module[data-state="down"] { color: #ff8a80; border-color: rgba(244, 67, 54, 0.5); }
.module[data-state="down"] .dot { background: var(--err); }

.banner {
    padding: 10px 24px;
    background: rgba(244, 67, 54, 0.15);
    border-bottom: 1px solid rgba(244, 67, 54, 0.5);
    color: #ff8a80;
    font-size: 0.9rem;
    text-align: center;
}

/* Layout */
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr);
    gap: 20px;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px 24px 40px;
    align-items: start;
}
.layout-single { grid-template-columns: minmax(0, 1fr); max-width: 1200px; }
.col { display: grid; gap: 20px; min-width: 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    min-width: 0;
}
.card.is-offline { border-color: rgba(244, 67, 54, 0.5); }
.card.is-offline > :not(.card-head):not(.feedback) { opacity: 0.45; }
.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.card-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.count { color: var(--muted); font-weight: 400; }
.empty { color: var(--muted); font-size: 0.9rem; }

/* Controls */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-small { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; padding: 16px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn:focus-visible, .input:focus-visible, select:focus-visible, .plate:focus-within, .switch input:focus-visible + .switch-track {
    outline: 2px solid var(--info);
    outline-offset: 2px;
}
.btn.is-busy::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.row { display: flex; gap: 10px; align-items: flex-end; }
.row > .input, .row > .field { flex: 1; min-width: 0; }
.input, select {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font: inherit;
}
.input { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; }
.field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }

/* Licence plate input, drawn as a Serbian plate */
.plate {
    display: flex;
    margin-bottom: 12px;
    border: 3px solid #1c1c1c;
    border-radius: 8px;
    background: #f7f7f2;
    overflow: hidden;
}
.plate-band {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    width: 38px;
    padding-bottom: 6px;
    background: #0b3ea8;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
}
.plate input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border: 0;
    outline: 0;
    background: transparent;
    color: #111;
    font: 700 1.7rem ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-align: center;
}
.plate input::placeholder { color: #a9a9a2; font-weight: 500; }

.feedback {
    margin-top: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    border-left: 4px solid var(--info);
    background: var(--surface-2);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}
.feedback[data-tone="success"] { border-left-color: var(--ok); }
.feedback[data-tone="warning"] { border-left-color: var(--warn); }
.feedback[data-tone="error"] { border-left-color: var(--err); }

/* Unit display mirror */
.live {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #7ddc82;
}
.live .dot { background: var(--ok); animation: pulse 2s infinite; }
.live.is-down { color: #ff8a80; }
.live.is-down .dot { background: var(--err); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.screen {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    border-radius: 10px;
    border: 6px solid #05060c;
    background: #05060c;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
/* The page is rendered at a fixed size and scaled to fit (see debug_panel.js) */
.screen iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 1280px;
    height: 800px;
    border: 0;
    transform-origin: 0 0;
}
.screen-display iframe { pointer-events: none; }
/* The kiosk page with its debug emulators is taller than a ramp display */
.screen-kiosk { aspect-ratio: 4 / 3; }
.screen-kiosk iframe { height: 960px; }
.screen-offline {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(5, 6, 12, 0.88);
    color: #ff8a80;
    font-weight: 600;
    text-align: center;
}

/* Gate and induction loop */
.gate { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-bottom: 14px; }
.gate-scene {
    position: relative;
    height: 96px;
    border-radius: 8px;
    background: linear-gradient(#1d2038 0 72%, #2a2d45 72%);
    overflow: hidden;
}
.gate-road { position: absolute; left: 0; right: 0; bottom: 10px; border-top: 2px dashed rgba(255, 255, 255, 0.25); }
.gate-post { position: absolute; left: 16px; bottom: 27px; width: 12px; height: 46px; border-radius: 3px; background: #555a7d; }
.gate-arm {
    position: absolute;
    left: 22px;
    bottom: 60px;
    width: 62%;
    height: 8px;
    border-radius: 4px;
    background: repeating-linear-gradient(90deg, var(--err) 0 14px, #fff 14px 28px);
    transform-origin: 0 50%;
    transition: transform 0.6s ease;
}
.gate[data-open="true"] .gate-arm { transform: rotate(-78deg); }
.gate-car {
    position: absolute;
    right: 14px;
    bottom: 27px;
    width: 54px;
    height: 20px;
    border-radius: 8px 12px 4px 4px;
    background: var(--info);
    opacity: 0;
    transform: translateX(70px);
    transition: opacity 0.3s, transform 0.4s ease;
}
.gate-car::before {
    content: '';
    position: absolute;
    left: 10px;
    top: -10px;
    width: 30px;
    height: 12px;
    border-radius: 8px 8px 0 0;
    background: #64b5f6;
}
.gate[data-car="true"] .gate-car { opacity: 1; transform: none; }
.gate-facts { display: grid; gap: 10px; }
.gate-facts dt { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.pill {
    display: inline-block;
    margin-top: 2px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--surface-2);
    white-space: nowrap;
}
.pill[data-tone="success"] { background: rgba(76, 175, 80, 0.2); color: #7ddc82; }
.pill[data-tone="error"] { background: rgba(244, 67, 54, 0.2); color: #ff8a80; }
.pill[data-tone="info"] { background: rgba(33, 150, 243, 0.2); color: #64b5f6; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.9rem; }
.switch input { position: absolute; opacity: 0; }
.switch-track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: background 0.15s;
}
.switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-track { background: rgba(33, 150, 243, 0.35); border-color: var(--info); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #fff; }

/* Tickets */
.tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; max-height: 640px; overflow-y: auto; }
.tickets > .empty { grid-column: 1 / -1; }
.ticket { display: grid; gap: 8px; align-content: start; padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.ticket-meta { font-size: 0.75rem; color: var(--muted); }
.ticket-code {
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--bg);
    font: 600 1rem ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    overflow-wrap: anywhere;
    user-select: all;
}
.ticket-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ticket img { width: 100%; border-radius: 6px; background: #fff; }

/* Activity log */
.log { list-style: none; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; font-size: 0.85rem; }
.log li:not(.empty) { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding-left: 10px; border-left: 3px solid var(--info); }
.log li[data-tone="success"] { border-left-color: var(--ok); }
.log li[data-tone="warning"] { border-left-color: var(--warn); }
.log li[data-tone="error"] { border-left-color: var(--err); }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log span { overflow-wrap: anywhere; }

@media (max-width: 980px) {
    .layout { grid-template-columns: minmax(0, 1fr); padding: 16px; }
    .topbar { padding: 12px 16px; position: static; }
}
@media (max-width: 520px) {
    .card { padding: 14px; }
    .row { flex-direction: column; align-items: stretch; }
    .gate { grid-template-columns: minmax(0, 1fr); }
    .gate-facts { grid-template-columns: 1fr 1fr; }
    .plate input { font-size: 1.3rem; }
    .card-head { flex-wrap: wrap; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
