body {
    font-family: Tahoma, Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* فرم لاگین */
.auth-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 380px;
    text-align: center;
    backdrop-filter: blur(10px);
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-container h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 28px;
}

.auth-container input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    box-sizing: border-box;
}

.auth-container input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.buttons button {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
}

.buttons button:first-child {
    background: #667eea;
    color: white;
}

.buttons button:first-child:hover {
    background: #5a67d8;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.buttons button:last-child {
    background: #48bb78;
    color: white;
}

.buttons button:last-child:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.4);
}

.guide {
    font-size: 13px;
    color: #666;
    background: #f7fafc;
    padding: 10px;
    border-radius: 8px;
    margin: 15px 0;
}

/* محیط چت */
.chat-wrapper {
    width: 100%;
    max-width: 1100px;
    height: 700px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-width: 0; /* اضافه شده برای جلوگیری از بیرون زدگی */
}

.header span {
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 100%; /* اضافه شده برای متن طولانی در هدر */
}

.header b {
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    max-width: 100%; /* اضافه شده برای متن طولانی در هدر */
}

.logout-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(255,255,255,0.5);
    padding: 8px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.chat-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0; 
}

/* لیست کاربران ادمین */
.users-sidebar {
    width: 280px;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0; 
}

.users-sidebar h3 {
    padding: 20px 20px 10px;
    margin: 0;
    color: #2d3748;
    font-size: 18px;
    flex-shrink: 0;
}

.search-box {
    padding: 10px 20px;
    flex-shrink: 0;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.3s;
    box-sizing: border-box;
}

.search-box input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.users-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0; 
}

.user-item {
    padding: 10px 20px;
    margin: 5px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: #4a5568;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0; /* اضافه شده برای باگ دسکتاپ */
}

.user-item:hover {
    background: #edf2f7;
    transform: translateX(-5px);
}

.user-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.user-item.active .delete-user-btn {
    color: white;
    opacity: 0.9;
}

.user-item.active .delete-user-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

.username {
    flex: 1;
    padding: 5px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* اضافه شده */
}

.delete-user-btn {
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 50%;
    transition: all 0.3s;
    color: #e53e3e;
    opacity: 0.7;
    line-height: 1;
    flex-shrink: 0;
}

.delete-user-btn:hover {
    opacity: 1;
    background: rgba(229, 62, 62, 0.1);
    transform: scale(1.1);
}

/* صفحه اصلی چت */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f7fafc;
    min-height: 0; 
    min-width: 0; /* اضافه شده برای رفع باگ بیرون زدگی پیام در دسکتاپ */
    overflow-x: hidden; /* اضافه شده */
}

.chat-box {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f7fafc;
    min-height: 0; 
}

.message {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 18px;
    margin-bottom: 5px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.3s ease;
    
    /* سه خط زیر برای جلوگیری از بیرون زدگی رشته های طولانی مثل لینک در دسکتاپ اضافه شد */
    overflow-wrap: anywhere; 
    word-break: break-word;
    min-width: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-me {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

.msg-other {
    background: white;
    color: #2d3748;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.msg-time {
    font-size: 11px;
    opacity: 0.7;
    display: block;
    margin-top: 5px;
    text-align: left;
}

.file-link {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 15px;
    color: inherit;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0; /* اضافه شده */
}

.file-link:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

/* فرم ارسال */
#chat-form {
    padding: 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0; 
}

.input-area {
    display: flex;
    gap: 15px;
    align-items: center;
    background: #f8fafc;
    padding: 10px 15px;
    border-radius: 30px;
    border: 1px solid #e2e8f0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

#chat-form input[type="text"] {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    padding: 5px;
    min-width: 0; 
    color: #2d3748;
}

#chat-form input[type="text"]:focus {
    outline: none;
}

.file-upload-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
}

.file-upload-wrapper input[type="file"] {
    font-size: 100px;
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
}

.file-btn {
    background: #edf2f7;
    color: #4a5568;
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    transition: all 0.3s;
}

.file-btn:hover {
    background: #e2e8f0;
    color: #2d3748;
    transform: rotate(10deg);
}

