* {

    margin: 0;

    padding: 0;

    box-sizing: border-box;

    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

}



body {

    background: #0a0c10;

    min-height: 100vh;

    direction: rtl;

    color: #e4e6eb;

}



/* ================= LOGIN PAGE ================= */



.container {

    display: flex;

    justify-content: center;

    align-items: center;

    min-height: 100vh;

    padding: 16px;

    background: #0a0c10;

}


video {
    width: 100%;
}

.login-box {

    background: #1e2a3a;

    padding: 32px 24px;

    border-radius: 16px;

    width: 100%;

    max-width: 400px;

    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);

    border: 1px solid #2d3d54;

}



.login-box h1 {

    text-align: center;

    color: #ffffff;

    font-size: 26px;

    margin-bottom: 28px;

    font-weight: 600;

}



.login-box input {

    width: 100%;

    padding: 14px 16px;

    margin-bottom: 16px;

    border-radius: 12px;

    border: 1px solid #2d3d54;

    background: #141a24;

    color: #ffffff;

    font-size: 15px;

}



.login-box input:focus {

    outline: none;

    border-color: #3390ec;

    background: #1a222f;

}



.login-box input::placeholder {

    color: #7e8a98;

}



.login-box button {

    width: 100%;

    padding: 14px;

    background: #3390ec;

    color: #ffffff;

    border: none;

    border-radius: 12px;

    font-weight: 600;

    font-size: 16px;

    cursor: pointer;

    transition: background 0.2s;

    margin-top: 8px;

}



.login-box button:hover {

    background: #2a7bcc;

}



#message {

    margin-top: 16px;

    padding: 10px;

    border-radius: 8px;

    text-align: center;

    font-size: 14px;

}



#message.error {

    background: rgba(220, 38, 38, 0.2);

    color: #ff8a8a;

}



#message.info {

    background: rgba(51, 144, 236, 0.2);

    color: #90caf9;

}



/* ================= CHAT PAGE ================= */



.chat-container {

    max-width: 900px;

    margin: 0 auto;

    height: 100vh;

    background: #0f1824;

    display: flex;

    flex-direction: column;

}



/* Header */

.chat-header {

    background: #1e2a3a;

    padding: 12px 16px;

    display: flex;

    justify-content: space-between;

    align-items: center;

    border-bottom: 1px solid #2d3d54;

}



.chat-header h2 {

    color: #ffffff;

    font-size: 16px;

    font-weight: 600;

}



.header-buttons {

    display: flex;

    gap: 8px;

}



.btn-danger {

    background: transparent;

    color: #ff7b7b;

    border: 1px solid #ff7b7b;

    padding: 6px 12px;

    border-radius: 6px;

    font-size: 13px;

    cursor: pointer;

}



.btn-danger:hover {

    background: rgba(255, 123, 123, 0.1);

}



.btn-logout {

    background: transparent;

    color: #e4e6eb;

    border: 1px solid #2d3d54;

    padding: 6px 12px;

    border-radius: 6px;

    font-size: 13px;

    text-decoration: none;

}



.btn-logout:hover {

    background: rgba(255, 255, 255, 0.05);

}



/* Messages Area */

.chat-messages {

    flex: 1;

    padding: 16px;

    overflow-y: auto;

    background: #0f1824;

    display: flex;

    flex-direction: column;

    gap: 8px;

}



/* پیام‌ها */

.message {

    max-width: 85%;

    padding: 8px 12px;

    border-radius: 8px;

    position: relative;

    background: #1e2a3a;

    align-self: flex-start;

    margin-bottom: 4px;

}



/* پیام‌های خودی */

.message.own-message {

    background: #2b3b4c;

    align-self: flex-end;

}



.message-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    margin-bottom: 4px;

    font-size: 12px;

}



.username {

    color: #3390ec;

    font-weight: 600;

    font-size: 13px;

}



.timestamp {

    font-size: 10px;

    color: #7e8a98;

    margin-right: 8px;

}



.message-content {

    font-size: 14px;

    line-height: 1.3;

    color: #e4e6eb;

    white-space: pre-wrap;

    word-break: break-word;

}



.message-content a {

    color: #3390ec;

    text-decoration: none;

}



.message-content a:hover {

    text-decoration: underline;

}



/* تصاویر و فایل‌ها */

.message img {

    max-width: 100%;

    max-height: 200px;

    border-radius: 6px;

    margin-top: 6px;

    cursor: pointer;

}



