/* Kľúčik – štýly pre deti. Farby sú premenné, takže témy stačí prepnúť na <body data-theme="…">. */

:root {
    --bg: #eaf6ff;
    --bg-2: #d4ecff;
    --card: #ffffff;
    --ink: #1d2a4d;
    --muted: #5b6b8c;
    --accent: #3a86ff;
    --accent-2: #ff006e;
    --accent-ink: #ffffff;
    --ok: #06d6a0;
    --warn: #ffb703;
    --line: rgba(29, 42, 77, 0.12);
    --shadow: 0 10px 30px rgba(29, 42, 77, 0.18);
    --radius: 22px;
    --font: "Baloo 2", "Segoe UI", system-ui, sans-serif;
}

/* Farebné témy (výber používateľa, uložený v prehliadači). */
body[data-theme="sun"] {
    --bg: #fff7d6; --bg-2: #ffe8a3; --accent: #ff9f1c; --accent-2: #e71d36; --ink: #3d2b00; --muted: #7a6320;
}
body[data-theme="mint"] {
    --bg: #e6fff6; --bg-2: #b9f5e0; --accent: #06a77d; --accent-2: #ff5d8f; --ink: #0c3b2e; --muted: #3d6e60;
}
body[data-theme="grape"] {
    --bg: #f3e8ff; --bg-2: #dcc6ff; --accent: #8338ec; --accent-2: #ff006e; --ink: #2b1651; --muted: #6a5494;
}
body[data-theme="night"] {
    --bg: #14183a; --bg-2: #222a5c; --card: #1f2650; --ink: #f2f5ff; --muted: #b7c0e8;
    --accent: #5ec8ff; --accent-2: #ff6fb1; --accent-ink: #14183a; --line: rgba(255, 255, 255, 0.12);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--font);
    font-size: 18px;
    color: var(--ink);
    background:
        radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.7) 0 6%, transparent 7%),
        radial-gradient(circle at 90% 20%, rgba(255, 255, 255, 0.6) 0 5%, transparent 6%),
        linear-gradient(160deg, var(--bg), var(--bg-2));
    background-color: var(--bg);
    background-attachment: fixed;
}

h1, h2, h3 { margin: 0 0 .4em; line-height: 1.15; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: .4em 0; }
a { color: var(--accent); }
.small { font-size: .85rem; color: var(--muted); }
.center { text-align: center; }

/* ---- Tlačidlá a polia ---- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4em;
    font: inherit; font-weight: 800; color: var(--accent-ink); background: var(--accent);
    border: 0; border-radius: 999px; padding: .55em 1.1em; cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
    transition: transform .08s ease, box-shadow .08s ease;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.big { font-size: 1.15rem; padding: .7em 1.4em; }
.btn.small { font-size: .9rem; padding: .4em .9em; }
.btn.ghost { background: var(--card); color: var(--ink); border: 2px solid var(--line); box-shadow: none; }

input, select, textarea {
    font: inherit; color: var(--ink); background: var(--card);
    border: 2px solid var(--line); border-radius: 14px; padding: .55em .8em; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; }
label { display: grid; gap: .3em; font-weight: 700; }
label.check { display: flex; align-items: center; gap: .4em; font-weight: 700; }
label.check input { width: auto; }

.stack { display: grid; gap: .8rem; }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: flex-end; }

.alert {
    background: #ffe3ea; color: #8a0030; border-radius: 14px; padding: .7em 1em; font-weight: 700;
}

.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.6rem;
}

/* ---- Prihlásenie a registrácia ---- */

body.landing { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.landing-card { width: min(440px, 100%); display: grid; gap: .8rem; text-align: left; }
.landing-card .stack { margin-top: .4rem; }
.hero-logo {
    font-size: 4rem; text-align: center; width: 110px; height: 110px; margin: 0 auto;
    display: grid; place-items: center; border-radius: 36px;
    background: linear-gradient(135deg, #ffd166, #ff6fb1);
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
    animation: bob 3s ease-in-out infinite;
}
.lead { font-size: 1.1rem; color: var(--muted); }
.theme-picker { display: flex; gap: .5rem; flex-wrap: wrap; }
.swatch {
    width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; cursor: pointer;
    background: var(--c); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); padding: 0;
}
.swatch[aria-pressed="true"] { outline: 3px solid var(--ink); outline-offset: 2px; }

@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }

