* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    text-align: right;
}

/* Auth Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-box {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.auth-box h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 28px;
}

.auth-subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 16px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 30px;
    border-radius: 10px;
    overflow: hidden;
    background: #f5f5f5;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #667eea;
    color: white;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    font-weight: 600;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.auth-links {
    text-align: center;
    margin-top: 20px;
}

.auth-links p {
    margin: 10px 0;
    color: #666;
}

.auth-links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* Chat Interface */
.chat-container {
    display: flex;
    height: 100vh;
    direction: rtl;
}

.sidebar {
    width: 320px;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.sidebar-header h2 {
    color: white;
    margin-bottom: 16px;
    font-weight: 700;
    font-size: 20px;
    text-align: right;
}

.sidebar-header .btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.sidebar-header .btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #fafafa;
}

.conversation-item {
    padding: 16px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid transparent;
    background: white;
    text-align: right;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.conversation-item:hover {
    background: #f0f4ff;
    border-color: #667eea;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.conversation-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.conversation-title {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 15px;
    line-height: 1.4;
}

.conversation-date {
    font-size: 12px;
    opacity: 0.7;
    font-weight: 400;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
}

.user-info span {
    font-weight: 600;
    color: #374151;
}

.logout-btn {
    color: #dc2626;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.logout-btn:hover {
    background: #fef2f2;
    text-decoration: none;
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.chat-header {
    background: white;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.chat-header h3 {
    color: #1f2937;
    font-weight: 700;
    font-size: 18px;
    text-align: right;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}

.welcome-message {
    text-align: center;
    color: #6b7280;
    margin-top: 120px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.welcome-message h2 {
    margin-bottom: 16px;
    color: #374151;
    font-size: 28px;
    font-weight: 700;
}

.welcome-message p {
    font-size: 16px;
    line-height: 1.6;
}

.message-item {
    margin-bottom: 24px;
    display: flex;
    direction: rtl;
}

.message-item.user {
    justify-content: flex-start;
}

.message-item.assistant {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 75%;
    padding: 16px 20px;
    border-radius: 18px;
    font-weight: 400;
    line-height: 1.6;
    font-size: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.message-item.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
    text-align: right;
}

.message-item.assistant .message-bubble {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    text-align: right;
}

.chat-input-container {
    background: white;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.input-group {
    display: flex;
    gap: 12px;
    direction: rtl;
    align-items: center;
}

.input-group input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-family: 'Cairo', sans-serif;
    font-size: 15px;
    transition: all 0.3s ease;
    text-align: right;
    background: #f9fafb;
    min-height: 50px;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-group .btn {
    padding: 14px 20px;
    border-radius: 25px;
    white-space: nowrap;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 50px;
    font-size: 15px;
    flex: 0 0 auto;
    width: auto;
}

.input-group .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        direction: rtl;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        max-height: 300px;
        border-left: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .sidebar-header {
        padding: 16px 20px;
    }
    
    .sidebar-header h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .conversations-list {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .conversation-item {
        min-width: 200px;
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .conversation-title {
        font-size: 14px;
    }
    
    .conversation-date {
        font-size: 11px;
    }
    
    .chat-area {
        flex: 1;
        min-height: calc(100vh - 300px);
    }
    
    .chat-header {
        padding: 16px 20px;
    }
    
    .chat-header h3 {
        font-size: 16px;
    }
    
    .messages-container {
        padding: 16px;
    }
    
    .message-bubble {
        max-width: 90%;
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .chat-input-container {
        padding: 16px 20px;
    }
    
    .input-group input {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
        flex: 1;
    }
    
    .input-group .btn {
        padding: 12px 18px;
        font-size: 14px;
        min-height: 44px;
        flex: 0 0 auto;
        width: auto;
    }
    
    .welcome-message {
        margin-top: 60px;
        padding: 0 20px;
    }
    
    .welcome-message h2 {
        font-size: 24px;
    }
    
    .welcome-message p {
        font-size: 14px;
    }
}