.message a[download] {

    display: inline-block;

    margin-top: 6px;

    padding: 6px 12px;

    background: #2d3d54;

    border-radius: 6px;

    color: #3390ec;

    text-decoration: none;

    font-size: 12px;

}



.message a[download]:hover {

    background: #3a4a63;

}



/* دکمه کپی */

.copy-btn {

    background: transparent;

    border: none;

    color: #7e8a98;

    font-size: 14px;

    cursor: pointer;

    padding: 2px 6px;

    margin-top: 4px;

    border-radius: 4px;

}



.copy-btn:hover {

    color: #3390ec;

    background: rgba(51, 144, 236, 0.1);

}



/* دکمه حذف (همیشه نمایش داده بشه) */

.delete-btn {

    background: transparent;

    border: none;

    color: #ff7b7b;

    font-size: 12px;

    cursor: pointer;

    padding: 4px 8px;

    margin-top: 4px;

    border-radius: 4px;

    display: inline-block;

}



.delete-btn:hover {

    background: rgba(255, 123, 123, 0.1);

}



/* ================= INPUT AREA ================= */



.chat-input {

    background: #1e2a3a;

    padding: 10px 12px;

    border-top: 1px solid #2d3d54;

}



#message-form {

    display: flex;

    align-items: center;

    gap: 8px;

}



#message-text {

    flex: 1;

    padding: 10px 14px;

    border-radius: 20px;

    border: 1px solid #2d3d54;

    background: #0f1824;

    color: #ffffff;

    font-size: 14px;

    resize: none;

    min-height: 40px;

    max-height: 100px;

    line-height: 1.5;

}



#message-text:focus {

    outline: none;

    border-color: #3390ec;

}



#message-text::placeholder {

    color: #7e8a98;

}



.file-label {

    background: #2d3d54;

    color: #ffffff;

    width: 40px;

    height: 40px;

    border-radius: 50%;

    display: flex;

    align-items: center;

    justify-content: center;

    cursor: pointer;

    font-size: 20px;

    flex-shrink: 0;

}



.file-label:hover {

    background: #3a4a63;

}



#message-form button {

    background: #3390ec;

    color: #ffffff;

    border: none;

    width: 70px;

    height: 40px;

    border-radius: 20px;

    font-size: 14px;

    font-weight: 500;

    cursor: pointer;

    flex-shrink: 0;

}



#message-form button:hover {

    background: #2a7bcc;

}



/* ================= FILE PREVIEW ================= */







#file-preview {



    margin-top: 8px;



    padding: 8px 16px;



    background: #0f1824;



    border-radius: 20px;



    font-size: 13px;



    color: #3390ec;



    border: 1px solid #2d3d54;



    display: none; /* مخفی به صورت پیش‌فرض */



    animation: slideDown 0.2s ease-out;



    max-width: fit-content;



}







#file-preview:not(:empty) {



    display: inline-block; /* فقط وقتی محتوا داره نمایش بده */



}







#file-preview div {



    display: flex;



    align-items: center;



    gap: 8px;



}







#file-preview span[onclick] {



    color: #ff7b7b;



    cursor: pointer;



    font-size: 16px;



    padding: 0 4px;



}







#file-preview span[onclick]:hover {



    color: #ff5252;



}







@keyframes slideDown {



    from {



        opacity: 0;



        transform: translateY(-10px);


    }

    to {

        opacity: 1;

        transform: translateY(0);

    }

}



/* ================= SCROLLBAR ================= */



.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #2d3d54;
    border-radius: 4px;

}



/* ================= MOBILE ================= */



@media (max-width: 768px) {


    .chat-container {

        height: 100vh;

        height: 100dvh;

        position: relative; /* تغییر از fixed به relative */

        top: 0;

        left: 0;

        right: 0;

        bottom: 0;

        margin: 0;

        max-width: 100%;

    }

    

    body {


        position: relative;


    }


    


    .chat-header {

        padding: 10px 12px;

    }



    .chat-header h2 {

        font-size: 15px;

    }



    .btn-danger, .btn-logout {

        padding: 5px 10px;

        font-size: 12px;

    }



    .message {

        max-width: 90%;

        padding: 6px 10px;

    }



    .message-content {

        font-size: 14px;

    }



    .username {

        font-size: 12px;

    }



    .timestamp {

        font-size: 9px;

    }



    .chat-input {

        padding: 8px 10px;

    }



    #message-text {

        padding: 8px 12px;

        min-height: 36px;

        font-size: 14px;

    }



    .file-label {

        width: 36px;

        height: 36px;

        font-size: 18px;

    }



    #message-form button {

        width: 60px;

        height: 36px;

        font-size: 13px;

    }



    .login-box {

        padding: 24px 20px;

    }



    .login-box h1 {

        font-size: 22px;

        margin-bottom: 20px;

    }



    .login-box input,

    .login-box button {

        padding: 12px;

        font-size: 14px;

    }

}



