/* =====================================================
ОЗЕРО ДРУЗЕЙ — chat.css (компонент чата)
===================================================== */

/* ---------- Базовые стили ---------- */
.chat-wrap {
    max-width: 1080px;
    padding: 2rem 0 1rem;
}

.chat-notice {
    padding: 1.5rem;
    text-align: center;
}

.chat-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: .8rem;
    flex-wrap: wrap;
}

.chat-tab {
    padding: .45rem 1.1rem;
    border-radius: 999px;
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

.chat-tab.active {
    border-color: var(--turquoise);
    background: var(--turquoise-light);
    color: var(--turquoise-dark);
}

.chat-messages {
    height: 55vh;
    overflow-y: auto;
    padding: 1rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .9rem;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
}

.chat-msg {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
}

.chat-avatar {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: .9rem;
}

/* Палитра аватарок — из природных тонов проекта */
.av-0 {
    background: var(--turquoise);
}

.av-1 {
    background: var(--terracotta);
}

.av-2 {
    background: var(--green);
}

.av-3 {
    background: #5a8f8a;
}

.av-4 {
    background: #b48a3c;
}

.av-5 {
    background: #7a9a3f;
}

/* Фото-аватар (загруженный пользователем) */
.chat-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.chat-meta {
    font-size: .85rem;
    color: var(--muted);
    margin-bottom: .15rem;
}

.chat-meta strong {
    color: var(--text);
}

.chat-text {
    white-space: pre-wrap;
    word-break: break-word;
    flex: 1;
}

/* Пометка "ред." для отредактированных сообщений */
.chat-edited {
    font-size: 0.75rem;
    color: var(--muted);
    font-style: italic;
    margin-left: 0.25rem;
}

.chat-form {
    display: flex;
    gap: .6rem;
    padding: .9rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.chat-form .input {
    flex: 1;
}

/* ---------- Две колонки: чат + видео ---------- */
.chat-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 900px) {
    .chat-layout {
        grid-template-columns: 1fr;
    }
}

.chat-right {
    padding: 1rem 1.2rem;
}

.chat-right h3 {
    margin-bottom: .3rem;
}

.small {
    font-size: .8rem;
}

.video-frame {
    aspect-ratio: 16 / 9;
    background: #101a18;
    border-radius: 12px;
    overflow: hidden;
    margin: .6rem 0;
}

.video-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
}

.video-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

/* ---------- Кнопки действий (редактировать/удалить) ---------- */
.chat-msg-actions {
    margin-left: auto;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    align-items: center;
}

.chat-msg:hover .chat-msg-actions {
    opacity: 1;
}

.chat-action-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border, #ddd);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    line-height: 1;
    white-space: nowrap;
    color: #555;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.chat-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.chat-action-btn[data-action="edit"] {
    color: #4a90d9;
    border-color: #4a90d9;
}

.chat-action-btn[data-action="edit"]:hover {
    background: #4a90d9;
    color: white;
}

.chat-action-btn[data-action="delete"] {
    color: #d33;
    border-color: #d33;
}

.chat-action-btn[data-action="delete"]:hover {
    background: #d33;
    color: white;
}

/* SVG-иконки внутри кнопок */
.chat-action-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* =====================================================
ЭМОДЗИ — КАЧЕСТВЕННЫЕ (TWEMOJI) + УМНЫЕ АНИМАЦИИ
===================================================== */

/* ---------- Кнопка открытия панели ---------- */
#emoji-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#emoji-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.6s;
}

#emoji-btn:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

#emoji-btn:hover::before {
    left: 100%;
}

#emoji-btn:active {
    transform: translateY(0) scale(0.95);
}

/* ---------- Панель эмодзи ---------- */
#emoji-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    padding: 0;
    min-width: 340px;
    max-width: 380px;
    z-index: 100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: emojiPanelSlide 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes emojiPanelSlide {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Вкладки категорий ---------- */
.emoji-categories {
    display: flex;
    gap: 6px;
    padding: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px 16px 0 0;
}

.emoji-cat-btn {
    flex: 1;
    padding: 8px 12px;
    border: none;
    background: rgba(255, 255, 255, 0.7);
    color: #555;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.25s ease;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.emoji-cat-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.emoji-cat-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* ---------- Сетка эмодзи ---------- */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
    max-height: 320px;
    overflow-y: auto;
}

.emoji-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    position: relative;
}

.emoji-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    transform: scale(1.15);
}

/* ---------- Изображения Twemoji внутри кнопок ---------- */
.emoji-btn img.emoji {
    width: 28px;
    height: 28px;
    transition: transform 0.2s ease;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.emoji-btn:hover img.emoji {
    transform: scale(1.3);
}

/* ---------- УМНЫЕ АНИМАЦИИ ЭМОДЗИ ---------- */
.emoji-animated {
    display: inline-block;
    vertical-align: middle;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
    transform-origin: center center;
}

/* Трясутся — смех, радость, удивление */
@keyframes emoji-wiggle {

    0%,
    100% {
        transform: rotate(0deg) scale(1);
    }

    15% {
        transform: rotate(-12deg) scale(1.05);
    }

    30% {
        transform: rotate(10deg) scale(1.05);
    }

    45% {
        transform: rotate(-8deg) scale(1.05);
    }

    60% {
        transform: rotate(6deg) scale(1.05);
    }

    75% {
        transform: rotate(-4deg) scale(1.05);
    }
}

.emoji-wiggle {
    animation-name: emoji-wiggle;
}

/* Пульсируют — сердца, любовь */
@keyframes emoji-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    15% {
        transform: scale(1.25);
    }

    30% {
        transform: scale(1);
    }

    45% {
        transform: scale(1.2);
    }

    60% {
        transform: scale(1);
    }
}

