/* ═══════════════════════════════════════════════════════════════════════════
   Asistent — plovoucí okno s dotazy.

   Vkládá ho js/assistant.js na každou stránku, proto je styl ve sdíleném
   souboru a ne v <style> jedné stránky. Barvy jdou z proměnných webu,
   takže tmavý režim funguje sám.
   ═══════════════════════════════════════════════════════════════════════════ */

.asst {
    position: fixed; right: 18px; bottom: 18px; z-index: 400;
    display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
    font-family: 'Inter', system-ui, sans-serif;
}

/* ── Plovoucí tlačítko ─────────────────────────────────────────────────── */
.asst-fab {
    width: 54px; height: 54px; flex-shrink: 0; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%; cursor: pointer;
    background: var(--accent, #00a2e8); color: #fff;
    box-shadow: 0 8px 26px rgba(0,110,170,.38);
    transition: transform .18s, box-shadow .18s;
}
.asst-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(0,110,170,.5); }
.asst-fab svg   { width: 24px; height: 24px; }
.asst-fab .asst-ico-close { display: none; }
.asst.is-open .asst-fab .asst-ico-close { display: block; }
.asst.is-open .asst-fab .asst-ico-open  { display: none; }
html[data-theme="dark"] .asst-fab { color: #04121c; }

/* ── Panel ─────────────────────────────────────────────────────────────── */
/* Vlastní display přebíjí výchozí chování atributu hidden, takže panel
   je potřeba schovat výslovně — jinak je pořád vidět. */
.asst-panel[hidden] { display: none; }

.asst-panel {
    width: min(370px, calc(100vw - 36px));
    max-height: min(560px, calc(100vh - 130px));
    display: flex; flex-direction: column; overflow: hidden;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e3eaf3);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(10,30,60,.22);
}
html[data-theme="dark"] .asst-panel { box-shadow: 0 24px 60px rgba(0,0,0,.6); }

.asst-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 10px; padding: .95rem 1rem .8rem;
    border-bottom: 1px solid var(--border, #e3eaf3);
}
.asst-head strong { display: block; font-size: .92rem; font-weight: 800; color: var(--text); }
.asst-head span   { display: block; font-size: .72rem; color: var(--text-m); margin-top: .1rem; }
.asst-x {
    flex-shrink: 0; width: 28px; height: 28px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; border-radius: 7px;
    color: var(--text-m); cursor: pointer; transition: background .15s, color .15s;
}
.asst-x:hover { background: rgba(0,0,0,.06); color: var(--text); }
.asst-x svg   { width: 15px; height: 15px; }
html[data-theme="dark"] .asst-x:hover { background: rgba(255,255,255,.1); }

/* ── Konverzace ────────────────────────────────────────────────────────── */
.asst-log {
    flex: 1; overflow-y: auto; padding: 1rem;
    display: flex; flex-direction: column; gap: .7rem;
}
.asst-msg { max-width: 88%; font-size: .86rem; line-height: 1.6; }
.asst-msg p { margin: 0; }

.asst-bot {
    align-self: flex-start;
    background: var(--bg-2, #f5f9fd);
    border: 1px solid var(--border, #e3eaf3);
    color: var(--text-2);
    padding: .65rem .8rem; border-radius: 12px 12px 12px 4px;
}
.asst-me {
    align-self: flex-end;
    background: var(--accent, #00a2e8); color: #fff;
    padding: .55rem .8rem; border-radius: 12px 12px 4px 12px;
    font-weight: 500;
}
html[data-theme="dark"] .asst-me { color: #04121c; }

/* Bublina, která nese jen nabídku otázek — bez pozadí, ať to nevypadá
   jako by asistent poslal prázdnou zprávu. */
.asst-plain { background: none; border: none; padding: 0; max-width: 100%; }

.asst-hint { font-size: .76rem; color: var(--text-m); margin-bottom: .45rem !important; }

.asst-link {
    display: inline-block; margin-top: .55rem;
    font-size: .8rem; font-weight: 600; color: var(--accent);
    text-decoration: none;
}
.asst-link:hover { text-decoration: underline; }

.asst-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .55rem; }
.asst-chip {
    font-family: inherit; font-size: .75rem; line-height: 1.35;
    text-align: left; padding: .35rem .6rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-2, var(--border2, #d0dcea));
    border-radius: 50px; color: var(--text-2); cursor: pointer;
    transition: border-color .15s, color .15s;
}
.asst-chip:hover { border-color: var(--accent); color: var(--accent); }

/* Tři tečky, než dorazí odpověď. */
.asst-typing { display: flex; gap: 4px; align-items: center; padding: .75rem .8rem; }
.asst-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-m); opacity: .5;
    animation: asst-blink 1.1s infinite ease-in-out;
}
.asst-dot:nth-child(2) { animation-delay: .18s; }
.asst-dot:nth-child(3) { animation-delay: .36s; }
@keyframes asst-blink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

/* ── Vstup ─────────────────────────────────────────────────────────────── */
.asst-form {
    display: flex; gap: .5rem; padding: .75rem;
    border-top: 1px solid var(--border, #e3eaf3);
}
.asst-input {
    flex: 1; min-width: 0; font-family: inherit; font-size: .85rem;
    padding: .6rem .75rem; border-radius: 9px;
    border: 1px solid var(--border-2, var(--border2, #d0dcea));
    background: var(--bg, #fff); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.asst-input::placeholder { color: var(--text-m); }
.asst-input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,162,232,.14);
}
html[data-theme="dark"] .asst-input { background: var(--bg-2); }

.asst-send {
    flex-shrink: 0; width: 38px; height: 38px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 9px; cursor: pointer;
    background: var(--accent, #00a2e8); color: #fff;
    transition: opacity .15s;
}
.asst-send:hover { opacity: .88; }
.asst-send svg   { width: 17px; height: 17px; }
html[data-theme="dark"] .asst-send { color: #04121c; }

/* Kontejner nechytá kliky; jen tlačítko a okno. */
.asst { pointer-events: none; }
.asst-fab, .asst-panel { pointer-events: auto; }

/* Na úzkém displeji ať okno nepřekrývá celou stránku. */
@media (max-width: 460px) {
    .asst { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
    .asst-fab { align-self: flex-end; }
    .asst-panel { width: 100%; max-height: calc(100vh - 120px); }
}

@media (prefers-reduced-motion: reduce) {
    .asst-fab, .asst-chip, .asst-input, .asst-send { transition: none; }
    .asst-dot { animation: none; opacity: .5; }
}

/* Na mobilu je dole pevná navigační lišta (css/nav.css) — asistent nad ni. */
@media (max-width: 860px) {
    .asst { bottom: calc(18px + 64px + env(safe-area-inset-bottom, 0px)); }
    .asst-panel { max-height: min(560px, calc(100vh - 200px)); }
}
@media (max-width: 460px) {
    .asst { bottom: calc(12px + 64px + env(safe-area-inset-bottom, 0px)); }
}
