/* Chat container - центрирование */
.chat-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 1rem;
    overflow: hidden; /* Убираем скролл */
    height: calc(100vh - 100px); /* Вся высота экрана минус навигация */
}

/* Main chat - основной блок чата */
.main-chat {
    max-width: 800px;
    width: 100%;
    height: 100%; /* Занимает всю высоту контейнера */
    background: #1e293b;
    border: 2px solid #475569;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

/* Messages area - область сообщений */
.messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #1e293b;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Message - стили для сообщений */
.message {
    max-width: 80%;
    padding: 0.75rem;
    border-radius: 12px;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease-out;
}

.message.user {
    background: #3b82f6;
    color: white;
    margin-left: auto;
    text-align: left;
}

.message.other {
    background: #475569;
    color: #e2e8f0;
    margin-right: auto;
    text-align: left;
}

.message.system {
    background: #dc2626;
    color: white;
    text-align: left;
    max-width: 100%;
    margin: 0 auto;
}

.message.success {
    background: #166534;
    color: #bbf7d0;
    text-align: left;
    max-width: 100%;
    margin: 0 auto;
    border: 1px solid #22c55e;
}

/* Message header - заголовок сообщения */
.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.8;
}

.message.user .message-header {
    flex-direction: row-reverse;
}

.message.system .message-header {
    justify-content: flex-start;
}

.message.success .message-header {
    justify-content: flex-start;
    color: #bbf7d0;
}

.sender {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.timestamp {
    opacity: 0.7;
    font-size: 0.7rem;
}

/* Message content - содержимое сообщения */
.message-content {
    line-height: 1.5;
}

/* Loading message - сообщение загрузки */
.loading-message {
    background: #475569;
    color: #e2e8f0;
}

.loading-dots {
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: loadingDots 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0s; }

/* Empty chat state - пустое состояние */
.messages:empty::before {
    content: "Start a conversation...";
    display: block;
    text-align: center;
    color: #94a3b8;
    font-style: italic;
    padding: 2rem;
    opacity: 0.6;
}

/* Animations - анимации */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loadingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input area - область ввода внизу */
.input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid #475569;
    background: #1e293b;
    margin-top: auto; /* Прижимает к низу */
    flex-shrink: 0; /* Не сжимается */
}

/* Поле ввода сообщения */
.message-input {
    flex: 1;
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.875rem;
    min-height: 44px;
}

.message-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.message-input::placeholder {
    color: #94a3b8;
}

/* Кнопка микрофона */
.microphone-btn {
    padding: 0.75rem;
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 48px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.microphone-btn:hover {
    background: #3b82f6;
    color: white;
    transform: scale(1.05);
}

.microphone-btn.recording {
    background: #dc2626;
    animation: pulse 1s infinite;
}

.microphone-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #334155;
    color: #94a3b8;
}

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

/* Кнопка отправки */
.send-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 80px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: #2563eb;
}