.emoji-pulse {
    animation-name: emoji-pulse;
}

/* Подпрыгивают — жесты, одобрение, сила */
@keyframes emoji-bounce {

    0%,
    100% {
        transform: translateY(0) scale(1);
    }

    40% {
        transform: translateY(-8px) scale(1.1);
    }

    60% {
        transform: translateY(-4px) scale(1.05);
    }

    80% {
        transform: translateY(-2px) scale(1.02);
    }
}

.emoji-bounce {
    animation-name: emoji-bounce;
}

/* Покачиваются — романтика, музыка, природа */
@keyframes emoji-swing {

    0%,
    100% {
        transform: rotate(-8deg) scale(1);
    }

    50% {
        transform: rotate(8deg) scale(1.05);
    }
}

.emoji-swing {
    animation-name: emoji-swing;
}

/* Дрожат — злость, страх, тревога */
@keyframes emoji-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-3px) rotate(-2deg);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(3px) rotate(2deg);
    }
}

.emoji-shake {
    animation-name: emoji-shake;
}

/* Парят — еда, напитки, лёгкость */
@keyframes emoji-float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-4px) rotate(3deg);
    }

    50% {
        transform: translateY(-6px) rotate(0deg);
    }

    75% {
        transform: translateY(-4px) rotate(-3deg);
    }
}

.emoji-float {
    animation-name: emoji-float;
}

/* Вращаются — техника, космос, движение */
@keyframes emoji-spin {
    0% {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.1);
    }

    100% {
        transform: rotate(360deg) scale(1);
    }
}

.emoji-spin {
    animation-name: emoji-spin;
}

/* Пауза анимации при наведении на сообщение */
.chat-msg:hover .emoji-animated {
    animation-play-state: paused;
}

/* Ограничиваем размер ВСЕХ эмодзи в чате */
.chat-text img.emoji,
.chat-text .emoji {
    width: 28px !important;
    height: 28px !important;
    max-width: 28px !important;
    max-height: 28px !important;
    vertical-align: middle;
    display: inline-block;
    margin: 0 2px;
}

/* Если эмодзи в сообщении один (без текста) — делаем чуть больше */
.chat-msg:has(.chat-text img.emoji:only-child) img.emoji,
.chat-msg:has(.chat-text .emoji:only-child) .emoji {
    width: 48px !important;
    height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
}

/* ---------- Скроллбар панели эмодзи ---------- */
.emoji-grid::-webkit-scrollbar {
    width: 6px;
}

.emoji-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a42a0 100%);
}

/* =====================================================
ТЁМНАЯ ТЕМА
===================================================== */

html[data-theme="dark"] .chat-messages {
    background: rgba(15, 15, 35, 0.5);
}

html[data-theme="dark"] .chat-form {
    background: rgba(15, 15, 35, 0.5);
    border-top-color: rgba(255, 255, 255, 0.15);
}

html[data-theme="dark"] .chat-right {
    background: rgba(15, 15, 35, 0.5);
    border-radius: 12px;
}

html[data-theme="dark"] .chat-text {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .chat-meta strong {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .chat-meta {
    color: #a1a1aa;
}

html[data-theme="dark"] .chat-right h3 {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

html[data-theme="dark"] .chat-right p,
html[data-theme="dark"] .chat-right .small {
    color: #c0c0c0;
}

html[data-theme="dark"] .chat-right button {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.3);
}

html[data-theme="dark"] .chat-form .input {
    background: rgba(30, 30, 50, 0.7);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

html[data-theme="dark"] .chat-form .input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

html[data-theme="dark"] .chat-action-btn {
    background: rgba(30, 30, 50, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ccc;
}

html[data-theme="dark"] .chat-action-btn[data-action="edit"]:hover {
    background: #4a90d9;
    color: white;
}

html[data-theme="dark"] .chat-action-btn[data-action="delete"]:hover {
    background: #d33;
    color: white;
}

html[data-theme="dark"] #emoji-panel {
    background: rgba(30, 30, 50, 0.98);
    border-color: rgba(255, 255, 255, 0.15);
}

html[data-theme="dark"] .emoji-categories {
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.9) 0%, rgba(20, 20, 40, 0.9) 100%);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .emoji-cat-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ddd;
}

html[data-theme="dark"] .emoji-cat-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

html[data-theme="dark"] .emoji-cat-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

html[data-theme="dark"] .emoji-btn:hover {
    background: rgba(102, 126, 234, 0.2);
}

html[data-theme="dark"] .emoji-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}