.ai-chat-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
    transition: background-color 0.3s ease;
    padding: 20px;
}

.ai-chat-container {
    width: 100%;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    background-color: var(--card-bg);
    box-shadow: 0px 4px 15px 0px var(--card-shadow);
    transition: all 0.3s ease;
    overflow: hidden;
    animation: fadeIn 0.5s ease-in forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Header чата ---- */
.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.ai-chat-header-avatar {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 100%;
}

.ai-chat-header-info h2 {
    font-family: 'Rubik', sans-serif;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    transition: color 0.3s ease;
}

.ai-chat-header-info p {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: #8000FF;
    margin: 2px 0 0;
}

html.dark-theme .ai-chat-header-info p {
    color: #B164FD;
}

/* ---- Область сообщений ---- */
.ai-chat-messages {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 320px;
    max-height: 460px;
    overflow-y: auto;
}

.ai-chat-message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.ai-chat-message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    margin-top: 2px;
    border-radius: 100%;
}

.ai-chat-bubble {
    background: linear-gradient(135deg, rgba(128, 0, 255, 0.08), rgba(177, 100, 253, 0.05));
    border: 1px solid rgba(128, 0, 255, 0.2);
    border-radius: 16px;
    border-top-left-radius: 4px;
    padding: 14px 18px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--text-color);
    max-width: 85%;
    transition: all 0.3s ease;
}

.ai-chat-bubble strong {
    color: #6B00E0;
    font-weight: 600;
}

html.dark-theme .ai-chat-bubble {
    background: linear-gradient(135deg, rgba(177, 100, 253, 0.12), rgba(128, 0, 255, 0.08));
    border-color: rgba(177, 100, 253, 0.25);
}

html.dark-theme .ai-chat-bubble strong {
    color: #C98AFD;
    font-weight: 600;
}

/* ---- Сообщение пользователя ---- */
.ai-chat-message-user {
    justify-content: flex-end;
}

.ai-chat-bubble-user {
    background: linear-gradient(135deg, #8000FF, #B164FD) !important;
    border: none !important;
    color: #ffffff !important;
    border-radius: 16px !important;
    border-top-right-radius: 4px !important;
    border-top-left-radius: 16px !important;
}

html.dark-theme .ai-chat-bubble-user {
    background: linear-gradient(135deg, #9B4DFF, #B164FD) !important;
}

/* ---- Скрытие блоков ---- */
.ai-chat-hidden {
    display: none !important;
}

/* ---- Быстрые команды ---- */
.ai-chat-quick-label {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text-secondary);
    padding: 0 0 8px;
    transition: color 0.3s ease;
}

.ai-chat-quick-commands {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 24px 20px;
}

.ai-chat-quick-commands-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-chat-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 12px;
    border: none;
    /* background: linear-gradient(135deg, #8000FF, #B164FD); */
    background: #8000FF;
    font-family: 'Rubik', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.25s ease;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(128, 0, 255, 0.35);
}

.ai-chat-quick-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(128, 0, 255, 0.45);
    opacity: 0.95;
}

.ai-chat-quick-btn svg path,
.ai-chat-quick-btn svg circle {
    stroke: #ffffff;
}

html.dark-theme .ai-chat-quick-btn {
    background: linear-gradient(135deg, #9B4DFF, #B164FD);
    box-shadow: 0 4px 14px rgba(155, 77, 255, 0.4);
}

html.dark-theme .ai-chat-quick-btn:hover {
    box-shadow: 0 6px 18px rgba(155, 77, 255, 0.5);
}

.ai-chat-quick-btn svg {
    flex-shrink: 0;
}

/* ---- Поле ввода ---- */
.ai-chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background-color: var(--input-bg);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    color: var(--text-color);
    outline: none;
    transition: all 0.3s ease;
}

.ai-chat-input::placeholder {
    color: var(--text-tertiary);
}

.ai-chat-input:focus {
    border-color: #8000FF;
    box-shadow: 0 0 0 3px rgba(128, 0, 255, 0.1);
}

html.dark-theme .ai-chat-input:focus {
    border-color: #B164FD;
    box-shadow: 0 0 0 3px rgba(177, 100, 253, 0.15);
}

.ai-chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #8000FF, #B164FD);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover {
    opacity: 0.85;
    transform: scale(1.04);
}

.ai-chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* ---- Ссылка «назад» ---- */
.ai-chat-back {
    margin-top: 16px;
    font-family: 'Rubik', sans-serif;
    font-size: 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ai-chat-back:hover {
    color: #8000FF;
}

html.dark-theme .ai-chat-back:hover {
    color: #B164FD;
}

/* ---- Капча-слайдер ---- */
.captcha-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.captcha-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.captcha-modal {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 28px 32px 32px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    position: relative;
    transform: scale(0.92);
    transition: transform 0.25s ease;
}

.captcha-overlay.active .captcha-modal {
    transform: scale(1);
}

.captcha-title {
    font-family: 'Rubik', sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 20px;
    transition: color 0.3s ease;
}

.captcha-slider-track {
    position: relative;
    width: 100%;
    height: 50px;
    border-radius: 12px;
    background-color: var(--empty-bg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.captcha-slider-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 50px;
    background: linear-gradient(135deg, rgba(128, 0, 255, 0.15), rgba(177, 100, 253, 0.1));
    border-radius: 12px 0 0 12px;
    pointer-events: none;
    transition: background 0.3s ease;
}

.captcha-slider-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    pointer-events: none;
    transition: opacity 0.2s ease, color 0.3s ease;
}

.captcha-slider-thumb {
    position: absolute;
    top: 3px;
    left: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(135deg, #8000FF, #B164FD);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    box-shadow: 0 2px 10px rgba(128, 0, 255, 0.4);
    transition: left 0.3s ease;
    margin-left: 3px;
}

.captcha-slider-thumb:active {
    cursor: grabbing;
}

html.dark-theme .captcha-slider-thumb {
    background: linear-gradient(135deg, #9B4DFF, #B164FD);
    box-shadow: 0 2px 10px rgba(155, 77, 255, 0.5);
}

.captcha-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s ease;
}

.captcha-close:hover {
    color: var(--text-color);
}

/* ---- Адаптив ---- */
@media (max-width: 630px) {
    .ai-chat-container {
        max-width: 100%;
        border-radius: 18px;
    }

    .ai-chat-messages {
        min-height: 260px;
        padding: 18px;
    }

    .ai-chat-quick-commands {
        padding: 0 18px 16px;
    }

    .ai-chat-input-area {
        padding: 12px 18px;
    }

    .ai-chat-header {
        padding: 16px 18px;
    }
}

@media (max-width: 440px) {
    .ai-chat-quick-btn {
        padding: 8px 14px;
        font-size: 13px;
    }

    .ai-chat-bubble {
        font-size: 14px;
        padding: 12px 14px;
    }

    .ai-chat-input {
        font-size: 14px;
        padding: 10px 14px;
    }

    .ai-chat-send-btn {
        width: 40px;
        height: 40px;
    }
}