#chat-form button[type="submit"] {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

#chat-form button[type="submit"]:hover {
    background: #5a67d8;
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(102, 126, 234, 0.4);
}

.file-name {
    font-size: 12px;
    color: #718096;
    margin-top: 5px;
    text-align: right;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}


/* ریسپانسیو - مدیا کوئری ها (بدون تغییر باقی ماندند تا طراحی موبایل حفظ شود) */

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .chat-wrapper {
        height: 95vh;
        border-radius: 15px;
    }
    
    .chat-container {
        flex-direction: column;
    }
    
    .users-sidebar {
        width: 100%;
        border-left: none;
        border-bottom: 1px solid #e2e8f0;
        max-height: 30vh;
        min-height: 120px;
    }
    
    .users-sidebar h3 {
        padding: 15px 15px 5px;
        font-size: 16px;
    }
    
    .search-box {
        padding: 5px 15px;
    }
    
    .users-sidebar ul {
        display: flex;
        flex-wrap: wrap;
        padding: 10px;
        gap: 5px;
        align-content: flex-start;
    }
    
    .user-item {
        margin: 0;
        min-width: calc(50% - 20px);
        flex: 1 1 auto;
        padding: 8px 12px;
        font-size: 14px;
        border-radius: 20px;
        border: 1px solid #e2e8f0;
        background: white;
    }
    
    .chat-main {
        height: calc(65vh - 120px);
        max-height: calc(65vh - 120px);
        flex: 1;
        display: flex;
        flex-direction: column;
    }
    
    .chat-box {
        flex: 1;
        padding: 15px;
        overflow-y: auto;
    }
    
    .message {
        max-width: 90%;
        padding: 10px 15px;
        font-size: 14px;
        word-break: break-word;
    }
    
    .file-link {
        max-width: 200px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #chat-form {
        padding: 15px;
        background: white;
        z-index: 10;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }
    
    .input-area {
        gap: 10px;
        padding: 8px 12px;
        flex-wrap: wrap;
    }
    
    #chat-form input[type="text"] {
        font-size: 14px;
        width: 100%;
    }
    
    .file-btn, #chat-form button[type="submit"] {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 12px 15px;
    }
    
    .header span {
        font-size: 14px;
    }
    
    .header b {
        font-size: 16px;
    }
    
    .users-sidebar ul {
        flex-direction: column;
        flex-wrap: nowrap;
    }
    
    .user-item {
        min-width: 100%;
        border-radius: 10px;
    }
    
    .chat-main {
        height: calc(70vh - 110px);
        max-height: calc(70vh - 110px);
    }
    
    .message {
        max-width: 95%;
        padding: 10px 14px;
    }
    
    .file-link {
        max-width: 150px;
        font-size: 12px;
    }
}

@media (max-width: 360px) {
    .user-item {
        padding: 8px;
        font-size: 13px;
    }
    
    .message {
        font-size: 13px;
    }
    
    .file-link {
        max-width: 120px;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .chat-wrapper {
        height: 90vh;
    }
    
    .users-sidebar {
        max-height: 35vh;
    }
    
    .users-sidebar ul {
        max-height: calc(35vh - 100px);
    }
    
    .chat-main {
        height: calc(55vh - 120px);
    }
    
    .message {
        max-width: 80%;
    }
}
/* اضافه کردن به انتهای فایل style.css */

.receiver-section {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f0f4f8;
    border-radius: 12px;
}

#receiver {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    box-sizing: border-box;
}

#receiver:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.start-chat-btn {
    padding: 12px 20px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
    white-space: nowrap;
}

.start-chat-btn:hover {
    background: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

/* برای موبایل */
@media (max-width: 768px) {
    .receiver-section {
        flex-direction: column;
    }
    
    .start-chat-btn {
        width: 100%;
    }
}
/* اضافه کردن به انتهای فایل style.css */

/* بخش نوتیفیکیشن - اصلاح شده */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    pointer-events: none;
}

