/* ====================================
   BASE
==================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Segoe UI, sans-serif;
}

body {
    background: #efe7dd;
}

/* ====================================
   SIDEBAR (لیست مخاطبین)
==================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 350px;
    height: 100vh;
    background: white;
    border-right: 1px solid #ddd;
}

.sidebar-header {
    height: 65px;
    background: #075E54;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
}

.sidebar-header h2 {
    font-size: 20px;
}

.sidebar-header .logout {
    color: white;
    text-decoration: none;
    font-size: 14px;
}

.chat-list {
    padding: 10px;
    height: calc(100vh - 65px);
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: #222;
}

.chat-item:hover {
    background: #f5f5f5;
}

.chat-item img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

.chat-info b {
    display: block;
}

.chat-info small {
    color: #555;
}

/* ====================================
   CHAT SECTION
==================================== */
.chat-container {
    margin-left: 350px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.chat-header {
    height: 65px;
    background: #075E54;
    color: white;
    display: flex;
    align-items: center;
    padding: 10px;
}

.chat-header img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 10px;
}

/* دکمه Back */
.back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 10px;
    border-radius: 50%;
    text-decoration: none;
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.back-btn:hover {
    background: rgba(255,255,255,0.15);
}

.chat-header b {
    display: block;
}

.chat-header small {
    display: block;
    font-size: 12px;
}

/* ====================================
   CHAT BOX
==================================== */
.chat-box {
    flex: 1;
    padding: 15px 5%;
    overflow-y: auto;
    background-image: url('chat-bg.png'); /* آدرس عکس شما */
    background-size: cover; /* عکس را به اندازه کل کادر در می‌آورد */
    background-position: center; /* عکس را وسط‌چین می‌کند */
    background-repeat: no-repeat; /* جلوگیری از تکرار شدن عکس */
}


/* حباب‌های پیام */
.message-row {
    display: flex;
    width: 100%;
    margin: 4px 0;
}

.me-row {
    justify-content: flex-end;
}

.not-me-row {
    justify-content: flex-start;
}

.bubble {
    width: fit-content;
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 15px;
    position: relative;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
}

.me {
    background: #dcf8c6;
    border-top-right-radius: 0; /* استایل گوشه پیام واتساپ */
}

.not-me {
    background: white;
    border-top-left-radius: 0; /* استایل گوشه پیام واتساپ */
}

.bubble-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.timestamp {
    display: inline-block;
    font-size: 11px;
    color: #888;
}

.delete-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    opacity: 0.7;
}

/* فایل ضمیمه در پیام */
.file-link {
    display: block;
    margin-top: 5px;
    color: #0645AD;
    text-decoration: none;
}

.file-link:hover {
    text-decoration: underline;
}

/* ====================================
   INPUT
==================================== */
.chat-input {
    padding: 10px;
    background: #f0f0f0;
    display: flex;
    align-items: center; /* تراز کردن در مرکز */
    gap: 8px;
}

.attach-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #54656f; /* رنگ خاکستری تیره مثل واتساپ */
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.attach-btn:hover {
    background: #e4e4e4;
}

/* وقتی فایلی انتخاب شد، رنگ آیکون سبز می‌شود تا کاربر متوجه شود */
.attach-btn.has-file {
    color: #00a884;
    background: #dcf8c6;
}


.chat-input input[type="text"] {
    flex: 1;
    padding: 12px;
    border-radius: 20px;
    border: 1px solid #ccc;
    outline: none;
}

.chat-input input[type="file"] {
    width: 180px;
    align-self: center;
}

.chat-input button {
    width: 80px;
    background: #00a884;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

/* ====================================
   STATUS DOT (در لیست مخاطبین)
==================================== */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 6px;
    display: inline-block;
}

.status-online {
    background: #25D366;
}

.status-offline {
    background: #ccc;
}

@media (max-width: 800px) {
    .sidebar {
        width: 100%;
        height: 100vh;
        position: relative;
        display: flex;
        flex-direction: column;
    }
    .chat-container {
        margin-left: 0;
        width: 100%;
        height: 100vh;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 100;
        background: #efe7dd;
    }
    .empty-chat {
        display: none !important;
    }
    .back-btn {
        display: inline-flex !important;
    }
}
@media (max-width: 800px) {
    /* سایر کدهایی که از قبل اینجا بود بماند... */

    .chat-input {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        box-sizing: border-box;
        z-index: 1000;
    }

    /* برای اینکه پیام‌های آخر زیر باکسِ فیکس‌شده مخفی نشوند، به باکس چت پدینگ می‌دهیم */
    .chat-box {
        padding-bottom: 70px; 
    }
}


/* تنظیمات سایدبار و محیط چت برای زبان فارسی (راست‌چین) در دسکتاپ */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid #ddd;
}

[dir="rtl"] .chat-container {
    margin-left: 0;
    margin-right: 350px;
}


/* ===== FIX DESKTOP FULL WIDTH ===== */
@media (min-width: 801px) {

    body {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 350px;
        height: 100vh;
    }

    .chat-container {
        margin-left: 350px;
        margin-right: 0;
        width: calc(100% - 350px);
        height: 100vh;
    }

    [dir="rtl"] .chat-container {
        margin-right: 350px;
        margin-left: 0;
        width: calc(100% - 350px);
    }
}
