/*
 * Signage Manager – "Wegweiser"
 * The panel borrows from what the displays are: public signage. Asphalt and concrete
 * as ground, signal yellow for the one thing to do, exit-sign green for "running".
 * Typeface: Barlow (after highway signage), Semi Condensed for headings.
 */

@font-face { font-family: 'Barlow'; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-400-normal-l053MFU.woff2") format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/barlow-latin-400-italic-RE1xFki.woff2") format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-500-normal-VMkGyYA.woff2") format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-latin-600-normal-fSS6XKm.woff2") format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-500-normal-zlgPlGN.woff2") format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-600-normal-BwiUhEJ.woff2") format('woff2'); }
@font-face { font-family: 'Barlow Semi Condensed'; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/barlow-semi-condensed-latin-700-normal-6ZktTDp.woff2") format('woff2'); }

:root {
    --asphalt: #2b2f36;
    --asphalt-soft: #4a5059;
    --concrete: #e6e8ea;
    --surface: #ffffff;
    --line: #d3d8de;
    --line-strong: #aeb5be;
    --muted: #646b75;
    --signal: #ffc800;
    --signal-deep: #e0ac00;
    --exit: #237f52;
    --exit-soft: #e3f1e9;
    --stop: #c1121c;
    --stop-soft: #fbe7e8;
    --amber: #a86a00;

    --font: 'Barlow', system-ui, sans-serif;
    --font-display: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;

    --radius: 4px;
    --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--concrete);
    color: var(--asphalt);
    font: 400 16px/1.5 var(--font);
    font-feature-settings: 'tnum' 0;
}

h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; }
h1 { font-size: 32px; font-weight: 700; letter-spacing: -.005em; }
h2 { font-size: 21px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }

a { color: var(--asphalt); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--asphalt); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.numbers { font-feature-settings: 'tnum' 1; }

/* ---------- Header band ---------- */

.topbar {
    display: flex;
    align-items: stretch;
    gap: 32px;
    padding: 0 var(--gutter);
    height: 60px;
    background: var(--asphalt);
    color: #fff;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font: 600 19px/1 var(--font-display);
}
.brand-logo { display: block; width: 154px; height: auto; }
.brand-logo + .brand-name { padding-left: 12px; border-left: 1px solid var(--asphalt-soft); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a, .topbar .logout {
    display: flex;
    align-items: center;
    padding: 0 12px;
    color: #c9ced5;
    text-decoration: none;
    font-weight: 500;
    border-bottom: 4px solid transparent;
    border-top: 4px solid transparent;
}
.topbar nav a:hover, .topbar .logout:hover { color: #fff; }
.topbar nav a.active, .topbar .logout.active { color: #fff; border-bottom-color: var(--signal); }
.topbar :focus-visible { outline-color: var(--signal); outline-offset: -3px; }

/* ---------- Page ---------- */

.container { max-width: 1180px; margin: 0 auto; padding: 40px var(--gutter) 64px; }

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 32px;
}
.page-header p { margin: 6px 0 0; color: var(--muted); }

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 24px;
    margin-bottom: 24px;
}
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.panel > h2 { margin-bottom: 16px; }
.panel > h2 + p { margin-top: -8px; }

.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 24px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.danger-zone { margin-top: 8px; }

/* ---------- Flash messages ---------- */

.flash {
    padding: 12px 16px;
    margin-bottom: 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--asphalt);
    border-radius: var(--radius);
}
.flash-success { border-left-color: var(--exit); }
.flash-error { border-left-color: var(--stop); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--asphalt);
    font: 500 15px/1 var(--font);
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { border-color: var(--asphalt); }
.btn-primary { background: var(--signal); border-color: var(--signal-deep); font-weight: 600; }
.btn-primary:hover { background: var(--signal-deep); border-color: var(--signal-deep); }
.btn-danger { color: var(--stop); }
.btn-danger:hover { border-color: var(--stop); background: var(--stop-soft); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 14px; }
.btn-icon { width: 32px; padding: 0; font-size: 16px; }
.btn:disabled { opacity: .35; cursor: default; border-color: var(--line); background: var(--surface); }
.btn-link { border: 0; background: none; padding: 0; min-height: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; font-weight: 400; }
.btn-link:hover { color: var(--asphalt); background: none; }
.btn-link.btn-danger:hover { color: var(--stop); background: none; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions form { display: contents; }

/* ---------- Forms ---------- */

form > div, .form-row { margin-bottom: 20px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=number], select {
    width: 100%;
    max-width: 440px;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--asphalt);
    font: 400 16px var(--font);
}
input:hover, select:hover { border-color: var(--asphalt-soft); }
input:focus, select:focus { outline: none; border-color: var(--asphalt); box-shadow: 0 0 0 3px var(--signal); }
.help-text, form .form-text { margin: 6px 0 0; font-size: 14px; color: var(--muted); max-width: 60ch; }
form ul { list-style: none; padding: 0; margin: 6px 0 0; color: var(--stop); font-size: 14px; }

