/* Общие стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8b6b3f;
    --secondary-color: #506b7a;
    --accent-color: #b87a3d;
    --bg-main: #f4efe6;
    --bg-panel: #fbf8f2;
    --bg-header: #f7f1e7;
    --text-primary: #1f2933;
    --text-secondary: #6b7280;
    --message-user-bg: #e3edf6;
    --message-assistant-bg: #f6efe3;
    --input-bg: #ffffff;
    --border-color: #e0d8c8;
    --shadow-soft: 0 18px 35px rgba(15, 23, 42, 0.08);
    --recording-color: #b91c1c;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(circle at top, #fdf8ef 0%, #f4efe6 42%, #ece3d4 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Модальное окно авторизации */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.auth-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-content {
    background: rgba(251, 248, 242, 0.98);
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid rgba(215, 204, 186, 0.9);
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.3s ease-out;
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.auth-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.auth-content h2 {
    font-family: 'Playfair Display', serif;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.auth-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-form input {
    background: #fffdf8;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    text-align: center;
    transition: all 0.2s;
}

.auth-form input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(184, 122, 61, 0.18);
}

.auth-form button {
    background: linear-gradient(135deg, #b88746 0%, #8b6b3f 100%);
    border: none;
    padding: 0.75rem;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.auth-form button:hover {
    opacity: 0.9;
}

.auth-error {
    color: var(--recording-color);
    margin-top: 1rem;
    font-size: 0.875rem;
    min-height: 1.25em;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    transition: filter 0.3s ease;
}

/* Заголовок */
.header {
    background: var(--bg-header);
    border: 1px solid rgba(220, 209, 191, 0.9);
    border-radius: 18px;
    padding: 0.75rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.header::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.6) 0, transparent 55%),
        radial-gradient(circle at bottom right, rgba(184, 122, 61, 0.11) 0, transparent 60%);
    opacity: 0.9;
    pointer-events: none;
}

.header-content {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1;
}

.poet-portrait-wrapper {
    flex-shrink: 0;
}

.poet-portrait {
    width: 56px;
    height: 56px;
    border-radius: 999px;
    padding: 2px;
    background: radial-gradient(circle at top, #fdf8ef 0%, #d6c4a8 55%, #b78b48 100%);
    box-shadow: 0 6px 14px rgba(120, 88, 38, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.poet-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    filter: saturate(1.05) contrast(1.02);
}

.header-text h1 {
    font-family: 'Cormorant Garamond', 'Playfair Display', serif;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #2b3540;
    margin-bottom: 0;
    line-height: 1.2;
}

.subtitle {
    font-family: 'Cormorant Garamond', serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.tagline {
    display: none; /* Скрываем для компактности */
}

.header-controls {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-left: auto;
}

.language-info {
    display: none; /* Скрываем языки для компактности */
}

.model-selector-wrapper {
    position: relative;
}

.model-selector {
    appearance: none;
    background: #f9f4eb;
    border: 1px solid rgba(203, 187, 157, 0.9);
    color: var(--text-primary);
    padding: 0.5rem 2rem 0.5rem 1rem;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    min-width: 180px;
}

.model-selector:hover {
    border-color: var(--primary-color);
    background: #fdf8ef;
}

.model-selector-wrapper::after {
    content: '▼';
    font-size: 0.7rem;
    color: var(--text-secondary);
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.lang-badge {
    background: rgba(226, 213, 191, 0.5);
    border: 1px solid rgba(203, 187, 157, 0.9);
    padding: 0.5rem 1rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* Чат */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem 1.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    scroll-behavior: smooth;
}

/* Скроллбар */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(152, 120, 73, 0.4);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(152, 120, 73, 0.7);
}

/* Сообщения */
.message {
    display: flex;
    gap: 1rem;
    animation: slideIn 0.3s ease-out;
}

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

.message-avatar {
    font-size: 2rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.1);
}

.user-message .message-avatar {
    background: rgba(59, 130, 246, 0.1);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-author {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.assistant-message .message-author {
    color: var(--primary-color);
}

.user-message .message-author {
    color: #1f2933;
}

.message-text {
    background: var(--message-assistant-bg);
    border: 1px solid rgba(205, 190, 164, 0.9);
    padding: 1.1rem 1.2rem;
    border-radius: 18px;
    font-family: 'Merriweather', serif;
    font-size: 1.02rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.user-message .message-text {
    background: var(--message-user-bg);
    border-color: rgba(148, 180, 210, 0.85);
    font-family: 'Inter', sans-serif;
    font-size: 0.98rem;
    line-height: 1.6;
}

.welcome-message .message-text {
    background: linear-gradient(135deg, #f8f2e7 0%, #f3e8d8 100%);
    border-color: rgba(201, 181, 145, 0.9);
}

.message-text p {
    margin-bottom: 0.75rem;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text em {
    color: var(--accent-color);
}

.message-text strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* Индикатор печати */
.typing-indicator {
    display: flex;
    gap: 1rem;
    padding: 0 1.75rem;
    animation: slideIn 0.3s ease-out;
}

.typing-dots {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 1rem;
    background: #f4ede0;
    border: 1px solid rgba(205, 190, 164, 0.9);
    border-radius: 16px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    30% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Форма ввода */
.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem 1.25rem;
    background: rgba(247, 241, 231, 0.9);
}

.chat-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: flex-end; /* Выравнивание кнопок по низу поля ввода */
}

.chat-input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid rgba(210, 197, 177, 0.9);
    border-radius: 16px;
    padding: 1rem 1.25rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    resize: none;
    max-height: 150px;
    transition: all 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(184, 122, 61, 0.13);
}

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

.send-button, .voice-button {
    background: linear-gradient(135deg, #b88746 0%, #8b6b3f 100%);
    border: none;
    border-radius: 16px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    position: relative;
    overflow: hidden;
}

.voice-button {
    background: #faf3e6;
    border: 1px solid rgba(210, 197, 177, 0.9);
    color: #1f2933;
}

.voice-button:hover {
    border-color: var(--primary-color);
    color: #1f2933;
}

.voice-button.recording {
    background: rgba(185, 28, 28, 0.07);
    border-color: var(--recording-color);
    color: var(--recording-color);
    animation: pulse 1.5s infinite;
}

.recording-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    background: var(--recording-color);
    border-radius: 50%;
    opacity: 0.2;
    animation: ripple 1.5s infinite;
}

@keyframes ripple {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.send-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(120, 88, 38, 0.28);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.clear-button {
    background: transparent;
    border: 1px solid rgba(210, 197, 177, 0.9);
    border-radius: 12px;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.clear-button:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Футер */
.footer {
    display: none; /* Убираем футер для максимизации чата */
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
        height: 100dvh;
    }

    .header {
        padding: 0.5rem 0.75rem;
        border-radius: 14px;
        margin-bottom: 0.5rem;
    }

    .header-content {
        gap: 0.75rem;
    }
    
    .header-controls {
        gap: 0.5rem;
    }

    .poet-portrait {
        width: 44px;
        height: 44px;
        box-shadow: 0 4px 10px rgba(120, 88, 38, 0.25);
    }

    .header-text h1 {
        font-size: 1.25rem;
        line-height: 1.2;
    }
    
    .subtitle {
        font-size: 0.75rem;
    }

    .model-selector {
        padding: 0.4rem 1.5rem 0.4rem 0.75rem;
        font-size: 0.8rem;
        min-width: 120px;
    }

    .chat-container {
        border-radius: 14px;
        flex: 1;
        min-height: 0;
    }

    .chat-messages {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .message {
        gap: 0.5rem;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
        border-radius: 8px;
    }

    .message-text {
        font-size: 0.9rem;
        padding: 0.6rem 0.75rem;
        border-radius: 12px;
        line-height: 1.5;
    }
    
    .message-author {
        font-size: 0.7rem;
        margin-bottom: 0.3rem;
    }

    .chat-input-container {
        padding: 0.5rem 0.6rem;
    }
    
    .chat-form {
        gap: 0.4rem;
        margin-bottom: 0.4rem;
    }
    
    .chat-input {
        padding: 0.6rem 0.75rem;
        font-size: 16px;
        border-radius: 12px;
    }

    .send-button, .voice-button {
        width: 44px;
        height: 44px;
        border-radius: 10px;
    }

    .input-footer {
        margin-top: 0.3rem;
    }

    .clear-button {
        font-size: 0.7rem;
        padding: 0.35rem 0.6rem;
        border-radius: 8px;
    }

    .hint {
        display: none;
    }
    
    /* Модальное окно */
    .auth-content {
        padding: 1.25rem;
        width: 88%;
        border-radius: 18px;
    }
    
    .auth-icon {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }
    
    .auth-content h2 {
        font-size: 1.3rem;
    }
    
    .auth-content p {
        font-size: 0.85rem;
        margin-bottom: 1rem;
    }
}
