/* ========================================
   STELLA - plovoucí chat okno (inc/ai-radce-widget.php)

   Barvy zůstávají světlé i při tmavém režimu systému (web je světlý).
   z-index: tlačítko 1000 (pod hlavičkou 1002 a mobilním menu 1003),
   otevřené okno 1004 (nad hlavičkou, pod modálním hledáním 1005).
======================================== */

.msn-stella {
    --stella-blue: #0b84ff;
    --stella-green: #34c759;
    --stella-ink: #171717;
    --stella-bg: #fbfaf7;
    --stella-line: #ece9e2;
    --stella-muted: #85817a;
    color-scheme: light;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    color: var(--stella-ink);
}

.msn-stella *,
.msn-stella *::before,
.msn-stella *::after {
    box-sizing: border-box;
}

/* ---------- Avatar ---------- */

.msn-stella-avatar {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #cdd8e6;
}

.msn-stella-avatar-img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.msn-stella-avatar-monogram {
    font-family: var(--msn-display-serif, 'Fraunces', Georgia, serif);
    font-weight: 600;
    color: #33475b;
    line-height: 1;
}

.msn-stella-avatar--launcher {
    width: 44px;
    height: 44px;
    border: 2px solid #fff;
}

.msn-stella-avatar--launcher .msn-stella-avatar-monogram { font-size: 20px; }

.msn-stella-avatar--head {
    width: 44px;
    height: 44px;
}

.msn-stella-avatar--head .msn-stella-avatar-monogram { font-size: 20px; }

.msn-stella-avatar--msg {
    width: 28px;
    height: 28px;
}

.msn-stella-avatar--msg .msn-stella-avatar-monogram { font-size: 13px; }

.msn-stella-avatar-dot {
    display: none;
}

/* ---------- Plovoucí tlačítko ---------- */

.msn-stella-launcher {
    position: fixed;
    right: calc(20px + env(safe-area-inset-right, 0px));
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 6px 18px 6px 6px;
    border: 0;
    border-radius: 999px;
    background: var(--stella-ink);
    color: #fff;
    font: 600 15px/1 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .12);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.msn-stella-launcher:hover {
    background: #000;
}

.msn-stella-launcher:focus-visible,
.msn-stella-close:focus-visible,
.msn-stella-reset:focus-visible,
.msn-stella-closed-reset:focus-visible,
.msn-stella-send:focus-visible,
.msn-stella-chip:focus-visible,
.msn-stella-input:focus-visible {
    outline: 2px solid var(--stella-blue);
    outline-offset: 2px;
}

.msn-stella-launcher-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--stella-green);
}

.msn-stella-launcher[aria-expanded="true"] {
    display: none;
}

/* ---------- Okno ---------- */

.msn-stella-panel {
    position: fixed;
    right: calc(20px + env(safe-area-inset-right, 0px));
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    z-index: 1004;
    display: flex;
    flex-direction: column;
    width: 360px;
    height: 560px;
    max-height: calc(100dvh - 40px);
    max-width: calc(100vw - 40px);
    overflow: hidden;
    border-radius: 14px;
    background: var(--stella-bg);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22), 0 3px 10px rgba(0, 0, 0, .1);
}

.msn-stella-panel[hidden] {
    display: none;
}

.msn-stella-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 8px 12px 14px;
    background: #fff;
    border-bottom: 1px solid var(--stella-line);
}

.msn-stella-head-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-width: 0;
}

.msn-stella-name {
    font-family: var(--msn-display-serif, 'Fraunces', Georgia, serif);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--stella-ink);
}

.msn-stella-sub {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12.5px;
    max-width: 100%;
    color: var(--stella-muted);
    white-space: nowrap;
}

.msn-stella-sub-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msn-stella-sub-dot {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--stella-green);
}

.msn-stella-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #5a5a5a;
    cursor: pointer;
}

.msn-stella-close:hover {
    background: #f1efea;
}

/* Nenápadné "Nový rozhovor" vedle křížku */
.msn-stella-reset {
    flex: 0 0 auto;
    margin: 0;
    padding: 5px 9px;
    border: 1px solid var(--stella-line);
    border-radius: 999px;
    background: transparent;
    color: var(--stella-muted);
    font: inherit;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}

.msn-stella-reset:hover {
    background: #f1efea;
    color: var(--stella-ink);
}

.msn-stella-reset[hidden] {
    display: none;
}

.msn-stella-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 12px 8px;
    -webkit-overflow-scrolling: touch;
}

.msn-stella-stamp {
    margin: 2px 0 10px;
    text-align: center;
    font-size: 11.5px;
    color: var(--stella-muted);
}

.msn-stella-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-top: 10px;
}

.msn-stella-row.is-grouped {
    margin-top: 3px;
}

.msn-stella-row--stella {
    justify-content: flex-start;
}

.msn-stella-row--user {
    justify-content: flex-end;
}

/* Avatar jen u poslední zprávy skupiny - ostatní drží jen místo. */
.msn-stella-row--stella .msn-stella-avatar--msg {
    visibility: hidden;
}

.msn-stella-row--stella.is-last .msn-stella-avatar--msg {
    visibility: visible;
}

.msn-stella-bubble {
    max-width: 80%;
    padding: 9px 13px;
    color: #fff;
    font-size: 15px;
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.msn-stella-bubble--stella {
    border-radius: 18px 18px 18px 4px;
    background: var(--stella-blue);
}

.msn-stella-bubble--user {
    border-radius: 18px 18px 4px 18px;
    background: var(--stella-green);
}

.msn-stella-bubble p {
    margin: 0;
}

.msn-stella-bubble p + p {
    margin-top: .55em;
}

.msn-stella-bubble a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.msn-stella-bubble strong {
    font-weight: 700;
}

/* Tlačítka voleb pod uvítáním */
.msn-stella-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 2px 34px;
}

