* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #0066CC;
    --primary-dark: #004C99;
    --secondary: #0080FF;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --bg-primary: #F5F7FA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E8EDF2;
    --bg-chat: #FFFFFF;
    
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    
    --border-color: #E0E0E0;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    
    --gradient-primary: linear-gradient(135deg, #0066CC 0%, #004C99 100%);
    --gradient-secondary: linear-gradient(135deg, #0080FF 0%, #0066CC 100%);
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    direction: rtl;
}

.container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-direction: row-reverse;
}

.logo-icon {
    animation: float 3s ease-in-out infinite;
}

.logo-icon img {
    display: block;
    max-height: 50px;
    width: auto;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: right;
}

.subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
    text-align: right;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.error {
    background: var(--danger);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
    overflow: hidden;
}

.chat-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
    scroll-behavior: smooth;
}

.chat-wrapper::-webkit-scrollbar {
    width: 8px;
}

.chat-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.chat-wrapper::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.chat-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    animation: fadeIn 0.6s ease-out;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.welcome-icon {
    margin-bottom: 2rem;
    animation: scaleIn 0.8s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.welcome-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.suggested-prompts {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.prompt-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.prompt-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    transform: translateX(5px);
}

.prompt-icon {
    font-size: 1.5rem;
}

/* Messages */
.messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    display: flex;
    gap: 1rem;
    animation: messageSlideIn 0.4s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--gradient-primary);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
}

.message-content {
    flex: 1;
    max-width: 70%;
}

.message.user .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-bubble {
    padding: 1rem 1.25rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

/* Message bubble content formatting */
.message-bubble p {
    margin: 0.5rem 0;
}

.message-bubble p:first-child {
    margin-top: 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
    padding-right: 0;
}

.message-bubble[dir="rtl"] ul,
.message-bubble[dir="rtl"] ol {
    padding-right: 1.5rem;
    padding-left: 0;
}

.message-bubble li {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.message-bubble ul {
    list-style-type: disc;
}

.message-bubble[dir="rtl"] ul {
    list-style-type: disc;
}

.message-bubble[dir="rtl"] ol {
    list-style-type: decimal;
}

.message-bubble ol {
    list-style-type: decimal;
}

.message-bubble strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-bubble code {
    background: var(--bg-primary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message.user .message-bubble {
    background: var(--gradient-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.user .message-bubble strong {
    color: white;
}

.message.assistant .message-bubble {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 0.5rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 1rem;
    margin-left: 3.5rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    padding: 1rem 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    width: 100%;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.input-form {
    display: flex;
    gap: 1rem;
    max-width: 100%;
    margin: 0 auto;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 0.75rem 1rem;
    transition: border-color 0.3s ease;
    align-items: center;
}

.input-form:focus-within {
    border-color: var(--primary);
}

#messageInput {
    flex: 1 1 0%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-family: 'Cairo', sans-serif;
    resize: none;
    max-height: 200px;
    min-height: 48px;
    height: 48px;
    width: 100%;
    overflow-y: auto;
    line-height: 1.7;
    direction: rtl;
    text-align: right;
}

#messageInput::placeholder {
    color: var(--text-tertiary);
    direction: rtl;
    text-align: right;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: var(--gradient-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding: 0 0.5rem;
}

.character-count {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.new-chat-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary);
    color: var(--text-primary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .chat-container {
        padding: 0 1rem;
    }

    .welcome-content h2 {
        font-size: 2rem;
    }

    .message-content {
        max-width: 85%;
    }

    .logo-text h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.7rem;
    }
}

/* Loading Animation */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading {
    animation: shimmer 2s infinite linear;
    background: linear-gradient(
        to right,
        var(--bg-tertiary) 4%,
        var(--bg-secondary) 25%,
        var(--bg-tertiary) 36%
    );
    background-size: 1000px 100%;
}