.send-btn:disabled {
    background: #64748b;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Finish button in header */
.finish-btn {
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 120px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finish-btn:hover {
    background: #b91c1c;
}

/* Мобильная адаптивность */
@media (max-width: 768px) {
    .chat-container {
        padding: 0.5rem;
        height: calc(100vh - 80px); /* Учитываем навигацию для планшетов */
    }
    
    .main-chat {
        max-width: 95%;
        border-radius: 8px;
        height: 100%; /* Занимает всю высоту контейнера */
    }
    
    .input-area {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .message-input {
        padding: 0.75rem;
        font-size: 0.9rem;
        min-height: 40px;
    }
    
    .send-btn {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        min-width: 70px;
        height: 40px;
    }
    
    .messages {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .message {
        max-width: 85%;
        padding: 0.625rem;
        border-radius: 10px;
    }
    
    .message-header {
        font-size: 0.7rem;
        margin-bottom: 0.375rem;
    }
}

@media (max-width: 480px) {
    .chat-container {
        height: calc(100vh - 80px); /* Учитываем навигацию для мобильных */
    }
    
    .main-chat {
        max-width: 98%;
        border-radius: 6px;
        height: 100%; /* Занимает всю высоту контейнера */
    }
    
    .input-area {
        padding: 0.5rem;
        gap: 0.375rem;
    }
    
    .message-input {
        padding: 0.5rem;
        font-size: 0.85rem;
        min-height: 36px;
    }
    
    .send-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-width: 60px;
        height: 36px;
    }
    
    .messages {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .message {
        max-width: 90%;
        padding: 0.5rem;
        border-radius: 8px;
    }
    
    .message-header {
        font-size: 0.65rem;
        margin-bottom: 0.25rem;
    }
}

/* Chat header - заголовок чата */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #475569;
    background: #1e293b;
}

.chat-header h2 {
    margin: 0;
    color: #e2e8f0;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Text scale selector - селектор масштаба */
.text-scale-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.text-scale-selector label {
    color: #94a3b8;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.scale-select {
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 80px;
}

/* Мобильная адаптивность для хедера */
@media (max-width: 768px) {
    .chat-header {
        padding: 0.75rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
    
    .chat-header h2 {
        font-size: 1.1rem;
    }
    
    .text-scale-selector {
        align-self: flex-end;
    }
    
    .scale-select {
        min-width: 70px;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 0.5rem;
        gap: 0.5rem;
        flex-direction: row; /* Оставляем горизонтальное расположение */
        align-items: center;
        justify-content: space-between;
    }
    
    .chat-header h2 {
        font-size: 1rem;
    }
    
    .text-scale-selector {
        gap: 0.25rem;
    }
    
    .text-scale-selector label {
        font-size: 0.8rem;
    }
    
    .scale-select {
        min-width: 60px;
        padding: 0.375rem;
        font-size: 0.8rem;
    }
}

/* Voice Recording Modal Styles */
.voice-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    backdrop-filter: blur(10px);
}

.voice-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-modal-content {
    background: #1e293b;
    border-radius: 50%;
    width: 300px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 3px solid #3b82f6;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    animation: modalAppear 0.3s ease-out;
}

.voice-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #334155;
    border: 1px solid #475569;
    color: #cbd5e1;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    z-index: 2001;
    user-select: none;
}

.voice-close-btn:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3);
}

.voice-close-btn:active {
    transform: scale(0.95);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.voice-timer {
    position: absolute;
    top: 20px;
    font-size: 2rem;
    font-weight: bold;
    color: #f1f5f9;
    background: #334155;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 2px solid #3b82f6;
}

.voice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.voice-send-btn {
    padding: 1rem 2rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.voice-send-text {
    position: relative;
    z-index: 2;
}

.voice-send-progress {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    transition: width 0.1s linear;
    z-index: 1;
}

.voice-send-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(59, 130, 246, 0.4);
}

.voice-status {
    position: absolute;
    bottom: 20px;
    color: #cbd5e1;
    font-size: 1rem;
    text-align: center;
    padding: 0.5rem 1rem;
    background: #334155;
    border-radius: 20px;
    border: 1px solid #475569;
}

.voice-visualizer {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 40px;
}

.voice-visualizer.active {
    display: flex;
}

.visualizer-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 100%;
}

.visualizer-bars .bar {
    width: 4px;
    background: #3b82f6;
    border-radius: 2px;
    transition: height 0.1s ease;
    min-height: 4px;
}

.voice-audio-status {
    position: absolute;
    bottom: 60px;
    text-align: center;
    padding: 8px 16px;
    background: #334155;
    border-radius: 20px;
    border: 1px solid #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 140px;
}

.audio-playing-indicator {
    font-size: 14px;
    animation: pulse 1s infinite;
}

.audio-status-text {
    color: #cbd5e1;
    font-size: 0.9rem;
}

/* Mobile responsiveness for voice modal */
@media (max-width: 768px) {
    .voice-modal-content {
        width: 250px;
        height: 250px;
    }
    
    .voice-timer {
        font-size: 1.5rem;
        padding: 0.375rem 0.75rem;
    }
    
    .voice-send-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    .voice-status {
        font-size: 0.9rem;
        padding: 0.375rem 0.75rem;
    }
}

@media (max-width: 480px) {
    .voice-modal-content {
        width: 200px;
        height: 200px;
    }
    
    .voice-timer {
        font-size: 1.25rem;
        padding: 0.25rem 0.5rem;
    }
    
    .voice-send-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .voice-status {
        font-size: 0.8rem;
        padding: 0.25rem 0.5rem;
    }
}
