/* Оптимизированная палитра для обучения с фокусом на письмо */
body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Merriweather', 'Georgia', serif;
    display: flex;
    flex-direction: column;
    background: #f0f4f8; /* Мягкий голубовато-серый фон */
    color: #2c3e50;
    overflow: hidden;
    line-height: 1.6;
}

/* Кастомный скроллбар */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    cursor: pointer;
}

::-webkit-scrollbar-track {
    background: rgba(58, 80, 107, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #5bc0be;
    border-radius: 4px;
    cursor: grab;
}

::-webkit-scrollbar-thumb:hover {
    background: #4aa8a6;
    cursor: grabbing;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center; /* Центрируем элементы по вертикали */
    width: 100%;
    padding: 8px 5%; /* Уменьшаем вертикальный padding */
    box-sizing: border-box;
    background-color: #3a506b;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    height: 60px; /* Фиксированная высота */
}

#title-container {
    display: flex;
    flex-direction: column;
}

#subtitle {
    font-size: 0.75rem; /* Уменьшаем размер подзаголовка */
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
    letter-spacing: 0.4px;
    margin-top: 2px; /* Уменьшаем отступ сверху */
    padding-left: 20px; /* Уменьшаем отступ слева */
    line-height: 1.2;
}

#subtitle::before {
    width: 15px; /* Укорачиваем декоративную линию */
    top: 45%; /* Корректируем позицию */
}

#page-title {
    margin: 0;
    font-size: 1.8rem; /* Уменьшаем размер шрифта */
    color: #ffffff;
    font-weight: 600;
    letter-spacing: 0.2px;
    font-family: 'Montserrat', 'Arial', sans-serif;
    line-height: 1.2; /* Уменьшаем межстрочный интервал */
}

#lang-switcher {
    display: flex;
    gap: 10px;
}

/* Анимация ТОЛЬКО для кнопок языка */
#lang-switcher button {
    padding: 6px 12px; /* Уменьшаем размер кнопок */
    font-size: 0.85rem; /* Уменьшаем шрифт кнопок */
    cursor: pointer;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

#lang-switcher button:hover {
    background-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px); /* Анимация при наведении */
}

#lang-switcher button.active {
    background-color: #5bc0be; /* Свежий бирюзовый */
    color: white;
    font-weight: 600;
}

#main-content {
    display: flex;
    flex-grow: 1;
    width: 100%;
    padding: 25px 5%;
    box-sizing: border-box;
    gap: 25px;
    min-height: 0;
}

/* Changed order: review-panel first (left) */
#review-panel {
    flex: 3;
    background: #f9f7f3; /* Светлый кремовый фон */
    border-radius: 8px;
    padding: 25px;
    overflow-y: auto;
    font-size: 16px;
    line-height: 1.7;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.05);
    cursor: default;
    user-select: text; /* Разрешаем копирование текста */
    border: 1px dashed #6c757d; /* Более контрастный пунктир */
    position: relative;
}

/* Editor container now on right */
#editor-container {
    display: flex;
    flex: 7;
    min-width: 0;
    background: #ffffff;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e1e8ed;
}

/* New wrapper for editor area and buttons */
.editor-area-wrapper {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    gap: 15px;
}

#essay-area {
    flex: 9; /* 90% width */
    width: 100%;
    margin: 0;
    padding: 20px;
    font-size: 16px;
    line-height: 1.7;
    border: 1px solid #d0d9e0;
    border-radius: 6px;
    resize: none;
    box-sizing: border-box;
    background: #ffffff;
    font-family: inherit;
    transition: border-color 0.2s;
}

#essay-area:focus {
    outline: none;
    border-color: #6a9eff;
    box-shadow: 0 0 0 2px rgba(106, 158, 255, 0.2);
}

/* Button column (vertical layout) */
#button-column {
    flex: 1; /* 10% width */
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    min-width: 140px; /* Фиксированная минимальная ширина */
    width: 140px; /* Фиксированная ширина для всех кнопок */
}

#button-column button {
    padding: 12px 10px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Montserrat', 'Arial', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    width: 100%; /* Занимает всю ширину колонки */
    box-sizing: border-box;
    white-space: nowrap; /* Текст не переносится */
    overflow: hidden; /* Скрываем текст, если не помещается */
    text-overflow: ellipsis; /* Добавляем многоточие если текст обрезается */
    flex-shrink: 0; /* Запрещаем уменьшение размера */
}

#button-column button:hover {
    opacity: 0.9;
}

#check-part-button {
    background-color: #6a9eff; /* Мягкий синий */
    color: white;
}

#finish-current-button {
    background-color: #8a9baf; /* Приглушенный серо-голубой */
    color: white;
}

#finish-current-button:hover {
    background-color: #7a8a9d;
    opacity: 0.9;
}