.msn-stella-chip {
    margin: 0;
    padding: 8px 14px;
    border: 1.5px solid var(--stella-blue);
    border-radius: 999px;
    background: #fff;
    color: var(--stella-blue);
    font: 600 14px/1.2 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
}

.msn-stella-chip:hover {
    background: #eef6ff;
}

/* Indikátor psaní */
.msn-stella-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
}

.msn-stella-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    animation: msn-stella-typing 1.2s infinite ease-in-out;
}

.msn-stella-typing span:nth-child(2) { animation-delay: .15s; }
.msn-stella-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes msn-stella-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .55; }
    30% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .msn-stella-typing span { animation: none; opacity: .85; }
}

.msn-stella-error {
    margin: 10px 8px 0;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    color: #b42318;
}

.msn-stella-privacy {
    /* Souhlas se zpracováním - nesmí se v okně zmenšit ani uříznout
       (zmenšuje se jen oblast zpráv nad ní). */
    flex: 0 0 auto;
    margin: 0;
    padding: 6px 14px 6px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--stella-muted);
}

.msn-stella-privacy a {
    color: inherit;
    text-decoration: underline;
}

.msn-stella-closed {
    margin: 0;
    padding: 0 14px 8px;
    font-size: 13px;
    line-height: 1.4;
    color: #5a5a5a;
}

.msn-stella-closed[hidden] {
    display: none;
}

.msn-stella-closed-reset {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--stella-blue);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.msn-stella-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--stella-line);
}

.msn-stella-input {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 120px;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid #d9d6cf;
    border-radius: 20px;
    background: #fff;
    color: var(--stella-ink);
    font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif; /* 16 px - iOS nezoomuje */
    resize: none;
    overflow-y: hidden;
}

.msn-stella-input:disabled {
    background: #f4f2ee;
}

.msn-stella-send {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--stella-ink);
    color: #fff;
    cursor: pointer;
}

.msn-stella-send:disabled {
    opacity: .4;
    cursor: default;
}

/* ---------- Telefon ---------- */

@media (max-width: 699px) {
    .msn-stella-launcher {
        padding: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 50%;
    }

    .msn-stella-launcher:hover {
        background: transparent;
    }

    .msn-stella-launcher-text,
    .msn-stella-launcher-dot {
        display: none;
    }

    .msn-stella-avatar--launcher {
        width: 64px;
        height: 64px;
        border: 3px solid #fff;
        box-shadow: 0 8px 22px rgba(0, 0, 0, .25);
    }

    .msn-stella-avatar--launcher .msn-stella-avatar-monogram { font-size: 26px; }

    .msn-stella-avatar--launcher .msn-stella-avatar-dot {
        position: absolute;
        right: 1px;
        bottom: 1px;
        display: block;
        width: 15px;
        height: 15px;
        border: 2.5px solid #fff;
        border-radius: 50%;
        background: var(--stella-green);
    }

    /* Celá obrazovka; výška = viditelná část i s otevřenou klávesnicí
       (--msn-stella-vvh nastavuje JS z visualViewport). */
    .msn-stella-panel {
        /* Celoobrazovkové okno i nad lištou WordPressu pro přihlášené
           (#wpadminbar má z-index 99999) - jinak by zakryla záhlaví. */
        z-index: 100000;
        top: 0;
        right: 0;
        bottom: auto;
        left: 0;
        width: 100%;
        max-width: none;
        height: var(--msn-stella-vvh, 100dvh);
        max-height: none;
        border-radius: 0;
        padding-top: env(safe-area-inset-top, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
}

/* Stránka pod celoobrazovkovým oknem na telefonu se neposouvá. */
html.msn-stella-lock,
html.msn-stella-lock body {
    overflow: hidden;
    overscroll-behavior: none;
}

/* ---------- Fáze 2: souhlas, pauza, poptávka ---------- */

.msn-stella-chip:disabled {
    border-color: #c9c6bf;
    color: #a19d95;
    cursor: default;
}

.msn-stella-card {
    margin: 12px 4px 4px 36px;
    padding: 12px 14px;
    border: 1px solid var(--stella-line);
    border-radius: 14px;
    background: #fff;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--stella-ink);
}

.msn-stella-card-title {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.msn-stella-card-btn {
    margin: 0;
    padding: 9px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--stella-blue);
    color: #fff;
    font: 600 14px/1.2 -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    cursor: pointer;
}

.msn-stella-card-btn:disabled {
    opacity: .5;
    cursor: default;
}

.msn-stella-card-btn:focus-visible {
    outline: 2px solid var(--stella-blue);
    outline-offset: 2px;
}

.msn-stella-card dl {
    margin: 6px 0 10px;
}

.msn-stella-card dt {
    font-size: 12px;
    color: var(--stella-muted);
}

.msn-stella-card dd {
    margin: 0 0 6px;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.msn-stella-card-note {
    margin: 8px 0 0;
    font-size: 12.5px;
    color: var(--stella-muted);
}

.msn-stella-pause {
    margin: 0;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--stella-ink);
    background: #fff4e5;
}

.msn-stella-pause[hidden] {
    display: none;
}

.msn-stella-extlink {
    text-decoration: underline dotted;
}

/* Past na roboty - člověk pole nevidí ani na něj nenaskočí tabulátorem. */
.msn-stella-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
}

/* Při malé výšce okna (telefon s klávesnicí) se zmenšuje jen oblast zpráv. */
.msn-stella-head,
.msn-stella-closed,
.msn-stella-pause,
.msn-stella-form {
    flex-shrink: 0;
}
