:root {
    --primary-color: #3A86FF;
    --secondary-color: #8338EC;
    --success-color: #06D6A0;
    --danger-color: #EF476F;
    --warning-color: #FFD166;
    --dark-color: #1A1A2E;
    --light-color: #F8F9FA;
    --gray-color: #6C757D;
    --sidebar-bg: #16213E;
    --chat-bg: #0F3460;
    --message-bg: #1E3163;
    --border-radius: 12px;
    --box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
}

body {
    background: linear-gradient(135deg, #0F3460 0%, #16213E 100%);
    color: var(--light-color);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* مدال ورود */
.modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--dark-color);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlide 0.5s ease;
}

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

.modal-header {
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.modal-header h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.modal-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.modal-body {
    padding: 30px;
}

.avatar-selector {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
    justify-content: center;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: white;
    border: 4px solid var(--primary-color);
    box-shadow: var(--box-shadow);
}

#avatar-color {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid white;
    cursor: pointer;
    padding: 0;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #adb5bd;
}

.form-group input {
    width: 100%;
    padding: 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    color: white;
    font-size: 1rem;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.3);
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--gray-color);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(58, 134, 255, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-icon {
    background: transparent;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-footer {
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
}

.stat-item i {
    color: var(--primary-color);
    font-size: 1.3rem;
}

/* رابط اصلی چت */
#chat-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

#chat-container.hidden {
    display: none;
}

/* سایدبار */
.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
    padding: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 1.2rem;
}

.user-status {
    font-size: 0.85rem;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-block;
}

.user-status.online {
    background: rgba(6, 214, 160, 0.2);
    color: var(--success-color);
}

.user-status.offline {
    background: rgba(239, 71, 111, 0.2);
    color: var(--danger-color);
}

.sidebar-section {
    padding: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h4 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

.badge {
    background: var(--primary-color);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.room-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.room-item {
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.room-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.room-item.active {
    background: var(--primary-color);
    box-shadow: 0 5px 15px rgba(58, 134, 255, 0.3);
}

.room-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-users {
    font-size: 0.85rem;
    color: #adb5bd;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.9rem;
}

.user-item-name {
    flex: 1;
}

.user-item-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.user-item-status.online {
    background: var(--success-color);
    box-shadow: 0 0 10px var(--success-color);
}

.sidebar-footer {
    margin-top: auto;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-box i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    display: block;
}

.stat-label {
    font-size: 0.85rem;
    color: #adb5bd;
}

/* بخش اصلی چت */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
}

.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.2);
}

.room-info h2 {
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.room-description {
    color: #adb5bd;
    font-size: 0.95rem;
}

.room-actions {
    display: flex;
    gap: 10px;
}

.messages-container {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 70%;
    display: flex;
    gap: 15px;
    animation: messageAppear 0.3s ease;
}

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

.message.self {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.message-content {
    background: var(--message-bg);
    padding: 15px;
    border-radius: var(--border-radius);
    position: relative;
}

.message.self .message-content {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.message-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.message-username {
    font-weight: 600;
    font-size: 0.95rem;
}

.message-time {
    font-size: 0.8rem;
    color: #adb5bd;
}

.message.self .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-text {
    line-height: 1.5;
    word-break: break-word;
}

.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #adb5bd;
}

.welcome-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-message h3 {
    margin-bottom: 10px;
    color: white;
}

.message-input-container {
    padding: 20px 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.2);
}

.typing-indicator {
    min-height: 25px;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-indicator i {
    animation: typingPulse 1.5s infinite;
}

@keyframes typingPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#message-input {
    flex: 1;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--border-radius);
    color: white;
    font-size: 1rem;
    transition: var(--transition);
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(58, 134, 255, 0.3);
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.char-count {
    font-size: 0.85rem;
    color: #adb5bd;
}

.quick-actions {
    display: flex;
    gap: 8px;
}

.quick-btn {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.quick-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* اعلان‌ها */
#notification-container {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: var(--dark-color);
    border-radius: var(--border-radius);
    padding: 15px 20px;
    box-shadow: var(--box-shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 350px;
    animation: notificationSlide 0.3s ease;
    border-right: 4px solid var(--primary-color);
}

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

.notification i {
    font-size: 1.2rem;
}

.notification.info i {
    color: var(--primary-color);
}

.notification.success i {
    color: var(--success-color);
}

.notification.warning i {
    color: var(--warning-color);
}

.notification.error i {
    color: var(--danger-color);
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 3px;
}

.notification-message {
    font-size: 0.9rem;
    color: #adb5bd;
}

/* ریسپانسیو */
@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        order: 2;
    }
    
    .main-chat {
        order: 1;
    }
    
    .room-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .stats {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-header {
        padding: 20px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .message {
        max-width: 95%;
    }
}