/* style.css - تم روشن و جذاب برای چت موبایل */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: irs;
    background: #f8f9fa;
    color: #2c3e50;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* جلوگیری از زوم در موبایل */
textarea, input {
    font-size: 16px !important;
    max-height: 120px;
}

/* کانتینر اصلی */
.chat-container {
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 50%, #dee2e6 100%);
    position: relative;
}

/* هدر چت */
.chat-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    flex-shrink: 0;
    min-height: 70px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
}

/* اطلاعات کاربر */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 20px;
    color: white;
    background: linear-gradient(135deg, #6a89cc 0%, #4a69bd 100%);
    box-shadow: 0 4px 15px rgba(106, 137, 204, 0.2);
}

.user-details h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #2d3436;
}

.user-details p {
    font-size: 13px;
    color: #636e72;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #00b894;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 8px rgba(0, 184, 148, 0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.95); }
}

/* اطلاعات آنلاین */
.online-info {
    background: rgba(116, 185, 255, 0.1);
    padding: 10px 18px;
    border-radius: 25px;
    font-size: 14px;
    color: #2d3436;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(116, 185, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: #74b9ff;
    color: white;
}

/* کانتینر پیام‌ها */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 15px 100px 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

/* پیام */
.message {
    max-width: 85%;
    animation: fadeInUp 0.3s ease-out;
    position: relative;
    transition: transform 0.2s;
}

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

/* پیام خود کاربر - سمت راست */
.message.my-message {
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
}

/* پیام دیگران - سمت چپ */
.message.other-message {
    align-self: flex-start;
    margin-right: auto;
    margin-left: 0;
}

/* باکس پیام */
.message-box {
    padding: 16px 18px;
    border-radius: 22px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.5;
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.08);
    min-width: 65px;
    max-width: 100%;
}

/* پیام خود کاربر */
.my-message .message-box {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
    border-bottom-right-radius: 8px;
    border-top-right-radius: 5px;
}

/* پیام دیگران */
.other-message .message-box {
    background: linear-gradient(135deg, #ffffff 0%, #f5f6fa 100%);
    color: #2d3436;
    border-bottom-left-radius: 8px;
    border-top-left-radius: 5px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* نام فرستنده (فقط برای دیگران) */
.message-sender {
    font-size: 14px;
    font-weight: 700;
    color: #636e72;
    text-align: right;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-sender::before {
    font-size: 12px;
}

/* متن پیام */
.message-text {
    font-size: 16px;
    margin-bottom: 12px;
    line-height: 1.5;
    word-break: break-word;
    text-align: right;
}

/* زمان پیام */
.message-time {
    font-size: 12px;
    opacity: 0.7;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    color: rgba(45, 52, 54, 0.7);
    direction: ltr;
}

.message-time::before {
    font-size: 11px;
}

.my-message .message-time {
    justify-content: flex-start;
    flex-direction: row-reverse;
    color: rgba(255, 255, 255, 0.8);
}

/* وضعیت تایپ */
.typing-indicator {
    padding: 12px 20px;
    color: #636e72;
    font-size: 14px;
    font-style: italic;
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    margin: 0 20px 10px 20px;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.typing-indicator.active {
    display: block;
    animation: fadeIn 0.3s;
}

/* ناحیه ورودی پیام */
.input-area {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    gap: 12px;
    align-items: flex-end;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    backdrop-filter: blur(20px);
    min-height: 80px;
    box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.05);
}

#messageInput {
    flex: 1;
    min-height: 50px;
    max-height: 150px;
    padding: 14px 18px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    color: #2d3436;
    font-size: 16px;
    resize: none;
    line-height: 1.4;
    font-family: inherit;
    transition: all 0.3s;
}

#messageInput:focus {
    outline: none;
    border-color: #74b9ff;
    background: white;
    box-shadow: 0 0 0 3px rgba(116, 185, 255, 0.2);
}

#messageInput::placeholder {
    color: #adb5bd;
}

/* دکمه ارسال */
#sendButton {
    width: 55px;
    height: 55px;
    min-width: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: all 0.3s;
    box-shadow: 0 5px 20px rgba(116, 185, 255, 0.3);
}

#sendButton:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(116, 185, 255, 0.4);
}

#sendButton:active {
    transform: scale(0.95);
}

/* اسکرولبار */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #a4b0be;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #747d8c;
}

/* تاریخ جداکننده */
.date-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.date-separator::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.08), transparent);
}