/* New Talk button styles */
/* Talk button specific styles */
.talk-button {
    background: linear-gradient(145deg, #4CAF50, #388E3C) !important;
    color: white !important;
    position: relative;
    overflow: hidden;
}

.talk-button .button-text {
    display: inline-block;
    width: 100%;
    text-align: center;
    transition: opacity 0.2s;
    position: relative;
}

.talk-button.recording .button-text::after {
    content: attr(data-recording-text);
    position: absolute;
    left: 0;
    right: 0;
    text-align: center;
    opacity: 1;
}

.talk-button:not(.recording) .button-text::after {
    opacity: 0;
}

.talk-button.recording .button-text span {
    opacity: 0;
}

.talk-button:not(.recording) .button-text span {
    opacity: 1;
}

.talk-button.active {
    background-color: #f44336 !important; /* Red when active */
}

.recording-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ff5252;
    opacity: 0;
    transition: opacity 0.3s;
}

.talk-button.recording {
    background: linear-gradient(145deg, #f44336, #d32f2f) !important;
    animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 5px rgba(244, 67, 54, 0.4);
    }
    100% {
        box-shadow: 0 0 20px rgba(244, 67, 54, 0.8);
    }
}

.talk-button.disabled-processing {
    background: #b0bec5 !important; /* Светло-серый */
    color: #ffffff !important;
    cursor: not-allowed;
    pointer-events: none; /* Запрещает все события мыши */
    opacity: 0.7;
}

.talk-button.disabled-processing .spinner {
    display: inline-block;
}

.talk-button .spinner {
    display: none; /* по умолчанию скрыт */
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

.talk-button.recording::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    animation: shine 1.5s infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.button-text {
    font-size: 16px;
    font-weight: 600;
    position: relative;
    z-index: 1;
}

.button-icon {
    font-size: 18px;
}

/* Информационный стиль для подсказок */
.info-text {
    font-size: 14px;
    color: #6c757d;
    margin-top: 10px;
    font-style: italic;
}

/* Адаптивность */
@media (max-width: 1200px) {
    #main-content {
        flex-direction: column;
        padding: 20px;
        gap: 20px;
    }
    
    #editor-container, #review-panel {
        width: 100%;
        flex: none;
    }
    
    #editor-container {
        height: 60vh;
    }
    
    #review-panel {
        height: 30vh;
    }
    
    #button-column button {
        min-width: auto;
        padding: 10px;
        font-size: 14px;
    }

    #essay-theme-container {
        max-width: 40%;
    }
}

@media (max-width: 768px) {
    #top-bar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 5%;
    }
    
    #essay-theme-wrapper {
        position: static;
        order: 3;
        width: 100%;
        margin-top: 8px;
    }
    
    #essay-theme-container {
        max-width: 100%;
        padding: 8px 0 0;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    #essay-theme {
        max-width: 100%;
        padding: 5px 10px;
        font-size: 0.95rem;
    }

    
    #lang-switcher {
        justify-content: center;
    }
    
    /* Button column (vertical layout) */
    #button-column {
        flex: 1; /* 10% width */
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        min-width: 120px; /* Фиксированная минимальная ширина */
    }
    
    #button-column button {
        padding: 12px 5px; /* Уменьшил боковые отступы */
        font-size: 16px;
        font-weight: 600;
        border: none;
        border-radius: 4px;
        cursor: pointer;
        font-family: 'Montserrat', 'Arial', sans-serif;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 50px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
        width: 100%; /* Занимает всю ширину колонки */
        box-sizing: border-box; /* Чтобы padding не влиял на ширину */
        white-space: nowrap; /* Текст не переносится */
        overflow: hidden; /* Скрываем текст, если не помещается */
        text-overflow: ellipsis; /* Добавляем многоточие если текст обрезается */
    }

    #button-column button:hover {
        opacity: 0.9;
        transform: none !important;
    }
    
    #page-title {
        font-size: 1.8rem;
    }
    
    #editor-container, #review-panel {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .button-icon {
        display: none;
    }
    
    #button-column button {
        padding: 12px;
        font-size: 15px;
    }
    
    #top-bar {
        padding: 10px;
        position: relative;
    }

    #theme-label {
        display: none;
    }
    
    #essay-theme {
        font-size: 0.85rem;
    }
}

#essay-theme-wrapper {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none; /* Позволяет кликать сквозь этот элемент */
}

#essay-theme-container {
    display: flex;
    justify-content: center;
    max-width: 50%;
    padding: 0 20px;
}

#essay-theme {
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 1.1rem;
    text-align: center;
    padding: 0 15px;
    pointer-events: auto; /* Включаем взаимодействие с темой */
}

.spinner {
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}