/* ریست و تنظیمات پایه */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
}

/* صفحات */
.page {
    display: none;
}

.page.active {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* کانتینر احراز هویت */
.auth-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-container h1 {
    text-align: center;
    color: #667eea;
    margin-bottom: 30px;
    font-size: 2em;
}

/* تب‌های احراز هویت */
.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: #f0f0f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s;
    font-weight: 600;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tab-btn:hover:not(.active) {
    background: #e0e0e0;
}

/* فرم‌های احراز هویت */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form input {
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
}

.auth-form input:focus {
    outline: none;
    border-color: #667eea;
}

.auth-form button {
    padding: 15px;
    border: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.auth-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* پیام خطا */
.error-message {
    color: #e74c3c;
    text-align: center;
    margin-top: 15px;
    font-weight: 500;
}

/* کانتینر چت */
.chat-container {
    display: flex;
    width: 100%;
    max-width: 1400px;
    height: 90vh;
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* سایدبار */
.sidebar {
    width: 320px;
    background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 20px;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-header h2 {
    margin-bottom: 15px;
    font-size: 1.5em;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 15px;
    border-radius: 10px;
}

.user-info span {
    font-weight: 600;
}

#logout-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.2em;
}

#logout-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* تب‌های سایدبار */
.sidebar-tabs {
    display: flex;
    padding: 10px;
    gap: 5px;
}

.sidebar-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.sidebar-tab.active {
    background: white;
    color: #667eea;
}

/* لیست‌ها */
.list-container {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.list-container.active {
    display: flex;
}

.list-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.list-header h3 {
    color: white;
    font-size: 1.1em;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.2em;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.list-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.list-item {
    display: flex;
    align-items: center;
    padding: 15px;
    margin-bottom: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.list-item.active {
    background: white;
    color: #667eea;
}

.item-icon {
    font-size: 1.5em;
    margin-left: 15px;
}

.item-name {
    flex: 1;
    font-weight: 600;
    color: white;
}

.list-item.active .item-name {
    color: #667eea;
}

/* منطقه چت */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chat-header {
    padding: 20px 30px;
    background: white;
    border-bottom: 2px solid #e0e0e0;
}

.chat-header h2 {
    color: #333;
    font-size: 1.3em;
}

/* کانتینر پیام‌ها */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* پیام */
.message {
    max-width: 70%;
    background: white;
    padding: 12px 16px;
    border-radius: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    align-self: flex-start;
}

.message.own {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    gap: 15px;
}

.message-username {
    font-weight: 700;
    font-size: 0.9em;
}

.message.own .message-username {
    color: rgba(255, 255, 255, 0.9);
}

.message-time {
    font-size: 0.75em;
    color: #999;
}

.message.own .message-time {
    color: rgba(255, 255, 255, 0.7);
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

/* فایل‌های پیام */
.message-file {
    margin-top: 10px;
}

.message-image {
    max-width: 100%;
    border-radius: 10px;
    cursor: pointer;
}

.message-video {
    max-width: 100%;
    border-radius: 10px;
}

.message-audio {
    width: 100%;
}

.file-download {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
}

.message.own .file-download {
    background: rgba(255, 255, 255, 0.2);
}

.file-download:hover {
    background: rgba(0, 0, 0, 0.1);
}

.file-icon {
    font-size: 2em;
}

.file-info {
    flex: 1;
}

.file-name-text {
    font-weight: 600;
}

.file-size {
    font-size: 0.85em;
    opacity: 0.7;
}

/* پیش‌نمایش فایل */
.file-preview {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 30px;
    background: #fff3cd;
    border-top: 2px solid #ffc107;
}

.file-name {
    flex: 1;
    font-weight: 600;
    color: #856404;
}

.remove-file-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.remove-file-btn:hover {
    background: #c82333;
}

/* ورودی پیام */
.message-input-container {
    display: flex;
    gap: 10px;
    padding: 20px 30px;
    background: white;
    border-top: 2px solid #e0e0e0;
}

.file-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.2em;
    transition: all 0.3s;
}

.file-btn:hover {
    background: #5a6268;
}

#message-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1em;
    transition: all 0.3s;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

.send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* اسکرول‌بار سفارشی */
.list-content::-webkit-scrollbar,
.messages-container::-webkit-scrollbar {
    width: 8px;
}

.list-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.list-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

/* ریسپانسیو */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: 100vh;
    }

    .sidebar {
        width: 100%;
        max-height: 40vh;
    }

    .message {
        max-width: 85%;
    }
}
