:root {
    --primary-color: #21A038;
    /* Sber Green */
    --primary-dark: #1A802C;
    --background: #F4F5F7;
    --surface: #FFFFFF;
    --text-primary: #1C1C1E;
    --text-secondary: #8E8E93;
    --border: #E5E5EA;
    --message-user-bg: #E8F5E9;
    --message-ai-bg: #FFFFFF;
    --accent-blue: #2481FA;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    margin: 0;
}

.bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: background-image 0.8s ease-in-out;
    background-image: url('/bg/default.png');
}

.chat-container {
    width: 100%;
    max-width: 800px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

@media (min-width: 800px) {
    .chat-container {
        height: 90vh;
        border-radius: 16px;
        overflow: hidden;
    }
}

/* Header */
.chat-header {
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    z-index: 10;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-image {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    /* Optional, adds nice rounded corners if not already round */
}

.logo-text {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 8px;
}

.icon-btn:hover {
    color: var(--primary-color);
    background-color: rgba(33, 160, 56, 0.1);
}

/* Messages */
.chat-messages {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message-wrapper {
    display: flex;
    width: 100%;
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-wrapper.ai {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.user-bubble {
    background: rgba(232, 245, 233, 0.85);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.ai-bubble {
    background: rgba(255, 255, 255, 0.85);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.ai-bubble p {
    margin-bottom: 8px;
}

.ai-bubble p:last-child {
    margin-bottom: 0;
}

.ai-bubble ul,
.ai-bubble ol {
    margin-left: 20px;
    margin-bottom: 8px;
}

.ai-bubble a {
    color: var(--accent-blue);
    text-decoration: none;
}

.ai-bubble a:hover {
    text-decoration: underline;
}

.fallback-btn-container {
    margin-top: 12px;
}

.fallback-btn {
    display: inline-block;
    background-color: var(--primary-color);
    color: #ffffff !important;
    padding: 8px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.fallback-btn:hover {
    background-color: var(--primary-dark);
    text-decoration: none;
    color: #ffffff !important;
}

/* Inline Buttons for Settings */
.inline-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.inline-btn {
    background-color: var(--surface);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.2s, color 0.2s;
    font-family: inherit;
}

.inline-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
}

/* Loading indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
    background-color: var(--message-ai-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.chat-input-area {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.5);
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
}

textarea {
    flex-grow: 1;
    border: none;
    background: none;
    resize: none;
    padding: 8px 0;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    max-height: 120px;
    outline: none;
}

textarea::placeholder {
    color: var(--text-secondary);
}

.send-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s, opacity 0.2s;
}

.send-btn:disabled {
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.send-btn:not(:disabled):hover {
    background-color: rgba(33, 160, 56, 0.1);
}

.modal {
    position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center;
}
.modal-content {
    background: white; padding: 20px; border-radius: 15px; width: 80%; max-width: 500px;
    max-height: 70vh; overflow-y: auto; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}
.close { float: right; cursor: pointer; font-size: 24px; }
.inline-btn {
    margin-top: 5px; cursor: pointer; background: var(--primary-color);
    color: white; border: none; padding: 5px 10px; border-radius: 5px;
}

* Контейнер для позиционирования */
.docs-menu-container {
    display: flex;
    align-items: center;
}

/* Выпадающее меню */
.docs-dropdown {
    position: absolute;
    bottom: 50px; /* Появляется над кнопкой */
    left: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
    width: 220px;
    z-index: 1000;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Элементы меню */
.dropdown-item {
    background: none;
    border: none;
    padding: 10px 12px;
    text-align: left;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-primary);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dropdown-item:hover {
    background: var(--message-user-bg);
    color: var(--primary-color);
}

/* Анимация появления */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.docs-dropdown {
    animation: fadeInScale 0.2s ease-out;
}