﻿/* صفحه چت */
.chat-page {
    background: radial-gradient(1200px 600px at 50% -200px,#f7f9fc 60%,#edf1f6);
    min-height: 100dvh;
}

/* نخ گفتگو */
.chat-thread {
    padding: 12px 10px 120px; /* جایی برای composer */
    overflow-y: auto;
    height: 58dvh;
    scroll-behavior: smooth;
}

/* حباب‌ها */
.msg {
    max-width: 86%;
    margin: 8px 0;
    padding: 10px 12px;
    border-radius: 16px;
    line-height: 1.7;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    animation: fadeIn .2s ease-out;
}

    .msg .meta {
        font-size: .72rem;
        opacity: .6;
        margin-top: 3px;
        white-space: nowrap;
        text-align: left;
    }

    .msg img {
        max-width: 100%;
        border-radius: 12px;
        display: block;
    }

/* من (راست) */
.me {
    margin-left: auto;
    background: linear-gradient(135deg,#2A72C0,#5CA9E6);
    color: #fff;
    border-top-right-radius: 6px;
}

    .me .meta {
        color: #eaf4ff;
    }

/* طرف مقابل (چپ) */
.them {
    margin-right: 0;
    color: #223;
    border-top-left-radius: 6px;
}

/* جداکننده تاریخ */
.day-sep {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

    .day-sep span {
        font-size: .75rem;
        padding: 4px 10px;
        border-radius: 10px;
        background: #eef2f6;
        color: #667;
    }

/* --- نوار ورودی (Composer) --- */
.composer-wrap {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    padding: 8px 10px;
    box-sizing: border-box;
    z-index: 999;
}

.composer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    max-width: 100%;
}

    .composer textarea {
        flex-grow: 1;
        width: 100%;
        min-height: 40px;
        max-height: 120px;
        border: none;
        outline: none;
        resize: none;
        background: #f9f9f9;
        border-radius: 18px;
        padding: 8px 12px;
        font-size: 15px;
    }


.icon-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #2A72C0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    min-height: 42px;
    border-radius: 50%;
}

    .icon-btn:disabled {
        opacity: 0.45;
    }

/* ارسال داخل همان ردیف */
.send-btn {
    background: linear-gradient(135deg, #2A72C0, #5CA9E6);
    color: #fff;
    font-size: 1.25rem;
    padding: 6px;
}

/* ضبط صدا */
.recording-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #c62828;
    font-size: 0.9rem;
    font-weight: 600;
}

.dot {
    width: 10px;
    height: 10px;
    background: #c62828;
    border-radius: 50%;
}

.blink {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50%, 100% {
        opacity: 1;
    }

    25%, 75% {
        opacity: 0;
    }
}

/* پیش‌نمایش عکس */
.preview-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.preview-thumb {
    height: 55px;
    width: 55px;
    border-radius: 10px;
    object-fit: cover;
    border: 2px solid #e0e0e0;
}

.cancel-btn {
    background: none;
    border: none;
    color: #c62828;
    font-size: 1.3rem;
}

/* حالت تاریک */
.theme-dark .chat-page {
    background: #16181c;
}

.theme-dark .them {
    background: #2a2f36;
    color: #e9edf3;
}

.theme-dark .composer {
    background: #20242b;
    border-color: #2c3440;
}

.theme-dark .composer-text {
    color: #e9edf3;
}

.theme-dark .day-sep span {
    background: #2a2f36;
    color: #9aa4b2;
}

/* انیمیشن ظاهر شدن پیام */
@keyframes fadeIn {
    from {
        opacity: .0;
        transform: translateY(2px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* === Chat Thread Container === */
.chat-thread {
    display: flex;
    flex-direction: column; /* 👈 پیام‌ها زیر هم */
    gap: 8px;
    padding: 10px 14px 110px; /* فضای پایین برای composer */
    overflow-y: auto;
    max-height: 75vh;
}

/* === پیام مخاطب (سمت چپ) === */
.message-left {
    align-self: flex-start;
    background: #f3f3f3;
    color: #222;
    border-radius: 16px 16px 16px 4px;
    padding: 10px 14px;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    display: inline-block;
    word-wrap: break-word;
}

/* === پیام کاربر (سمت راست) === */
.message-right {
    align-self: flex-end;
    background: #d8fdee;
    color: #111;
    border-radius: 16px 16px 4px 16px;
    padding: 10px 14px;
    max-width: 80%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    display: inline-block;
    word-wrap: break-word;
}

/* === ساعت پیام === */
.message-time {
    display: block;
    font-size: 0.75rem;
    color: #999;
    text-align: left;
    margin-top: 4px;
}

.message-right .message-time {
    text-align: right;
    color: #888;
}

/* === برای عکس و صوت داخل پیام === */
.message-left img, .message-right img {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 5px;
}

.message-left audio, .message-right audio {
    width: 100%;
    margin-top: 5px;
}

/* موبایل */
@media (max-width: 768px) {
    .chat-thread {
        max-height: calc(100vh - 160px);
        padding-bottom: 120px;
    }
}

.recording-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff8f8;
    padding: 10px 16px;
    border-radius: 24px;
    border: 1px solid #ffd7d7;
}

.recording-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #d33;
    font-weight: 500;
    font-size: 14px;
}

.recording-timer {
    font-family: monospace;
    color: #444;
    font-weight: bold;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff3b30;
}

.blink {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50%, 100% {
        opacity: 1;
    }

    25%, 75% {
        opacity: 0;
    }
}

.icon-btn.stop-btn {
    background: #ff3b30;
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn.cancel-btn {
    background: transparent;
    border: none;
    color: #999;
    font-size: 22px;
}

.recorded-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f5faff;
    padding: 10px 14px;
    border-radius: 20px;
    border: 1px solid #d0e3ff;
    max-width:80%;
}

.audio-preview {
    flex-grow: 1;
    margin-left: 10px;
}