.inline-form { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.inline-form > div { margin: 0; }
.inline-form > div:first-child { flex: 1 1 260px; }
.inline-form > div:first-child input, .inline-form > div:first-child select { max-width: none; }
.inline-form input[type=number] { width: 140px; }
.inline-form .form-submit { padding-top: 28px; }

/* File picker as a large drop area */
.upload input[type=file] {
    display: block;
    width: 100%;
    padding: 28px 20px;
    border: 2px dashed var(--line-strong);
    border-radius: 6px;
    background: #f6f7f8;
    font: 500 15px var(--font);
    color: var(--muted);
    cursor: pointer;
}
.upload input[type=file]:hover { border-color: var(--asphalt-soft); }
.upload input[type=file]::file-selector-button {
    margin-right: 16px;
    padding: 10px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--asphalt);
    font: 500 15px var(--font);
    cursor: pointer;
}

/* ---------- Status ---------- */

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.status.online { color: var(--exit); font-weight: 500; }
.status.online::before { background: var(--exit); }
.status.waiting { color: var(--amber); font-weight: 500; }
.status.waiting::before { background: var(--signal-deep); }

/* ---------- Display overview: every display drawn as a screen in its real orientation ---------- */

.screens {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end; /* screens hang on a common line, like on a wall */
    gap: 48px 40px;
}
.screen-card { width: 300px; text-decoration: none; color: inherit; }
.screen-card.portrait { width: 185px; }

