/* ================== تنظیمات عمومی ================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to right, #6a11cb, #2575fc);
    color: #fff;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* تیتر اصلی */
h2 {
    margin: 20px 0;
    font-size: 2em;
}

/* ================== فرم ثبت نام و ورود ================== */
#auth {
    background: rgba(0,0,0,0.5);
    padding: 20px 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    width: 350px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
}

#auth input {
    width: 100%;
    margin: 8px 0;
    padding: 10px;
    border-radius: 10px;
    border: none;
    outline: none;
}

#auth button {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    border: none;
    border-radius: 12px;
    background-color: #ff4b2b;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

#auth button:hover { background-color: #ff416c; }

/* ================== چت ================== */
#chat {
    width: 80%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#logoutBtn {
    align-self: flex-end;
    background-color: #ff4b2b;
    border: none;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

#logoutBtn:hover { background-color: #ff416c; }

/* پیام‌ها */
#messages {
    width: 100%;
    height: 400px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    overflow-y: auto;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    margin-bottom: 15px;
}

/* پیام‌های فردی */
.message {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 12px;
    max-width: 80%;
}

.message img.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
}

/* پیام خودی */
.message.self {
    display: block;          /* هر پیام یک خط */
    max-width: 90%;
    margin-left: auto;       /* راست چین */
    margin-right: 0;
    padding: 10px 15px;
    background: rgba(255,255,255,0.9);
    color: black;
    text-align: right;
    word-wrap: break-word;
    white-space: normal;
    border-radius: 12px;
}

/* پیام دیگران */
.message:not(.self) {
    display: block;          /* هر پیام یک خط */
    max-width: 90%;
    margin-left: 0;
    margin-right: auto;      /* چپ چین */
    padding: 10px 15px;
    background: rgba(0,0,0,0.35);
    color: white;
    text-align: left;
    word-wrap: break-word;
    white-space: normal;
    border-radius: 12px;
}

/* اگر داخل پیام آواتار هم هست */
.message .avatar {
    display: inline-block;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
}

/* ورودی پیام */
#messageInput {
    width: 65%;
    padding: 10px;
    border-radius: 10px;
    border: none;
    outline: none;
    margin-right: 10px;
}

#fileInput { margin-right: 10px; }

/* دکمه ارسال */
#sendBtn {
    padding: 10px 15px;
    border: none;
    border-radius: 12px;
    background-color: #ff4b2b;
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

#messageInput {
    width: 100%;
    min-height: 30px;
    max-height: 150px;
    padding: 10px 15px;
    border-radius: 30px;
    border: none;
    font-size: 1.5em;
    margin-right: 10px;
    overflow-y: auto;
    resize: none;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#sendBtn:hover { background-color: #ff416c; }

/* لینک فایل */
.message a { color: #ffd700; margin-left: 5px; text-decoration: none; }
.message a:hover { text-decoration: underline; }

/* اسکرول بار */
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-track { background: rgba(255,255,255,0.1); border-radius:10px; }
#messages::-webkit-scrollbar-thumb { background: #ff4b2b; border-radius:10px; }
#messages::-webkit-scrollbar-thumb:hover { background: #ff416c; }

/* ================== استایل فایل انتخابی ================== */
input[type="file"] {
    display: inline-block;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 12px;
    background-color: #ff4b2b;
    color: white;
    font-weight: bold;
    transition: 0.3s;
    border: none;
    outline: none;
}

input[type="file"]:hover { background-color: #ff416c; }

input[type="file"]::-webkit-file-upload-button { visibility: hidden; }

input[type="file"]::before {
    content: 'انتخاب فایل';
    display: inline-block;
    background: #ff4b2b;
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
    white-space: nowrap;
    -webkit-user-select: none;
    cursor: pointer;
    color: white;
    font-weight: bold;
    transition: 0.3s;
}

input[type="file"]:hover::before { background-color: #ff416c; }

input[type="file"]::file-selector-button {
    background: #ff4b2b;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 12px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

input[type="file"]::file-selector-button:hover { background-color: #ff416c; }

/* ================== دکمه بازگشت ================== */
a.back {
    display: inline-block;
    padding: 10px 18px;
    background-color: #ff4b2b;
    color: white;
    text-decoration: none;
    font-weight: bold;
    border-radius: 12px;
    transition: 0.3s;
    margin: 10px 0;
}

a.back:hover { background-color: #ff416c; transform: translateY(-2px); }

/* ================== واکنش‌گرا موبایل ================== */
@media (max-width: 480px) {
    body { padding: 10px; }
    #auth { width: 90%; padding: 15px 20px; }
    #chat { width: 95%; }
    #messages { height: 300px; padding: 10px; }
    #messageInput { width: 55%; margin-right: 5px; padding: 8px; }
    #fileInput { margin-right: 5px; padding: 6px 8px; }
    #sendBtn { padding: 8px 12px; font-size: 0.9em; }
    a.back { padding: 8px 12px; font-size: 0.9em; }
    .message img.avatar { width: 30px; height: 30px; margin-right: 6px; }
    .message { padding: 6px 8px; font-size: 0.9em; max-width: 100%; }
}
/* استایل دکمه انتخاب استایل */
#styleSelector {
    width: 200px;       /* عرض */
    height: 60px;       /* ارتفاع */
    border-radius: 12px;
    border: none;
    background-color: #fd9090;
    color: rgb(0, 0, 0);
    font-weight: bold;
    font-size: 2em;
    cursor: pointer;
    transition: 0.3s;
    outline: none;
}

#styleSelector:hover,
#styleSelector:focus {
    background-color: #ff0000;
}

#changeAvatarBtn {
    padding: 10px 20px;
    border-radius: 12px;
    border: none;
    background-color: #ff4b2b;
    color: rgb(0, 0, 0);
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

#changeAvatarBtn:hover {
    background-color: #ff416c;
}

 /* تازه سازی صفحه */
.refresh-btn {
    margin: 10px;
    padding: 8px 16px;
    border-radius: 8px;
    background-color: #4CAF50; /* سبز */
    color: rgb(0, 0, 0);
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.refresh-btn:hover {
    background-color: #45a049; /* سبز تیره هنگام هاور */
}

/*نمایش و اندازه عکس پروفایل*/
#currentAvatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    cursor: pointer; /* وقتی موس روش میره، حالت کلیک بده */
    transition: all 0.3s ease;
}

/* کلاس برای بزرگ شدن */
#currentAvatar.large {
    width: 200px;
    height: 200px;
    transition: all 0.3s ease;
}