/*
 * Стилистика повторяет дизайн-токены личного кабинета «МОЖНО» (resources/cabinet/src/index.css):
 * тёплый кремовый фон, тёмно-серый текст, оранжевый акцент, скругления ~16–24px. Страница
 * работает в двух режимах:
 *  - обычный (по умолчанию) — самостоятельная страница на весь экран, например по прямому
 *    ответу «Поддержка» со ссылкой на этот адрес;
 *  - встроенный (?embed=1 в адресе, см. index.html) — скрывает шапку/подвал страницы и
 *    растягивает диалог на весь размер контейнера, чтобы уместиться в маленьком окне чата
 *    личного кабинета (ChatWidget.tsx, resources/cabinet/src/index.css — .chat-panel/.chat-iframe).
 */
:root {
    --ink: #3A3C40;
    --muted: #77736e;
    --border: #dedbd6;
    --orange: #f37338;
    --orange-dark: #c94b0d;
    --bg: #f3f1ef;
    --surface: #fff;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 -apple-system, "Segoe UI", system-ui, sans-serif;
}
main {
    display: flex;
    flex-direction: column;
    max-width: 720px;
    height: 100dvh;
    margin: 0 auto;
    background: var(--surface);
}
header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 18px 24px;
    background: var(--ink);
    color: #fff;
}
header .avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: var(--orange);
    color: #fff;
    font-weight: 800;
    font-size: 15px;
}
header .titles { display: flex; flex-direction: column; min-width: 0; }
header strong { font-size: 15px; font-weight: 800; }
header span {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12px;
    color: rgba(255, 255, 255, .7);
}
header span::before {
    content: '';
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .25);
}

#messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bot, .user {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 10px 14px;
    max-width: 84%;
    font-size: 14px;
    line-height: 1.45;
}
.bot {
    align-self: flex-start;
    background: var(--bg);
    color: var(--ink);
    border-radius: 16px 16px 16px 4px;
}
.user {
    align-self: flex-end;
    background: var(--orange);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}

.notice {
    flex-shrink: 0;
    padding: 0 20px 8px;
    color: var(--muted);
    font-size: 12px;
}

form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--surface);
}
form label { display: none; }
textarea {
    flex: 1;
    resize: none;
    max-height: 96px;
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 10px 14px;
    font: inherit;
    color: var(--ink);
    background: var(--bg);
}
textarea:focus { outline: none; border-color: var(--orange); }
textarea::placeholder { color: var(--muted); }

button {
    flex-shrink: 0;
    border: none;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
button:disabled { opacity: .5; cursor: wait; }

#send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: var(--orange);
    color: #fff;
}
#send:hover:not(:disabled) { background: var(--orange-dark); }
#send svg { width: 18px; height: 18px; }

#clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    border: 1.5px solid var(--border);
}
#clear:hover:not(:disabled) { color: var(--orange-dark); border-color: #f3b8ac; background: #fdecea; }
#clear svg { width: 16px; height: 16px; }

footer {
    display: none;
}

/* Обычный режим (не встроен в ЛК) — карточка по центру экрана с отступами, как
   у обычной самостоятельной страницы, плюс видимый футер со ссылкой на поддержку. */
body:not(.is-embedded) {
    display: flex;
    padding: 24px 12px;
}
body:not(.is-embedded) main {
    height: min(720px, calc(100dvh - 48px));
    margin: auto;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(15, 15, 15, .12);
    overflow: hidden;
}
body:not(.is-embedded) header { border-radius: 24px 24px 0 0; }
body:not(.is-embedded) footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
}
body:not(.is-embedded) footer a { color: var(--orange-dark); text-decoration: none; }
body:not(.is-embedded) footer a:hover { text-decoration: underline; }

/* Встроенный режим (?embed=1) — используется внутри iframe маленького окна чата в личном
   кабинете (ChatWidget.tsx): своя шапка/скругления уже есть у окна виджета в ЛК, поэтому
   здесь шапка страницы скрывается, а диалог занимает всю высоту iframe без полей. */
body.is-embedded main { max-width: none; }
body.is-embedded header { display: none; }