/* Logá: emoji na farebnom podklade */

.avatar {
    display: inline-grid; place-items: center; flex: 0 0 auto;
    width: 40px; height: 40px; border-radius: 14px; font-size: 1.4rem;
    background: var(--logo, #ff8a3d); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.avatar.big { width: 64px; height: 64px; border-radius: 20px; font-size: 2.2rem; }

.logo-pick { border: 0; padding: 0; margin: 0; }
.logo-pick legend { font-weight: 800; margin-bottom: .4rem; }
.logo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: .5rem; }
.logo-choice { position: relative; cursor: pointer; }
.logo-choice input { position: absolute; opacity: 0; pointer-events: none; }
.logo-choice span {
    display: grid; place-items: center; height: 52px; border-radius: 16px; font-size: 1.7rem;
    background: var(--logo); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
    transition: transform .1s ease;
}
.logo-choice:hover span { transform: scale(1.08); }
.logo-choice input:checked + span { outline: 4px solid var(--ink); outline-offset: 2px; }
.logo-choice input:focus-visible + span { outline: 3px solid var(--accent-2); }

/* ---- Hlavička ---- */

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
    padding: .6rem 1rem; background: var(--card); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
.brand { font-size: 1.5rem; font-weight: 800; }
.topbar-right { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; }
.me {
    display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-weight: 800;
    color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 999px;
    padding: .25rem .8rem .25rem .25rem; cursor: pointer;
}

/* ---- Rozloženie ---- */

.app {
    display: grid; grid-template-columns: 280px 1fr; gap: 1rem; padding: 1rem;
    max-width: 1280px; margin: 0 auto;
}
.sidebar, .main { min-width: 0; }
.sidebar {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem; display: flex; flex-direction: column; gap: .8rem; align-self: start;
}
.group-list { display: grid; gap: .4rem; }
.group-link {
    display: flex; align-items: center; gap: .6rem; padding: .4rem; border-radius: 16px;
    color: var(--ink); text-decoration: none; font-weight: 700;
}
.group-link:hover { background: var(--bg); }
.group-link.active { background: var(--bg-2); outline: 2px solid var(--accent); }
.join-form { display: grid; gap: .5rem; border-top: 2px dashed var(--line); padding-top: .8rem; }
.join-form .btn { justify-self: end; }
.join-form input { text-transform: uppercase; letter-spacing: .15em; }

.welcome { display: grid; gap: .6rem; }
.tips { padding-left: 1.2rem; margin: 0; }
.tips li { margin: .4rem 0; }

.group-head {
    display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: .8rem 1rem; margin-bottom: 1rem;
}
.group-head h2 { margin: 0; flex: 1 1 auto; }
.head-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.layout { display: grid; grid-template-columns: 1fr 240px; gap: 1rem; align-items: start; }
.chat-col {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem; display: flex; flex-direction: column; gap: .7rem; min-width: 0;
}
.side-col {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1rem; display: grid; gap: .6rem; align-content: start;
}

.notice {
    display: flex; align-items: center; justify-content: space-between; gap: .6rem;
    background: var(--warn); color: #3d2b00; border-radius: 14px; padding: .5rem .8rem; font-weight: 800;
}

.messages {
    height: min(58vh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: .6rem;
    padding: .4rem; border-radius: 16px; background: var(--bg); scroll-behavior: smooth;
}

.msg { display: flex; gap: .6rem; align-items: flex-start; max-width: 92%; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
/* Bublina má farbu autora správy (jeho logo), takže každý autor má vlastnú farbu. */
.bubble {
    background: var(--card);
    background: color-mix(in srgb, var(--logo, #ff8a3d) 26%, var(--card));
    border-radius: 18px 18px 18px 6px; padding: .5rem .8rem;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.06); min-width: 0; overflow-wrap: anywhere;
}
.msg.mine .bubble { color: var(--ink); border-radius: 18px 18px 6px 18px; }
.meta { display: flex; align-items: center; gap: .4rem; font-size: .85rem; flex-wrap: wrap; }
.meta time { color: var(--muted); }
.msg.mine .meta time { color: inherit; opacity: .8; }
.tag { background: var(--ink); color: var(--bg); border-radius: 999px; padding: 0 .5em; font-size: .75rem; }
.del { border: 0; background: transparent; cursor: pointer; font-size: .9rem; padding: 0 .2rem; }
.text { margin: .2rem 0 0; font-size: 1.05rem; white-space: pre-wrap; }
.text.gone { color: var(--muted); font-style: italic; }

.composer { display: grid; gap: .5rem; }
.composer-row { display: flex; align-items: center; gap: .6rem; justify-content: space-between; flex-wrap: wrap; }
.composer textarea { resize: vertical; min-height: 56px; }
.counter { margin-left: auto; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; }

.members { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.member { display: flex; align-items: center; gap: .5rem; padding: .25rem; border-radius: 14px; }
.member .avatar { width: 34px; height: 34px; font-size: 1.1rem; border-radius: 12px; }
.member .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .dot { font-size: .75rem; color: var(--muted); }
.member.on .dot { color: var(--ok); font-weight: 800; }

.scores { margin: 0; padding-left: 0; list-style: none; display: grid; gap: .4rem; }
.scores li { display: flex; align-items: center; gap: .5rem; }
.scores li .name { flex: 1; }
.scores li.mine { font-weight: 800; color: var(--accent-2); }
.scores .avatar { width: 30px; height: 30px; font-size: 1rem; border-radius: 10px; }

/* ---- Ankety ---- */

.poll { display: grid; gap: .4rem; min-width: min(300px, 70vw); }
.poll-q { font-weight: 800; margin: 0; }
.poll-opt {
    position: relative; display: flex; justify-content: space-between; gap: .5rem; align-items: center;
    font: inherit; font-weight: 700; color: var(--ink); text-align: left; cursor: pointer;
    background: var(--bg); border: 2px solid var(--line); border-radius: 14px; padding: .5rem .7rem; overflow: hidden;
}
.poll-opt:hover:not(:disabled) { border-color: var(--accent); }
.poll-opt:disabled { cursor: default; }
.poll-opt.picked { border-color: var(--accent-2); }
.poll-opt .bar {
    position: absolute; inset: 0 auto 0 0; background: var(--bg-2); z-index: 0;
    transition: width .4s ease;
}
.poll-opt .opt-text, .poll-opt .opt-votes { position: relative; z-index: 1; }
.poll-foot { margin-top: .2rem; }
.msg.mine .poll-opt { color: var(--ink); }

/* ---- Dialógy, hra, upozornenia ---- */

dialog {
    border: 0; border-radius: var(--radius); padding: 1.4rem; width: min(480px, calc(100vw - 32px));
    background: var(--card); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 16, 40, 0.5); }
dialog.game-dialog { width: min(420px, calc(100vw - 32px)); }
dialog fieldset { border: 0; padding: 0; }
.invite-code {
    font-size: 2.2rem; font-weight: 800; letter-spacing: .2em; text-align: center; margin: .4rem 0;
    background: var(--bg); border-radius: 18px; padding: .6rem;
}
#game-canvas {
    width: 100%; max-width: 360px; height: auto; border-radius: 18px; background: #7bd389;
    touch-action: none; display: block; margin: 0 auto; box-shadow: inset 0 0 0 4px var(--card);
}

.toast {
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 50;
    background: var(--ink); color: var(--bg); padding: .7em 1.2em; border-radius: 999px;
    font-weight: 800; box-shadow: var(--shadow); max-width: calc(100vw - 32px); text-align: center;
}
.toast[hidden], .notice[hidden] { display: none; }

/* ---- Správa členov (správca skupiny) ---- */

.member { flex-wrap: wrap; }
.member-admin { display: flex; flex-wrap: wrap; gap: .3rem; width: 100%; padding-left: 46px; }
.member-admin select { width: auto; flex: 1 1 110px; padding: .3em .5em; font-size: .85rem; }

/* ---- Hlasová konferencia, tabuľa, zariadenie ---- */

.call-box {
    display: grid; gap: .5rem; padding: .8rem; border-radius: 18px;
    background: var(--bg); border: 2px dashed var(--line);
}
.call-box h3 { margin: 0; }
.device-row select { margin-top: .2rem; }
.call-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.call-user {
    display: flex; align-items: center; gap: .5rem; padding: .25rem .4rem; border-radius: 14px;
    transition: box-shadow .15s ease, background .15s ease;
}
.call-user .avatar { width: 32px; height: 32px; font-size: 1rem; border-radius: 11px; }
.call-user .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-user.speaking { background: var(--bg-2); box-shadow: 0 0 0 3px var(--ok); }
.call-mark { font-size: .95rem; }
.call-mark.muted { opacity: .6; }
.btn.talking { background: var(--ok); color: #fff; box-shadow: 0 0 0 4px var(--bg-2); }
/* Nahrávanie hlasovky: tlačidlo svieti a pulzuje, kým sa nahráva. */
.btn.recording { background: #e5484d; color: #fff; animation: rec-glow 1s ease-in-out infinite; }
@keyframes rec-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .7); }
    50% { box-shadow: 0 0 18px 6px rgba(229, 72, 77, .55); }
}
@media (prefers-reduced-motion: reduce) { .btn.recording { animation: none; } }
.swatch.active, .btn.active { outline: 3px solid var(--ink); outline-offset: 2px; }
.board-dialog { width: min(900px, calc(100vw - 24px)); }
.board-tools { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.board-tools select { width: auto; padding: .35em .6em; }
#board-canvas {
    width: 100%; height: auto; aspect-ratio: 1200 / 750; background: #fff;
    border-radius: 16px; box-shadow: inset 0 0 0 3px var(--line); touch-action: none; cursor: crosshair; display: block;
}
.board-wrap { position: relative; }
.board-labels { position: absolute; inset: 0; pointer-events: none; }
.board-label {
    position: absolute; transform: translate(-50%, -130%); padding: .1em .45em; border-radius: 8px;
    background: var(--ink); color: #fff; font-size: .75rem; font-weight: 700; white-space: nowrap;
}
.board-images { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; max-height: 180px; overflow: auto; }
.board-images button { width: 100%; text-align: left; }
/* Tlačidlo konferencie je len na mobile; na počítači je panel v bočnom stĺpci. */
.call-fab { display: none; }
[data-device="mobile"] .call-fab {
    display: inline-flex; position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
    z-index: 20; font-size: 1.1rem; padding: .8em 1.6em; box-shadow: var(--shadow);
}
[data-device="mobile"] .device-row { display: none; }
[data-device="mobile"] .chat-col { padding-bottom: 5rem; }

/* ---- Mobil ---- */

@media (max-width: 860px) {
    .app { grid-template-columns: 1fr; padding: .6rem; }
    .sidebar { order: 2; }
    .main { order: 1; }
    .layout { grid-template-columns: 1fr; }
    .messages { height: 52vh; }
    .msg { max-width: 100%; }
    body { font-size: 17px; }
}

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

/* Priame správy */
.direct-btn { padding: .15em .5em; }
.btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.direct-card { display: grid; gap: .3rem; padding: .6rem; border-radius: 14px; background: var(--card-2, rgba(0, 0, 0, .04)); }
.direct-image { max-width: 100%; max-height: 50vh; border-radius: 12px; }
.direct-card audio { width: 100%; }

/* Prepínač jazyka */
.lang-switch { display: flex; gap: .35rem; justify-content: center; margin: .5rem 0; }
.lang-switch a { padding: .15em .6em; border-radius: 999px; font-weight: 800; text-decoration: none; color: var(--muted); }
.lang-switch a.active { background: var(--accent, #3a86ff); color: #fff; }

/* Prílohy v skupine */
.attach { cursor: pointer; position: relative; }
.chat-image { display: block; max-width: 100%; max-height: 260px; border-radius: 12px; margin-top: 4px; }
.file-link { display: inline-block; margin-top: 4px; word-break: break-all; }
.invite-link { word-break: break-all; font-size: 0.9em; }

/* Odznaky nových správ */
.unread:not([hidden]) { display: inline-block; min-width: 1.5em; padding: 0 6px; margin-left: 6px; border-radius: 999px; background: #ff5d8f; color: #fff; font-size: 0.8em; text-align: center; line-height: 1.5; }
.wide { width: 100%; margin-bottom: 8px; }
.unread.board:not([hidden]) { background: #3a86ff; }

/* ---- Správa aplikácie (správca) ---- */
.admin-page { width: min(760px, 100%); margin: 0 auto; padding: 16px; }
.admin-row { justify-content: flex-start; }
.admin-info { flex: 1; display: grid; gap: .1rem; min-width: 0; }
.admin-row form { margin: 0; }