.notification {
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInRight 0.3s ease;
    border-right: 4px solid #667eea;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.notification:hover {
    transform: translateX(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
}

.notification::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    animation: progress 5s linear forwards;
}

@keyframes progress {
    from { width: 100%; }
    to { width: 0%; }
}

.notification.success {
    border-right-color: #48bb78;
}

.notification.error {
    border-right-color: #f56565;
}

.notification.warning {
    border-right-color: #ed8936;
}

.notification-icon {
    font-size: 24px;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
    border-radius: 50%;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: bold;
    margin-bottom: 5px;
    color: #2d3748;
    font-size: 14px;
}

.notification-message {
    color: #718096;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #a0aec0;
    padding: 5px;
    transition: color 0.3s;
    z-index: 2;
}

.notification-close:hover {
    color: #4a5568;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}



@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* استایل مخاطبین برای کاربر عادی */
#user-sidebar {
    width: 280px;
    background: #f8fafc;
    border-left: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#contacts-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.contact-item {
    padding: 12px 20px;
    margin: 5px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: #4a5568;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    position: relative;
}

.contact-item:hover {
    background: #edf2f7;
    transform: translateX(-5px);
}

.contact-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.contact-info {
    flex: 1;
    overflow: hidden;
}

.contact-name {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-last-message {
    font-size: 12px;
    color: #a0aec0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.contact-item.active .contact-last-message {
    color: rgba(255,255,255,0.8);
}

.unread-badge {
    background: #f56565;
    color: white;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    margin-left: 10px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.contact-item.active .unread-badge {
    background: white;
    color: #f56565;
}

.add-contact-section {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
}

#new-contact {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
}

#new-contact:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.add-contact-btn {
    width: 40px;
    height: 40px;
    background: #48bb78;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.add-contact-btn:hover {
    background: #38a169;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(72, 187, 120, 0.3);
}

/* استایل هدر چت */
.chat-header {
    padding: 15px 25px;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#chat-with-label {
    font-size: 16px;
    color: #4a5568;
}

#chat-with-name {
    color: #667eea;
    font-size: 18px;
}

.online-status {
    font-size: 14px;
    color: #48bb78;
    display: flex;
    align-items: center;
    gap: 5px;
}

.online-status::before {
    content: '';
    width: 10px;
    height: 10px;
    background: #48bb78;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f7fafc;
    color: #a0aec0;
}

.welcome-content {
    text-align: center;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 20px;
    display: block;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* رسپانسیو برای موبایل */
@media (max-width: 768px) {
    .notification-container {
        top: 10px;
        left: 10px;
        right: 10px;
    }
    
    .notification {
        min-width: auto;
        max-width: none;
        width: 100%;
    }
    
    #user-sidebar {
        width: 100%;
        max-height: 30vh;
    }
    
    .chat-header {
        padding: 10px 15px;
    }
    
    #chat-with-name {
        font-size: 16px;
    }
    
    .online-status {
        font-size: 12px;
    }
}
/* اضافه کردن به انتهای فایل style.css */

/* نوتیفیکیشن ماندگار */
.notification.persistent {
    border-right: 4px solid #f56565;
    animation: none;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #fff 0%, #fef5f5 100%);
}

.notification.persistent:hover {
    transform: translateX(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
}

.notification.persistent::after {
    display: none; /* حذف نوار پیشرفت */
}

.notification.persistent .notification-icon {
    background: #f56565;
    color: white;
}

.notification-time {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 5px;
}

/* نوتیفیکیشن موقت (toast) */
.notification.toast {
    border-right-color: #48bb78;
    background: linear-gradient(135deg, #fff 0%, #f0fff4 100%);
    animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.notification.toast .notification-icon {
    background: #48bb78;
    color: white;
}

.notification.toast::after {
    background: linear-gradient(90deg, #48bb78, #2f855a);
}

/* کانتینر نوتیفیکیشن */
.notification-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
    pointer-events: none;
}

.notification {
    pointer-events: auto;
}

/* رسپانسیو */
@media (max-width: 768px) {
    .notification-container {
        top: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }
    
    .notification {
        width: 100%;
    }
}