.date-label {
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 20px;
    border-radius: 20px;
    color: #636e72;
    font-size: 13px;
    position: relative;
    z-index: 1;
    display: inline-block;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

/* استایل موبایل - بهینه‌سازی */
@media (max-width: 768px) {
    .chat-header {
        padding: 12px 15px;
        min-height: 60px;
    }
    
    .avatar {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .user-details h3 {
        font-size: 16px;
    }
    
    .user-details p {
        font-size: 12px;
    }
    
    .online-info {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    .messages-container {
        padding: 15px 12px 90px 12px;
        gap: 15px;
    }
    
    .message-box {
        padding: 14px 16px;
        border-radius: 20px;
    }
    
    .message-text {
        font-size: 15px;
    }
    
    .input-area {
        padding: 12px 15px;
        min-height: 70px;
    }
    
    #messageInput {
        min-height: 45px;
        padding: 12px 16px;
        font-size: 15px;
    }
    
    #sendButton {
        width: 50px;
        height: 50px;
        min-width: 50px;
        font-size: 20px;
    }
    
    .message {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .message {
        max-width: 95%;
    }
    
    .message-box {
        padding: 12px 14px;
    }
    
    .message-text {
        font-size: 14px;
    }
    
    .message-sender {
        font-size: 13px;
    }
    
    .message-time {
        font-size: 11px;
    }
}

/* انیمیشن برای پیام جدید */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.my-message {
    animation: slideInRight 0.3s ease-out;
}

.other-message {
    animation: slideInLeft 0.3s ease-out;
}

/* وضعیت خوانده شدن */
.read-status {
    font-size: 10px;
    margin-right: 5px;
}

/* برای جلوگیری از کشیده شدن صفحه در iOS */
body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
}

/* حل مشکل کیبورد در iOS */
@supports (-webkit-touch-callout: none) {
    .chat-container {
        height: -webkit-fill-available;
    }
}

/* استایل عکس پروفایل در پیام‌ها */
.avatar-in-message {
    width: 40px;
    height: 40px;
    margin-left: 10px;
    flex-shrink: 0;
}

.avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

/* پیام دیگران */
.other-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

/* پیام خودم */
.my-message {
    display: flex;
    flex-direction: row-reverse;
    align-items: flex-start;
    gap: 10px;
}

/* استایل آواتار تصویری */
.avatar-img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* برای موبایل */
@media (max-width: 480px) {
    .avatar-in-message {
        width: 35px;
        height: 35px;
    }
    
    .avatar-img {
        width: 40px;
        height: 40px;
    }
}

/* اضافه کردن شفافیت‌های ملایم */
.my-message .message-box {
    box-shadow: 0 4px 15px rgba(116, 185, 255, 0.2);
}

.other-message .message-box {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* هایلایت برای فکوس */
:focus {
    outline: none;
}

/* بهبود نمایش خطوط */
.message-text {
    letter-spacing: 0.2px;
}

/* رنگ‌بندی ثانویه */
.online-info {
    background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
}

.status-dot {
    background: #00b894;
}

/* ظریف‌سازی حاشیه‌ها */
.chat-header, .input-area, .date-label, .typing-indicator {
    border-radius: 0;
}

@media (max-width: 768px) {
    .chat-header, .input-area {
        border-radius: 0;
    }
}

/* تنظیمات در هدر */
.settings-menu {
    position: relative;
}

.settings-btn {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s;
    color: #2d3436;
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: rotate(90deg);
}

.settings-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    width: 300px;
    z-index: 1001;
    display: none;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.settings-dropdown.show {
    display: block;
    animation: fadeInDown 0.3s;
}

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

.settings-dropdown h4 {
    margin-bottom: 15px;
    color: #2d3436;
    border-bottom: 2px solid #74b9ff;
    padding-bottom: 8px;
}

.avatar-selection {
    margin-bottom: 20px;
}

.avatar-selection p {
    margin-bottom: 10px;
    color: #636e72;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.avatar-option {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s;
    overflow: hidden;
}

.avatar-option:hover {
    transform: scale(1.1);
    border-color: #74b9ff;
}

.avatar-option.selected {
    border-color: #0984e3;
    box-shadow: 0 0 0 2px white, 0 0 0 4px #0984e3;
}

.avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.color-preview {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.user-info-display {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.user-info-display p {
    margin: 8px 0;
    color: #2d3436;
}

.logout-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.logout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(214, 48, 49, 0.3);
}

/* رنگ پیام‌ها بر اساس کاربر */
.message[data-user-color] .message-box {
    border-left: 4px solid var(--user-color);
}

.other-message .message-sender {
    color: var(--user-color);
    font-weight: bold;
}

/* نوتیفیکیشن‌های سفارشی */
.custom-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    animation: slideInRight 0.3s ease-out;
    max-width: 350px;
}

.notification-content {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    border-left: 5px solid #74b9ff;
}

.custom-notification.success .notification-content {
    border-left-color: #00b894;
}

.custom-notification.error .notification-content {
    border-left-color: #d63031;
}

.custom-notification.info .notification-content {
    border-left-color: #74b9ff;
}

.notification-content span {
    flex: 1;
    color: #2d3436;
    font-size: 14px;
}

.notification-content button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #636e72;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.notification-content button:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #2d3436;
}

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