@media (max-width: 400px) {

    .chat-header h2 {

        font-size: 14px;

    }



    .message {

        max-width: 95%;

    }



    .header-buttons {

        gap: 4px;

    }



    .btn-danger, .btn-logout {

        padding: 4px 8px;

        font-size: 11px;

    }



    #message-form button {

        width: 55px;

        font-size: 12px;

    }

}


/* استایل برای پیام‌های خودی که ریپلای شدن */

.message.own-message.replied-message {

    background: #324a5e !important;

    border-right-color: #888;

}



.message.own-message.replied-message:hover {

    background: #3a556b !important;

    border-right-color: #3390ec;

}


/* ================= STYLES FOR REPLY SYSTEM ================= */



/* استایل برای پیام‌های قدیمی که ریپلای شدن */

.message.replied-message {

    background: #2a3a4a !important;

    border-right: 3px solid #666;

    opacity: 0.8;

    transition: all 0.3s ease;

}



.message.replied-message:hover {

    opacity: 1;

    background: #2d3d54 !important;

    border-right-color: #3390ec;

}



/* استایل برای باکس ریپلای بالای فرم ارسال */

#reply-box {

    background: #2a3a4a;

    border-right: 3px solid #888;

    padding: 10px 15px;

    margin-bottom: 10px;

    border-radius: 8px;

    font-size: 13px;

    animation: slideDown 0.2s ease-out;

}



.reply-content {

    display: flex;

    align-items: center;

    gap: 10px;

    flex-wrap: wrap;

}



.reply-label {

    color: #aaa;

    font-weight: 600;

    font-size: 12px;

}



.reply-text {

    color: #ccc;

    flex: 1;

    font-style: italic;

}



.close-reply {

    color: #ff7b7b;

    cursor: pointer;

    font-size: 18px;

    padding: 0 6px;

    transition: color 0.2s;

}



.close-reply:hover {

    color: #ff5252;

}



/* استایل برای نمایش پیام ریپلای شده در داخل پیام */

.reply-indicator {

    display: flex;

    align-items: center;

    gap: 8px;

    background: #253545;

    padding: 6px 10px;

    margin-bottom: 8px;

    border-radius: 6px;

    border-left: 2px solid #888;

    cursor: pointer;

    font-size: 12px;

    transition: all 0.2s;

}



.reply-indicator:hover {

    background: #2d3d54;

    border-left-color: #3390ec;

}



.reply-arrow {

    color: #888;

    font-size: 14px;

}



.reply-preview {

    flex: 1;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;

}



.reply-username {

    color: #aaa;

    font-weight: 600;

    margin-left: 5px;

}



.reply-message {

    color: #999;

    font-style: italic;

}



/* استایل برای پیام‌هایی که بهشون ریپلای شده (هایلایت موقت) */

@keyframes highlightReply {

    0% { background: rgba(51, 144, 236, 0.3); }

    50% { background: rgba(51, 144, 236, 0.2); }

    100% { background: transparent; }

}



.highlight-message {

    animation: highlightReply 2s ease;

}




/* استایل برای نمایش تعداد آنلاین */

.online-badge {

    display: flex;

    align-items: center;

    gap: 5px;

    background: #1e2a3a;

    padding: 4px 10px;

    border-radius: 20px;

    font-size: 13px;

    border: 1px solid #2d3d54;

}



.online-dot {

    width: 8px;

    height: 8px;

    background: #4caf50;

    border-radius: 50%;

    display: inline-block;

    animation: pulse 2s infinite;

}



@keyframes pulse {

    0% {

        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);

    }

    70% {

        box-shadow: 0 0 0 5px rgba(76, 175, 80, 0);

    }

    100% {

        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);

    }

}



/* رنگ‌های مختلف بر اساس تعداد */

.online-badge.online-low .online-dot {

    background: #ff9800;

}



.online-badge.online-medium .online-dot {

    background: #4caf50;

}



.online-badge.online-high .online-dot {

    background: #2196f3;

}



#online-count {

    font-weight: bold;

    margin-left: 2px;

}



/* برای موبایل */

@media (max-width: 768px) {

    .online-badge {

        padding: 3px 8px;

        font-size: 12px;

    }

    

    .online-dot {

        width: 6px;

        height: 6px;

    }

}


