/* Публичный ИИ-консультант — AI Mode */

/* Без футера: страница = экран, скролл только у диалога */
body.layout-no-footer {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
}

body.layout-no-footer .layout-no-footer__main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.pai {
    --pai-ink: #0f172a;
    --pai-muted: #64748b;
    --pai-line: #e2e8f0;
    --pai-brand: #0f766e;
    --pai-brand-soft: #ecfdf5;
    --pai-surface: #f8fafc;
    min-height: calc(100vh - 5rem);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(16, 185, 150, 0.12), transparent 60%),
        linear-gradient(180deg, #ffffff 0%, var(--pai-surface) 100%);
}

body.layout-no-footer .pai {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.pai__workspace {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 1.25rem;
    padding: 0 1rem;
    overflow: hidden;
}

.pai.has-context .pai__workspace {
    justify-content: center;
}

.pai__stage {
    width: min(720px, 100%);
    margin: 0;
    flex: 1 1 auto;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    padding: 2.5rem 0 1.5rem;
    min-height: 0;
}

.pai.is-dialog-mode .pai__stage {
    max-width: 920px;
}

body.layout-no-footer .pai__stage {
    overflow: hidden;
}

/* Правая панель переменных темы (как в админ-тесте) */
.pai-context-panel {
    flex: 0 0 16.5rem;
    width: 16.5rem;
    max-width: 16.5rem;
    align-self: stretch;
    margin: 1.5rem 0 6.5rem;
    padding: 0;
    overflow: auto;
    background: transparent;
}

.pai-context-panel[hidden],
.pai-context-panel.is-empty {
    display: none !important;
}

.pai-context-panel__list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.pai-context-card {
    margin: 0;
    padding: 0.65rem 0.75rem;
    border-radius: 0.75rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    border-left: 3px solid #60a5fa;
}

.pai-context-card__label {
    margin: 0 0 0.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #64748b;
}

.pai-context-card__value {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 650;
    line-height: 1.35;
    color: #0f172a;
    word-break: break-word;
}

@media (max-width: 960px) {
    .pai.has-context .pai__workspace {
        flex-direction: column;
        overflow: hidden;
    }

    .pai-context-panel {
        flex: 0 0 auto;
        width: 100%;
        max-width: none;
        margin: 0.5rem 0 0;
        max-height: 7rem;
        order: -1;
    }

    .pai-context-panel__list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .pai-context-card {
        flex: 1 1 9rem;
        padding: 0.45rem 0.6rem;
    }
}

.pai__hero {
    text-align: center;
    margin: auto 0 1.5rem;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.pai.is-chatting .pai__hero {
    margin: 0 0 1rem;
    transform: scale(0.96);
}

.pai__title {
    font-size: clamp(1.75rem, 4vw, 2.4rem);
    font-weight: 800;
    color: var(--pai-ink);
    letter-spacing: -0.03em;
    margin: 0 0 0.75rem;
}

/* Режим диалога: сцена вместо ленты сообщений */
.pai.is-dialog-mode .pai__hero,
.pai.is-dialog-mode .pai__thread {
    display: none !important;
}

.pai.is-dialog-mode .pai__stage {
    width: 100%;
    max-width: 920px;
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
}

.pai.is-dialog-mode .pai__status {
    display: none !important;
}

.pai-dialog-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1.25rem 0.5rem 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-padding-top: 1rem;
}

.pai-dialog-stage[hidden] {
    display: none !important;
}

.pai-dialog-stage__host {
    width: min(42rem, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: auto;
}

.pai-dialog-stage.is-long .pai-dialog-stage__host {
    margin-top: 0;
    margin-bottom: 0;
}

.pai-dialog-stage__text {
    width: 100%;
    text-align: center;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    font-weight: 500;
    line-height: 1.55;
    letter-spacing: 0.01em;
    color: var(--pai-ink);
    transition: opacity 0.22s ease;
}

.pai-dialog-stage__text.is-fading {
    opacity: 0;
}

.pai-dialog-stage__text p {
    margin: 0 0 0.75em;
}

.pai-dialog-stage__text p:last-child {
    margin-bottom: 0;
}

.pai-dialog-stage__text ul,
.pai-dialog-stage__text ol {
    display: inline-block;
    text-align: left;
    margin: 0.5em auto;
    padding-left: 1.25em;
}

.pai-dialog-stage__text strong {
    font-weight: 700;
}

.pai-dialog-glyph {
    opacity: 0;
    transition: opacity 0.45s ease;
}

.pai-dialog-glyph.is-in {
    opacity: 1;
}

.pai-dialog-glyph.is-space {
    transition-duration: 0.2s;
}

.pai-dialog-plaques {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    margin-top: 0.35rem;
}

.pai-dialog-plaques[hidden] {
    display: none !important;
}

.pai-dialog-plaques__chip {
    appearance: none;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: var(--pai-ink);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.pai-dialog-plaques__chip:hover,
.pai-dialog-plaques__chip:focus-visible {
    background: var(--pai-brand-soft);
    border-color: var(--pai-brand);
    outline: none;
}

.pai-dialog-plaques__chip:active {
    transform: scale(0.98);
}

.pai-dialog-plaques__chip:disabled {
    opacity: 0.45;
    cursor: default;
}

.pai-dialog-stage__pulse {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 2.5rem;
}

.pai-dialog-stage__pulse i {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: #94a3b8;
    opacity: 0.35;
    animation: pai-dialog-pulse 1.2s ease-in-out infinite;
}

.pai-dialog-stage__pulse i:nth-child(2) {
    animation-delay: 0.18s;
}

.pai-dialog-stage__pulse i:nth-child(3) {
    animation-delay: 0.36s;
}

@keyframes pai-dialog-pulse {
    0%, 100% { opacity: 0.25; transform: translateY(0); }
    50% { opacity: 0.9; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
    .pai-dialog-glyph {
        opacity: 1;
        transition: none;
    }
    .pai-dialog-stage__pulse i {
        animation: none;
        opacity: 0.55;
    }
}

.pai__opening {
    font-size: 1.05rem;
    line-height: 1.5;
    color: var(--pai-muted);
    margin: 0 auto;
    max-width: 34rem;
}

.pai__thread {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    padding: 0.5rem 0 1rem;
    min-height: 12rem;
}

.pai__msg {
    max-width: 100%;
    animation: paiIn 0.28s ease;
}

@keyframes paiIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.pai__msg--user {
    align-self: flex-end;
    background: #0f172a;
    color: #fff;
    border-radius: 1.15rem 1.15rem 0.35rem 1.15rem;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.pai__msg--assistant {
    align-self: stretch;
    color: var(--pai-ink);
    font-size: 1rem;
    line-height: 1.6;
}

.pai__msg--assistant .pai-prose p {
    margin: 0 0 0.75rem;
}

.pai__msg--assistant .pai-prose p:last-child {
    margin-bottom: 0;
}

.pai__msg--assistant .pai-prose ul,
.pai__msg--assistant .pai-prose ol {
    margin: 0 0 0.75rem;
    padding-left: 1.2rem;
}

.pai__status {
    text-align: center;
    font-size: 0.85rem;
    color: var(--pai-muted);
    margin: 0 0 0.75rem;
    min-height: 1.2em;
}

.pai__composer {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    background: #fff;
    border: 1px solid var(--pai-line);
    border-radius: 1.35rem;
    padding: 0.55rem 0.55rem 0.55rem 1rem;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    position: sticky;
    bottom: 1rem;
    flex-shrink: 0;
}

body.layout-no-footer .pai__composer {
    position: relative;
    bottom: auto;
    margin-top: auto;
}

.pai__input {
    flex: 1;
    border: 0;
    outline: none;
    resize: none;
    font: inherit;
    font-size: 1rem;
    line-height: 1.45;
    max-height: 8rem;
    background: transparent;
    color: var(--pai-ink);
    padding: 0.45rem 0;
}

.pai__send {
    flex: 0 0 auto;
    width: 2.6rem;
    height: 2.6rem;
    border: 0;
    border-radius: 999px;
    background: var(--pai-brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.pai__send:hover {
    background: #0d9488;
}

.pai__send:disabled {
    opacity: 0.45;
    cursor: default;
}

.pai-unavailable {
    min-height: calc(100vh - 5rem);
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background: var(--pai-surface);
}

.pai-unavailable__card {
    max-width: 28rem;
    text-align: center;
    background: #fff;
    border: 1px solid var(--pai-line);
    border-radius: 1.25rem;
    padding: 2rem 1.5rem;
}

.pai-unavailable__card h1 {
    font-size: 1.35rem;
    font-weight: 800;
    margin: 0 0 0.75rem;
    color: var(--pai-ink);
}

.pai-unavailable__card p {
    margin: 0 0 1.25rem;
    color: var(--pai-muted);
    line-height: 1.5;
}

.pai-unavailable__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1.1rem;
    border-radius: 999px;
    background: var(--pai-brand);
    color: #fff;
    text-decoration: none;
    font-weight: 650;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 640px) {
    .pai__stage {
        width: calc(100% - 1.25rem);
        padding-top: 1.5rem;
    }
    .pai__composer {
        bottom: 0.75rem;
    }
}
