/* General Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Tahoma', 'Arial', sans-serif; /* فونت فارسی */
}

body {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a, #1e293b); /* گرادیانت تیره */
    color: #e5e7eb; /* رنگ متن روشن */
    line-height: 1.8;
}

/* Authentication Page Styles */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(17, 24, 39, 0.92); /* پس‌زمینه نیمه‌شفاف */
    border: 1px solid rgba(255,255,255,0.08); /* حاشیه ظریف */
    border-radius: 24px; /* گوشه‌های گرد */
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35); /* سایه عمیق */
    backdrop-filter: blur(12px); /* افکت بلور */
}

.auth-header h1 {
    font-size: 28px;
    margin-bottom: 10px;
    text-align: center;
    color: #fff;
}

.auth-header p {
    color: #cbd5e1; /* رنگ خاکستری روشن */
    font-size: 14px;
    margin-bottom: 22px;
    line-height: 1.8;
    text-align: center;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.tab-btn {
    flex: 1;
    border: none;
    padding: 12px;
    border-radius: 14px;
    background: #1f2937; /* خاکستری تیره */
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.tab-btn.active {
    background: #2563eb; /* آبی اصلی */
}

.auth-form {
    display: none; /* مخفی پیش‌فرض */
    flex-direction: column;
    gap: 12px;
}

.auth-form.active {
    display: flex; /* نمایش وقتی فعال است */
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #334155; /* آبی تیره */
    border-radius: 14px;
    background: #0f172a; /* آبی خیلی تیره */
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: #2563eb; /* آبی اصلی */
}

.auth-form button[type="submit"] {
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: #2563eb; /* آبی اصلی */
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button[type="submit"]:hover {
    background: #1d4ed8; /* آبی تیره‌تر */
}

/* App Layout Styles */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background: #111827; /* سرمه‌ای تیره */
    border-left: 1px solid #1f2937; /* خط جداکننده */
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px;
    font-weight: bold;
    font-size: 18px;
    border-bottom: 1px solid #1f2937;
    background: #182231; /* کمی روشن‌تر برای هدر */
}

.channels {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.channel-item {
    background: #1f2937; /* خاکستری تیره */
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap; /* جلوگیری از شکستن نام چت */
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-item:hover,
.channel-item.active {
    background: #2563eb; /* آبی اصلی */
    color: #fff;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* برای جلوگیری از بیرون زدن در سایزهای کوچک */
}

.chat-header {
    padding: 16px;
    background: #111827; /* سرمه‌ای تیره */
    border-bottom: 1px solid #1f2937;
    font-weight: bold;
    font-size: 18px;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px; /* فاصله بین پیام‌ها */
}

.message {
    max-width: 75%;
    padding: 12px 14px;
    border-radius: 16px;
    line-height: 1.8;
    white-space: pre-wrap; /* حفظ فاصله‌ها و خطوط */
    word-wrap: break-word; /* شکستن کلمات طولانی */
    position: relative;
    padding-bottom: 25px; /* فضای کافی برای timestamp */
}

.message.me {
    align-self: flex-start; /* پیام‌های من در سمت چپ */
    background: #2563eb; /* آبی */
    color: #fff;
    border-bottom-left-radius: 0; /* شکل خاص برای گوشه */
}

.message.other {
    align-self: flex-end; /* پیام‌های دیگران در سمت راست */
    background: #1f2937; /* خاکستری تیره */
    color: #e5e7eb;
    border-bottom-right-radius: 0; /* شکل خاص برای گوشه */
}

.message .timestamp {
    position: absolute;
    bottom: 5px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0; /* مخفی پیش‌فرض */
    transition: opacity 0.2s;
}

.message.me .timestamp {
    left: 10px;
}

.message.other .timestamp {
    right: 10px;
}

.message:hover .timestamp, .message.active .timestamp {
    opacity: 1; /* نمایش در هاور یا وقتی فعال است */
}


.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: #111827; /* سرمه‌ای تیره */
    border-top: 1px solid #1f2937;
    align-items: flex-end; /* هم‌ترازی در پایین */
}

#message {
    flex: 1;
    min-height: 50px;
    max-height: 140px;
    resize: vertical; /* اجازه تغییر اندازه عمودی */
    border-radius: 14px;
    border: 1px solid #334155;
    background: #0f172a; /* آبی خیلی تیره */
    color: #fff;
    padding: 12px;
    outline: none;
    font-size: 14px;
}

#message::placeholder {
    color: #64748b; /* رنگ متن راهنما */
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center; /* هم‌ترازی عمودی دکمه‌ها */
}

.actions button, #attach-btn {
    border: none;
    border-radius: 14px;
    background: #2563eb; /* آبی اصلی */
    color: white;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.actions button:hover, #attach-btn:hover {
    background: #1d4ed8; /* آبی تیره‌تر */
}

#file-input {
    display: none; /* مخفی کردن input اصلی فایل */
}

/* Responsive Styles */
@media (max-width: 768px) {
    .auth-card {
        padding: 22px;
        border-radius: 20px;
    }

    .auth-header h1 {
        font-size: 24px;
    }

    .auth-header p {
        font-size: 13px;
    }

    .app {
        flex-direction: column; /* چیدمان ستونی در موبایل */
    }

    .sidebar {
        width: 100%;
        height: 180px; /* ارتفاع ثابت برای سایدبار در موبایل */
        border-left: none;
        border-bottom: 1px solid #1f2937;
    }

    .sidebar-header {
        font-size: 16px;
        padding: 12px;
    }

    .channels {
        display: flex; /* نمایش افقی چت‌ها در موبایل */
        overflow-x: auto; /* اسکرول افقی */
        white-space: nowrap;
        padding: 10px 10px 10px 10px;
    }

    .channel-item {
        min-width: 120px; /* حداقل عرض برای هر چت */
        margin-bottom: 0;
        margin-right: 8px; /* فاصله بین چت‌ها */
    }
    .channel-item:last-child {
        margin-right: 0;
    }

    .chat-area {
        height: calc(100vh - 180px); /* ارتفاع باقی‌مانده */
    }

    .chat-header {
        font-size: 16px;
        padding: 12px;
    }

    .messages {
        padding: 12px;
        gap: 8px;
    }

    .message {
        max-width: 90%;
        padding: 10px 12px;
        border-radius: 12px;
    }

    .message.me, .message.other {
        border-bottom-left-radius: 12px;
        border-bottom-right-radius: 12px;
    }

    .chat-input-area {
        flex-direction: column; /* چیدمان ستونی در موبایل */
        align-items: stretch; /* عرض کامل */
        padding: 10px;
    }

    #message {
        min-height: 40px;
        max-height: 100px;
        padding: 10px;
    }

    .actions {
        flex-direction: row; /* دکمه‌ها کنار هم */
        justify-content: space-between; /* فاصله بین دکمه‌ها */
    }

    .actions button, #attach-btn {
        flex: 1; /* گرفتن فضای برابر */
        padding: 10px;
        font-size: 14px;
    }
}