/* ================= فیلتر کردن فرد ================= */



.filter-bar {

    background: #1e2a3a;

    padding: 10px 16px;

    border-bottom: 1px solid #2d3d54;

    display: flex;

    align-items: center;

    gap: 10px;

    font-size: 14px;

}



.filter-active {

    background: #3390ec;

    color: white;

    padding: 4px 10px;

    border-radius: 16px;

    display: flex;

    align-items: center;

    gap: 5px;

}



.filter-active span {

    font-weight: bold;

}



.clear-filter-btn {

    background: transparent;

    border: 1px solid #ff7b7b;

    color: #ff7b7b;

    padding: 4px 12px;

    border-radius: 16px;

    cursor: pointer;

    font-size: 12px;

    transition: all 0.2s;

}



.clear-filter-btn:hover {

    background: rgba(255, 123, 123, 0.1);

}



.username-filterable {

    cursor: pointer;

    transition: all 0.2s;

    padding: 2px 4px;

    border-radius: 4px;

}



.username-filterable:hover {

    background: rgba(51, 144, 236, 0.2);

    text-decoration: underline;

}


/* ===== پیام‌های خوانده نشده ===== */
.unread-badge {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: #e53935;
    color: white;
    padding: 6px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 6px;
    z-index: 999;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    animation: pulse 2s infinite;
}

.unread-badge:hover {
    background: #c62828;
}

@keyframes pulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50%       { transform: translateX(-50%) scale(1.05); }
}

.first-unread-marker {
    text-align: center;
    margin: 10px 0;
    position: relative;
}

.first-unread-marker::before,
.first-unread-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: #e53935;
}

.first-unread-marker::before { right: 0; }
.first-unread-marker::after  { left: 0; }

.first-unread-marker span {
    background: #fff3f3;
    color: #e53935;
    font-size: 12px;
    font-weight: bold;
    padding: 3px 12px;
    border-radius: 10px;
    border: 1px solid #e53935;
}


.new-messages-separator {
    text-align: center;
    color: #e74c3c;
    font-size: 12px;
    padding: 8px 0;
    margin: 5px 0;
    border-top: 1px dashed #e74c3c;
    font-weight: bold;
    direction: rtl;
}

/* ===========================
   لایک - زیر هر پیام
   =========================== */
.like-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.like-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: #8899aa;
    padding: 3px 10px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.like-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
}
.like-btn.liked {
    background: rgba(239, 68, 68, 0.15);
    border-color: #ef4444;
    color: #f87171;
}

.like-count {
    font-size: 12px;
}

.likers-list {
    font-size: 11px;
    color: #7a8a9a;
    line-height: 1.5;
    direction: rtl;
}
.liker-name {
    color: #60a5fa;
    font-weight: 500;
}

/* ===========================
   نوتیفیکیشن لایک - بالای صفحه (دائمی)
   =========================== */
#like-notif-container {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 90%;
    max-width: 450px;
    pointer-events: none;
}

.like-notif {
    background: linear-gradient(135deg, #1a2a4a, #1e3a5f);
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: all;
}
.like-notif.show {
    opacity: 1;
    transform: translateY(0);
}
.like-notif.hiding {
    opacity: 0;
    transform: translateX(100px);
}

.like-notif-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.like-notif-icon {
    font-size: 22px;
    flex-shrink: 0;
}
.like-notif-text {
    font-size: 13px;
    color: #c8d6e5;
    line-height: 1.5;
    direction: rtl;
}
.like-notif-text strong {
    color: #60a5fa;
}
.like-notif-text em {
    color: #8899aa;
    font-style: normal;
}

.like-notif-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #8899aa;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.like-notif-close:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

@media (max-width: 480px) {
    #like-notif-container {
        width: 95%;
        top: 5px;
    }
    .like-notif {
        padding: 10px 12px;
    }
    .like-notif-text {
        font-size: 12px;
    }
}


/* دکمه اسکرول به پایین */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 70px;
    right: 20px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #2b5278;
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
    transition: opacity 0.3s, transform 0.3s;
    opacity: 0;
    transform: scale(0.8);
}

.scroll-to-bottom-btn.visible {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.scroll-to-bottom-btn:hover {
    background: #3a6a9a;
    transform: scale(1.1);
}

.scroll-to-bottom-btn:active {
    transform: scale(0.95);
}

/* بج تعداد پیام‌های جدید روی دکمه */
.new-msg-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* اطمینان از position: relative روی والد */
.chat-container {
    position: relative;
}
