/* Стили для чата */
html, body {
    height: 100%;
    height: 100vh;
    height: 100dvh; /* Динамическая высота viewport для мобильных */
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.cabinet-page {
    height: 100%;
    height: 100vh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100); /* Fallback для JS */
    background: linear-gradient(135deg, #1c96a6 0%, #2a9d8f 50%, #e9c46a 100%);
    padding: 60px 1rem 0 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
}

#cabinetContent {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.cabinet-content {
    display: none;
    animation: fadeIn 0.5s ease;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.cabinet-content.active {
    display: flex !important;
}

/* Вкладка чата на всю высоту */
#tabChat {
    height: 100%;
}

#tabChat.active {
    display: flex;
    flex-direction: column;
}

.chat-container {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    min-height: 0; /* Важно для flexbox */
}

.keyboard-container {
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0 0 20px 20px;
    transition: opacity 0.4s ease, transform 0.4s ease, max-height 0.6s ease 0.2s, padding 0.6s ease 0.2s, margin 0.6s ease 0.2s;
}

.keyboard-container.removing {
    opacity: 0;
    transform: scale(0.95);
    max-height: 0;
    padding: 0 1.5rem;
    margin-top: 0;
    overflow: hidden;
}

/* Вкладка профиля */
#tabProfile {
    height: 100%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 2.5rem;
    padding: 2.5rem;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    margin-bottom: 2rem;
    transition: transform 0.4s ease;
}

/* Адаптивность */
@media (max-width: 768px) {
    .cabinet-page {
        padding: 70px 1rem 1rem 1rem;
    }

    .chat-container {
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
    }

    .messages-container {
        padding: 1rem;
    }

    .keyboard-container {
        padding: 1rem;
    }

    .user-profile {
        flex-direction: column;
        text-align: center;
        padding: 1.5rem;
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    .cabinet-page {
        padding: 60px 0.8rem 0.8rem 0.8rem;
    }

    .chat-container {
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }
}

/* Остальные стили для сообщений */
.message {
    margin-bottom: 1rem;
    max-width: 80%;
}

.message.incoming {
    margin-right: auto;
}

.message.outgoing {
    margin-left: auto;
}

.message-bubble {
    padding: 0.8rem 1.2rem;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: #1a1a1a;
    font-weight: 300;
    font-size: 1rem;
    line-height: 1.5;
    letter-spacing: 0.2px;
}

.message-bubble:not(.message-bubble-top):not(.message-bubble-bottom) {
    border-radius: 20px;
}

.message-bubble.message-bubble-top {
    border-radius: 20px 20px 0 0;
}

.message-bubble.message-bubble-bottom {
    border-radius: 0 0 20px 20px;
}

.message-bubble.message-bubble-top.message-bubble-bottom {
    border-radius: 20px;
}

.message-bubble.message-bubble-full {
    border-radius: 20px !important;
}

.incoming .message-bubble {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #1a1a1a;
}

.outgoing .message-bubble {
    background: linear-gradient(135deg, #1c96a6, #2a9d8f);
    border: 1px solid rgba(42, 157, 143, 0.3);
    color: white;
    font-weight: 400;
}

.message-meta {
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.4);
    margin-top: 0.3rem;
    padding-left: 0.5rem;
    font-weight: 300;
}

/* Непрочитанные сообщения - желтая рамка */
.message.unread .message-bubble {
    border: 2px solid #f4a261 !important;
    box-shadow: 0 4px 12px rgba(244, 162, 97, 0.25);
}

/* Прочитанные сообщения - зеленая галочка */
.message.read .message-bubble {
    position: relative;
}

.message-checkmark {
    position: absolute;
    bottom: 8px;
    right: 12px;
    width: 18px;
    height: 18px;
    background: #2a9d8f;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
}

.keyboard-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.inline-button {
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: #1a1a1a;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    font-size: 0.95rem;
}

.inline-button:hover {
    transform: translateY(-3px) scale(1.03);
    background: rgba(255, 255, 255, 0.4);
    border-color: var(--color-yellow-accent);
    box-shadow: 0 8px 25px rgba(244, 162, 97, 0.3);
}

/* Стили для системных сообщений */
.message.system .message-bubble {
    background: rgba(255, 255, 255, 0.05);
    font-style: italic;
    font-weight: 300;
    text-align: center;
    max-width: 90%;
    margin: 0 auto;
}

/* Стили для сообщений об ошибках/успехе */
.error-message {
    padding: 1rem;
    background: rgba(220, 53, 69, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(220, 53, 69, 0.3);
    border-radius: 10px;
    color: #ff8a8a;
    text-align: center;
    margin-top: 1rem;
    font-weight: 400;
}

.success-message {
    padding: 1rem;
    background: rgba(40, 167, 69, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(40, 167, 69, 0.3);
    border-radius: 10px;
    color: #8bff8b;
    text-align: center;
    margin-top: 1rem;
    font-weight: 400;
}

/* Стили для скроллбара */
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}