/* Zakladny vzhlad je optimalizovany pre mobilny hovor a tmave prostredie. */
:root {
    color-scheme: dark;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #0c1220;
    color: #edf2f7;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: linear-gradient(145deg, #0c1220, #15233b); }
main { width: min(960px, 100%); margin: 0 auto; padding: 24px 16px 48px; }
h1 { margin: 0 0 20px; font-size: clamp(1.6rem, 5vw, 2.4rem); }
h2 { font-size: 1.15rem; }
.card { background: rgba(18, 29, 49, .94); border: 1px solid #2a3b59; border-radius: 14px; padding: 18px; margin-bottom: 16px; box-shadow: 0 12px 35px rgba(0,0,0,.22); }
label { display: block; margin-bottom: 6px; color: #b8c6dc; }
input, select { width: 100%; padding: 12px; margin-bottom: 14px; border: 1px solid #415473; border-radius: 9px; background: #0e192b; color: white; font-size: 16px; }
/* Admin prepinac ostane kompaktny a skryty pre technika. */
.check-option { display: flex; gap: 9px; align-items: center; margin-bottom: 14px; }
.check-option[hidden] { display: none; }
.check-option input { width: auto; margin: 0; }
button, .button { display: inline-block; border: 0; border-radius: 9px; padding: 11px 15px; background: #2f80ed; color: white; font-weight: 700; text-decoration: none; cursor: pointer; font-size: 15px; }
button.secondary { background: #334763; }
button.danger { background: #c33c4a; }
button:disabled { opacity: .55; cursor: wait; }
button[hidden] { display: none; }
/* Zakaznicka stranka vyplni mobilny viewport a nikdy nevytvori vertikalny scroll. */
.customer-page { height: 100vh; height: 100svh; height: 100dvh; min-height: 0; overflow: hidden; }
.customer-main { height: 100%; min-height: 0; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 8px; }
.customer-main .card { margin: 0; }
.customer-status-card { flex: 0 0 auto; padding: 10px; }
.customer-status-card .customer-call-status { margin: 0; }
.customer-video-card { flex: 1 1 auto; min-height: 0; padding: 8px; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; }
/* Zakaznicky nahlad je pasivny a nereaguje na tuknutie ani gesta nad videom. */
.customer-video-card .local-video { width: 100%; height: 100%; max-height: none; pointer-events: none; touch-action: none; user-select: none; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }
/* Technicke tlacidla tvoria rovnako velke polia aj na uzkom mobile. */
.technician-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.technician-actions button { width: 100%; min-height: 58px; text-align: center; }
/* Ikona mikrofonu meni farbu bez externych obrazkov alebo kniznic. */
button.mic-button { display: flex; align-items: center; justify-content: center; color: #fff; }
button.mic-button.on { background: #178653; }
button.mic-button.off { background: #c33c4a; }
button.mic-button.unavailable { background: #4b5565; }
.mic-button svg { width: 28px; height: 28px; fill: currentColor; }
.mic-button .mic-slash { display: none; }
.mic-button.off .mic-slash { display: block; }
.grow { flex: 1; }
.rooms { display: grid; gap: 12px; }
.room { border: 1px solid #314563; border-radius: 10px; padding: 14px; }
.room h3 { margin: 0 0 9px; }
.muted, #status:not(.customer-call-status) { color: #a9b8ce; }
.error { color: #ff9b9b; }
.presence { padding: 12px; border-radius: 9px; font-weight: 800; text-align: center; }
.presence.waiting { background: #59491e; color: #ffe59b; }
.presence.connecting { background: #173f63; color: #a8d9ff; }
.presence.connected { background: #164b36; color: #9af0c5; }
.presence.disconnected { background: #632936; color: #ffc0c8; }
/* Zakaznik dostane jeden velky a jednoznacny farebny stav hovoru. */
.customer-call-status { padding: 14px; border-radius: 9px; font-weight: 800; text-align: center; }
.customer-call-status.waiting { background: #59491e; color: #ffe59b; }
.customer-call-status.connected { background: #164b36; color: #9af0c5; }
.customer-call-status.disconnected { background: #632936; color: #ffc0c8; }
.diagnostics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 0; }
.diagnostics div { padding: 10px; border-radius: 8px; background: #0e192b; }
.diagnostics dt { color: #93a6c1; font-size: .82rem; }
.diagnostics dd { margin: 4px 0 0; font-weight: 700; }
/* Zhrnutie hovoru drzi media, technika a zakaznika v jednom bloku pod videom. */
.call-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; }
.call-summary-group { min-width: 0; padding: 6px; border-radius: 8px; background: #101b2d; }
.call-summary-group h3 { margin: 0 0 4px; font-size: .78rem; }
.call-summary-group .diagnostics { grid-template-columns: repeat(auto-fit, minmax(82px, 1fr)); gap: 3px; }
.call-summary-group .diagnostics div { padding: 4px; }
.technician-page .call-summary > summary { font-size: .84rem; }
.technician-page .call-summary-group .diagnostics dt { font-size: .6rem; }
.technician-page .call-summary-group .diagnostics dd { margin-top: 0; font-size: .72rem; }
.technician-page #status:empty { display: none; }
.video-grid { display: grid; gap: 12px; }
video { width: 100%; max-height: 70vh; border-radius: 12px; background: #03060b; object-fit: contain; }
.local-video { max-height: 55vh; }
/* Audio miestnost zobrazi jednoduchy symbol hovoru bez prazdneho video prvku. */
.audio-visual { width: 100%; height: 100%; min-height: 220px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: radial-gradient(circle, #27486f, #07101d 70%); color: #9af0c5; }
.audio-visual[hidden] { display: none; }
.audio-visual svg { width: min(32vw, 150px); height: min(32vw, 150px); fill: currentColor; }
.remote-card.audio-mode { min-height: min(58vh, 520px); }
.remote-card.audio-mode video { display: none; }
/* Zvacseny obraz vyplni displej a po otoceni telefonu sa prisposobi sirke. */
.remote-card { position: relative; touch-action: manipulation; }
/* Indikator zostava citatelny nad videom a neblokuje dotykove ovladanie. */
.mic-state { position: absolute; top: 24px; right: 24px; z-index: 2; width: 28px; height: 28px; padding: 5px; border-radius: 50%; background: #164b36; color: #9af0c5; pointer-events: none; }
.mic-state.off { background: #632936; color: #ffc0c8; }
.mic-state.unavailable { background: #4b5565; color: #e2e8f0; }
.mic-state[hidden] { display: none; }
.mic-state svg, .quality-state svg { width: 100%; height: 100%; fill: currentColor; }
.mic-state .mic-slash { display: none; }
.mic-state.off .mic-slash { display: block; }
/* Kvalita pouziva rovnaky citatelny indikator v beznom aj zvacsenom obraze. */
.quality-state { position: absolute; top: 24px; left: 24px; z-index: 2; width: 28px; height: 28px; padding: 5px; border-radius: 50%; background: #4b5565; color: #e2e8f0; pointer-events: none; }
.quality-state.good { background: #164b36; color: #9af0c5; }
.quality-state.weak { background: #59491e; color: #ffe59b; }
.quality-state.bad { background: #632936; color: #ffc0c8; }
.quality-state rect { opacity: .2; }
.quality-state.waiting rect { opacity: .45; }
.quality-state.bad .bar-1, .quality-state.weak .bar-1, .quality-state.weak .bar-2, .quality-state.good rect { opacity: 1; }
.remote-card.expanded .mic-state, .remote-card:fullscreen .mic-state, .remote-card:-webkit-full-screen .mic-state { top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); }
.remote-card.expanded .quality-state, .remote-card:fullscreen .quality-state, .remote-card:-webkit-full-screen .quality-state { top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); }
/* Cas hovoru je maly a neprekryva horne stavove indikatory. */
.call-duration { position: absolute; bottom: 24px; left: 24px; z-index: 2; padding: 4px 7px; border-radius: 999px; background: rgba(0,0,0,.68); color: #fff; font-size: .68rem; font-weight: 800; font-variant-numeric: tabular-nums; pointer-events: none; }
.remote-card.expanded .call-duration, .remote-card:fullscreen .call-duration, .remote-card:-webkit-full-screen .call-duration { bottom: max(14px, env(safe-area-inset-bottom)); left: max(14px, env(safe-area-inset-left)); }
/* CSS fullscreen kopiruje viditelny viewport iOS aj pri zobrazenom adresnom riadku. */
.remote-card.expanded { position: fixed; left: var(--expanded-left, 0); top: var(--expanded-top, 0); width: var(--expanded-width, 100vw); height: var(--expanded-height, 100dvh); z-index: 1000; margin: 0; padding: 0; border: 0; border-radius: 0; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.remote-card.expanded video, .remote-card:fullscreen video, .remote-card:-webkit-full-screen video { width: 100%; height: 100%; max-height: none; border-radius: 0; }
.remote-card:fullscreen, .remote-card:-webkit-full-screen { margin: 0; padding: 0; border: 0; border-radius: 0; background: #000; overflow: hidden; }
body.video-expanded { overflow: hidden; overscroll-behavior: none; touch-action: none; }
/* Technicka a hostovska cast su kompaktnejsie, zakaznicke velke ovladanie ostava bez zmeny. */
.page-loading #title { visibility: hidden; }
/* Technicka stranka nic nezobrazi, kym server nepotvrdi vlastnictvo zamku miestnosti. */
.technician-page.page-loading body { visibility: hidden; }
/* Technicke video sa ukaze az po potvrdeni video rezimu miestnosti. */
.technician-page:not(.technician-mode-ready) #remote-card { display: none; }
.technician-page main { width: min(760px, 100%); padding: 8px 8px 22px; }
.technician-page h1, .guest-page h1 { margin-bottom: 8px; font-size: clamp(1.2rem, 3.6vw, 1.6rem); }
.technician-page h2 { margin: 0 0 5px; font-size: .84rem; }
.technician-page .card, .guest-page .card { padding: 9px; margin-bottom: 7px; border-radius: 9px; }
.technician-page .technician-actions, .guest-page .technician-actions { gap: 5px; }
.technician-page .technician-actions button, .guest-page .technician-actions button { min-height: 40px; padding: 7px 9px; font-size: 13px; }
.technician-page .presence, .guest-page .presence { padding: 7px; margin: 0 0 6px; font-size: .9rem; }
.technician-page .rooms { gap: 6px; }
.technician-page .room { padding: 6px; }
.technician-page .diagnostics { grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 5px; }
.technician-page .diagnostics div { padding: 4px; }
.technician-page .diagnostics dt { font-size: .6rem; }
.technician-page .diagnostics dd { margin-top: 1px; font-size: .72rem; }
/* Vsetky pomocne sekcie technika pouzivaju rovnaku kompaktnu typografiu ako stav hovoru. */
.technician-page .connection-details > summary { font-size: .84rem; }
.technician-page .room h3, .technician-page .guest-form label { font-size: .76rem; }
.technician-page .room p, .technician-page .muted { font-size: .7rem; }
.technician-page .call-info p { font-size: .68rem; }
.technician-page input { padding: 6px; margin-bottom: 5px; font-size: 13px; }
/* Tlacidlo pozvanky patri ku kompaktnemu formularu hosti, nie k hlavnemu ovladaniu hovoru. */
.technician-page #guest-form button { min-height: 30px; padding: 4px 7px; font-size: .72rem; }
.technician-page .mic-state, .technician-page .quality-state { top: 14px; width: 24px; height: 24px; padding: 4px; }
.technician-page .mic-state { right: 14px; }
.technician-page .quality-state { left: 14px; }
.technician-page .call-duration { bottom: 14px; left: 14px; }
.guest-page main { width: min(680px, 100%); padding: 8px 8px 22px; }
/* Hostovske media sa ukazu az po rozpoznani video alebo audio rezimu. */
.guest-page:not(.guest-media-ready) #guest-media { display: none; }
/* Konferencny zoznam kompaktne ukazuje mikrofon a kvalitu kazdeho ucastnika. */
.conference-participant h3 { margin: 0 0 6px; font-size: .92rem; }
.conference-details { display: flex; flex-wrap: wrap; gap: 6px; }
.conference-icon { display: inline-flex; width: 27px; height: 27px; padding: 5px; border-radius: 50%; background: #4b5565; color: #e2e8f0; }
.conference-icon svg { width: 100%; height: 100%; fill: currentColor; }
.conference-icon.microphone.on, .conference-icon.quality.good { background: #164b36; color: #9af0c5; }
.conference-icon.microphone.off, .conference-icon.quality.bad, .conference-icon.quality.lost { background: #632936; color: #ffc0c8; }
/* Zamietnute opravnenie odlisuje vykricnik od bezne stlmeneho mikrofonu. */
.conference-icon.microphone.denied { position: relative; background: #8b1d2c; color: #fff; box-shadow: 0 0 0 2px #ff8d9b; }
.conference-icon.microphone.denied::after { content: "!"; position: absolute; top: -7px; right: -6px; width: 15px; height: 15px; border-radius: 50%; background: #ff334f; color: #fff; font: 800 11px/15px sans-serif; text-align: center; }
.conference-icon.quality.weak { background: #59491e; color: #ffe59b; }
.conference-icon.microphone .mic-slash { display: none; }
.conference-icon.microphone.off .mic-slash, .conference-icon.microphone.denied .mic-slash { display: block; }
.conference-icon.quality rect { opacity: .2; }
.conference-icon.quality.good rect, .conference-icon.quality.weak .bar-1, .conference-icon.quality.weak .bar-2, .conference-icon.quality.bad .bar-1 { opacity: 1; }
/* Diagnostika ucastnika zostava zbalena, kym ju cielene neotvori. */
.connection-details summary { cursor: pointer; font-weight: 800; }
.connection-details[open] summary { margin-bottom: 8px; }
.guest-page .connection-details .diagnostics { grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 6px; }
.guest-page .connection-details .diagnostics div { padding: 7px; }
/* Spolocny casovy blok opticky oddeli informacie od tlacidiel oboch roli. */
.call-info { margin: 7px 0 12px; padding: 8px 10px; border: 1px solid #314563; border-radius: 8px; background: #0e192b; }
.room-expiry, .conference-duration { margin: 0; color: #b9c8dc; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.call-info .conference-duration { margin-top: 4px; }
.conference-duration { color: #9af0c5; }
/* Karty dashboardu si ponechaju povodne kompaktne odsadenie expiracie. */
.dashboard-page .room-expiry { margin: 5px 0; }
/* Dashboard oddeli vytvorenie hovoru od kompaktneho zoznamu aktivnych miestnosti. */
.dashboard-page main { width: min(760px, 100%); padding: 12px 10px 28px; }
.dashboard-page .dashboard-header { margin-bottom: 9px; }
.dashboard-page .dashboard-header h1 { margin: 0; font-size: clamp(1.35rem, 4vw, 1.8rem); }
.dashboard-page .dashboard-header button { padding: 8px 11px; font-size: 13px; }
.dashboard-page h2 { margin: 0 0 9px; font-size: 1rem; }
.dashboard-page .create-card { padding: 12px; margin-bottom: 14px; border-color: #315f91; background: rgba(20, 39, 65, .96); }
.dashboard-page input, .dashboard-page select { padding: 8px 10px; margin-bottom: 9px; font-size: 14px; }
.dashboard-page .check-option { margin-bottom: 9px; font-size: .88rem; }
.dashboard-page #create > button { width: 100%; padding: 9px 12px; font-size: 14px; }
.dashboard-page .rooms-panel { padding: 12px; border: 1px solid #263750; border-radius: 11px; background: rgba(8, 17, 31, .72); }
.dashboard-page .rooms { gap: 7px; }
.dashboard-page .active-room-card { margin: 0; padding: 10px; border-left: 4px solid #2f80ed; background: rgba(18, 29, 49, .98); box-shadow: none; }
.dashboard-page .active-room-card h3 { margin: 0; font-size: .98rem; }
.dashboard-page .room-details { margin: 3px 0 8px; color: #93a6c1; font-size: .78rem; }
.dashboard-page .active-room-card .actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.dashboard-page .active-room-card .actions button, .dashboard-page .active-room-card .actions .button { width: 100%; padding: 7px 5px; font-size: 12px; text-align: center; }
.dashboard-page .rooms.empty { padding: 12px; border: 1px dashed #3c4e69; border-radius: 8px; color: #93a6c1; font-size: .88rem; text-align: center; }
/* Kompaktne karty nesmu pridat okraje spat do technickeho fullscreenu. */
.technician-page .remote-card.expanded, .technician-page .remote-card:fullscreen, .technician-page .remote-card:-webkit-full-screen { margin: 0; padding: 0; border: 0; border-radius: 0; }
/* Mobil zobrazi tri skupiny pod sebou a ich hodnoty v hustej dvojstlpcovej mriezke. */
@media (max-width: 600px) {
    .technician-page .call-summary[open] { padding: 7px; }
    .technician-page .call-summary[open] > summary { margin-bottom: 4px; }
    .technician-page .call-summary-grid { grid-template-columns: 1fr; gap: 4px; }
    .technician-page .call-summary-group { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 4px; padding: 4px; }
    .technician-page .call-summary-group h3 { margin: 5px 0 0; font-size: .66rem; }
    .technician-page .call-summary-group .diagnostics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
    .technician-page .call-summary-group .diagnostics div { min-width: 0; padding: 3px 4px; border-radius: 5px; }
    .technician-page .call-summary-group .diagnostics dt { font-size: .52rem; line-height: 1.1; }
    .technician-page .call-summary-group .diagnostics dd { margin-top: 1px; font-size: .64rem; line-height: 1.15; overflow-wrap: anywhere; }
}
@media (min-width: 760px) { .video-grid.two { grid-template-columns: 2fr 1fr; } }