.screen {
    position: relative;
    display: block;
    aspect-ratio: 16 / 9;
    padding: 7px 7px 14px;
    border-radius: 7px;
    background: var(--asphalt);
    box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 14px 24px -14px rgba(43, 47, 54, .55);
}
.portrait .screen { aspect-ratio: 9 / 16; }
.screen-glass {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 2px;
    background: #15181c;
}
.screen-glass img, .screen-glass video { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen-empty {
    display: grid;
    place-items: center;
    height: 100%;
    padding: 12px;
    color: #8a929c;
    font-size: 14px;
    text-align: center;
}
/* Power LED on the bezel */
.screen-led {
    position: absolute;
    right: 12px;
    bottom: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #5b616a;
}
.online .screen-led { background: #3ddc84; box-shadow: 0 0 6px #3ddc84; }
.waiting .screen-led { background: var(--signal); box-shadow: 0 0 6px var(--signal); }

.screen-card:hover .screen, .screen-card:focus-visible .screen { outline: 3px solid var(--signal); outline-offset: 3px; }
.screen-card:focus-visible { outline: none; }

.screen-info { display: block; margin-top: 16px; }
.screen-info > span { display: block; }
.screen-info h2 { font-size: 22px; }
.screen-address { margin-top: 2px; font: 500 17px var(--font); font-feature-settings: 'tnum' 1; color: var(--muted); }
.screen-address strong { color: var(--asphalt); font-weight: 600; }
.screen-info .status { margin-top: 8px; }
.screen-info .playlist-name { margin-top: 2px; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.screen-info h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.screen-new {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 300px;
    aspect-ratio: 16 / 9;
    padding: 16px;
    border: 2px dashed var(--line-strong);
    border-radius: 7px;
    color: var(--asphalt);
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}
.screen-new:hover { border-color: var(--asphalt); color: var(--asphalt); }

/* ---------- Player address as a sign plate ---------- */

.address-plate {
    display: inline-block;
    padding: 14px 20px 12px;
    border-radius: 6px;
    background: var(--signal);
    color: var(--asphalt);
    font: 600 clamp(24px, 4vw, 34px)/1.1 var(--font-display);
    font-feature-settings: 'tnum' 1;
    word-break: break-all;
    margin: 4px 0 12px;
}
.address-plate span { font-weight: 500; opacity: .7; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 16px 0 0; font-size: 15px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- Device pairing ---------- */

.pairing-list { list-style: none; margin: 16px 0 0; padding: 0; }
.pairing-list li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 20px;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid var(--line);
}
.pairing-code { font: 700 34px/1 var(--font-display); font-feature-settings: 'tnum' 1; letter-spacing: .06em; }
.pairing-list .actions { grid-column: 1 / -1; }
.user-agent { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.spaced { margin-top: 20px; }

/* ---------- Tables (kept for simple lists) ---------- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 14px; color: var(--muted); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
td.actions-cell { text-align: right; }

/* ---------- Playlists ---------- */

.playlist-list { list-style: none; margin: 0; padding: 0; }
.playlist-list li { border-top: 1px solid var(--line); }
.playlist-list li:first-child { border-top: 0; }
.playlist-list a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 4px;
    text-decoration: none;
}
.playlist-list a:hover h2 { text-decoration: underline; text-underline-offset: 4px; }
.playlist-list h2 { flex: 1; min-width: 0; }
.playlist-list .filmstrip { display: flex; gap: 4px; --thumb-h: 40px; }
.playlist-list .meta { width: 80px; text-align: right; color: var(--muted); font-size: 15px; white-space: nowrap; }

/* The running order: numbers are meaningful here, it is a sequence */
.sequence { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.sequence li {
    display: grid;
    grid-template-columns: 44px auto minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-top: 1px solid var(--line);
    --thumb-h: 64px;
}
.sequence li:first-child { border-top: 0; padding-top: 0; }
.sequence .step { font: 600 28px/1 var(--font-display); color: var(--line-strong); font-feature-settings: 'tnum' 1; text-align: right; }
.sequence .name { font-weight: 600; overflow-wrap: anywhere; }
.sequence .name, .sequence .detail { display: block; }
.sequence .detail { font-size: 14px; color: var(--muted); }
@media (max-width: 640px) {
    .sequence li { grid-template-columns: 32px auto minmax(0, 1fr); }
    .sequence .actions { grid-column: 2 / -1; }
    .sequence .step { font-size: 22px; }
}

/* ---------- Media ---------- */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.media-tile {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 6px;
    overflow: hidden;
}
.media-preview {
    display: grid;
    place-items: center;
    height: 168px;
    background: #15181c;
    --thumb-h: 168px;
}
.media-tile .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.media-tile .name { font-weight: 600; overflow-wrap: anywhere; }
.media-tile .detail { font-size: 14px; color: var(--muted); }
.media-tile .actions { margin-top: auto; padding-top: 10px; }

/* Thumbnails keep the aspect ratio the display will show */
.thumb {
    display: block;
    height: var(--thumb-h, 54px);
    width: auto;
    aspect-ratio: 16 / 9;
    max-width: 100%;
    object-fit: contain;
    background: #15181c;
    border-radius: 2px;
}
.thumb-portrait { aspect-ratio: 9 / 16; }
.thumb-crop { position: relative; overflow: hidden; }
.thumb-crop > img, .thumb-crop > video { position: absolute; max-width: none; object-fit: fill; }

.empty {
    padding: 40px 24px;
    text-align: center;
    color: var(--muted);
    border: 2px dashed var(--line-strong);
    border-radius: 6px;
}

/* ---------- Crop editor ---------- */

.crop-stage {
    position: relative;
    display: flex;
    justify-content: center;
    background: #15181c;
    border-radius: 6px;
    overflow: hidden;
    user-select: none;
    margin: 16px 0;
}
.crop-stage > img, .crop-stage > video { display: block; max-width: 100%; max-height: 70vh; }
.crop-frame {
    position: absolute;
    border: 2px solid var(--signal);
    box-shadow: 0 0 0 9999px rgba(21, 24, 28, .65);
    cursor: move;
    touch-action: none;
}
.crop-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    background: var(--signal);
    border: 2px solid var(--asphalt);
    border-radius: 2px;
    touch-action: none;
}
.crop-handle-nw { left: -10px; top: -10px; cursor: nwse-resize; }
.crop-handle-ne { right: -10px; top: -10px; cursor: nesw-resize; }
.crop-handle-sw { left: -10px; bottom: -10px; cursor: nesw-resize; }
.crop-handle-se { right: -10px; bottom: -10px; cursor: nwse-resize; }

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.segmented .btn { border: 0; border-radius: 0; min-height: 38px; }
.segmented .btn + .btn { border-left: 1px solid var(--line-strong); }
.segmented .btn.active { background: var(--asphalt); color: #fff; }

/* ---------- Login ---------- */

.login {
    max-width: 400px;
    margin: 10vh auto 0;
    padding: 32px;
}
.login-logo { display: block; width: 168px; height: auto; margin-bottom: 28px; }
.login h1 { margin-bottom: 24px; }
.login input { max-width: none; }
.login .btn { width: 100%; min-height: 44px; }

/* ---------- Account and two-factor login ---------- */

.warning { color: var(--amber); font-weight: 500; }

/* input.… so it outranks the general input[type=text] rule above */
input.code-input {
    font: 600 22px/1 var(--font-display);
    font-feature-settings: 'tnum' 1;
    letter-spacing: .12em;
    max-width: 220px;
}
.login input.code-input { max-width: none; }
.code-form > div:first-child { flex: 0 1 auto; }

/* The setup is a real sequence of steps, so it is numbered */
.setup-steps { list-style: none; margin: 0; padding: 0; counter-reset: step; max-width: 720px; }
.setup-steps > li { counter-increment: step; position: relative; padding-left: 72px; }
.setup-steps > li::before {
    content: counter(step);
    position: absolute;
    left: 24px;
    top: 20px;
    font: 700 32px/1 var(--font-display);
    color: var(--line-strong);
}
.setup-steps p { max-width: 60ch; }

.qr-code { display: inline-block; padding: 12px; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.qr-code svg { display: block; width: 220px; height: 220px; }

details summary { cursor: pointer; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
details[open] summary { color: var(--asphalt); }
.secret { font: 600 20px/1.4 var(--font-display); letter-spacing: .08em; word-break: break-all; margin: 12px 0 4px; }

.backup-codes {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 8px 24px;
    max-width: 560px;
    font: 600 20px/1.6 var(--font-display);
    letter-spacing: .06em;
}

@media print {
    .topbar, .actions, .page-header p { display: none !important; }
    body { background: #fff; }
    .panel { border: 0; padding: 0; }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .topbar { gap: 8px; height: auto; flex-wrap: wrap; padding-top: 8px; }
    .brand-logo { width: 126px; }
    .brand-logo + .brand-name { display: none; }
    .topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .topbar nav a { padding: 10px 10px 8px; }
    .topbar .logout { margin-left: auto; }
    .container { padding-top: 28px; }
    .setup-steps > li { padding-left: 24px; }
    .setup-steps > li::before { position: static; display: block; margin-bottom: 8px; }
    h1 { font-size: 27px; }
    .screens { gap: 36px 24px; }
    .screen-card { width: 100%; }
    .screen-card.portrait { width: 62%; }
    .screen-new { width: 100%; }
    .playlist-list .filmstrip { display: none; }
    .inline-form .form-submit { padding-top: 0; }
    .hide-sm { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
