/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* FlowIT Professional color palette */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --tertiary: #999999;
    --background: #ffffff;
    --surface: #f8f9fa;
    --border: #e9ecef;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --accent: #3b82f6;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 8px;
    --transition: all 0.2s ease;
    
    /* FlowIT Gradient Variables */
    --flowit-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    --flowit-gradient-soft: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(37, 99, 235, 0.1) 100%);
    --flowit-primary: #3b82f6;
    --border-light: #e2e8f0;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    min-height: 100vh;
    direction: ltr;
    line-height: 1.5;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
}

body[dir="rtl"] {
    direction: rtl;
    font-family: 'Noto Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--background);
    border-radius: var(--border-radius);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
    border: 1px solid var(--border);
}

/* Logo Styles */
.logo-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 16px;
    border-radius: var(--border-radius);
}

.header-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    margin-right: 12px;
    border-radius: 4px;
}

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

.welcome-form h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-form p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.welcome-form input,
.welcome-form select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    margin-bottom: 16px;
    transition: var(--transition);
    background: var(--background);
}

.welcome-form input:focus,
.welcome-form select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.language-selector label {
    font-weight: 500;
    color: #333;
}

.primary-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.primary-button:active {
    transform: scale(0.98);
}

/* Main Interface */
.main-interface {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--background);
}

/* Header */
.header {
    background: var(--background);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.welcome-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.language-selector-header select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 6px 12px;
    font-size: 0.8rem;
    color: var(--text-primary);
    cursor: pointer;
}

.icon-button {
    background: none;
    border: none;
    padding: 8px;
    border-radius: var(--border-radius);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.icon-button:hover {
    background: var(--surface);
    color: var(--text-primary);
}

/* Mode Selection */
.mode-selection {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    gap: 15px;
}

.mode-button {
    background: white;
    border: 2px solid #e1e5e9;
    padding: 15px 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: #666;
}

.mode-button:hover {
    border-color: #667eea;
    color: #667eea;
}

.mode-button.active {
    background: var(--flowit-gradient);
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-soft);
}

.mode-button svg {
    transition: transform 0.2s ease;
}

.mode-button:hover svg {
    transform: scale(1.1);
}

/* Model Selection */
.model-selection {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e1e5e9;
}

.model-options {
    display: flex;
    gap: 15px;
}

.model-button {
    background: white;
    border: 2px solid #e1e5e9;
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    text-align: left;
    position: relative;
}

.model-button:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.model-button.active {
    border-color: #667eea;
    background: #f8faff;
}

.model-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.model-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.model-desc {
    font-size: 0.9rem;
    color: #666;
}

.model-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #10b981;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.model-badge.pro {
    background: #8b5cf6;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    max-width: 768px;
    margin: 0 auto;
    width: 100%;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
}

.empty-state h2 {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.message {
    display: flex;
    gap: 15px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-content {
    background: white;
    padding: 24px;
    border-radius: var(--border-radius);
    max-width: 85%;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-light);
    position: relative;
    word-wrap: break-word;
    line-height: 1.6;
}

.message.user .message-content {
    background: var(--flowit-gradient);
    color: white;
    border: none;
}

.message.assistant .message-content {
    background: white;
    border: 1px solid var(--border-light);
}

.message.assistant .message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid white;
}

.message.user .message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    right: -8px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid var(--flowit-primary);
}

.message.system-message .message-content {
    background: var(--flowit-gradient-soft);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    font-weight: 500;
    text-align: center;
}

.message-content p {
    margin: 0;
    line-height: 1.6;
}

.message-content img {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 10px;
}

/* News URL styling */
.user-news-url {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.url-label {
    font-weight: 600;
    font-size: 0.9rem;
    opacity: 0.9;
}

.user-news-url a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
    word-break: break-all;
    font-size: 0.9rem;
    transition: opacity 0.2s ease;
}

.user-news-url a:hover {
    opacity: 0.8;
}

/* Input Container */
.input-container {
    background: var(--background);
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.input-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.mode-selector {
    display: flex;
    gap: 8px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.mode-btn:hover {
    background: var(--border);
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.model-selector select {
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#userInput {
    flex: 1;
    border: none;
    background: none;
    resize: none;
    font-size: 0.95rem;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    min-height: 20px;
    max-height: 120px;
    color: var(--text-primary);
}

#userInput::placeholder {
    color: var(--text-tertiary);
}

.send-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover:not(:disabled) {
    background: var(--secondary);
}

.send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Settings Modal */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e1e5e9;
}

.close-button {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    line-height: 1;
}

.close-button:hover {
    color: #333;
}

.settings-content {
    margin-bottom: 30px;
}

.setting-group {
    margin-bottom: 25px;
    text-align: left;
}

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

.setting-group input,
.setting-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 1rem;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.radio-group input[type="radio"] {
    width: auto;
    margin: 0;
}

.modal-footer {
    text-align: center;
}

/* Enhanced Loading Styles */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(12px);
}

.loading-content {
    background: white;
    padding: 48px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow-large);
    max-width: 400px;
    width: 90%;
}

.loading-animation {
    margin-bottom: 24px;
}

.flowit-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.loader-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--flowit-gradient);
    animation: flowit-pulse 1.4s ease-in-out infinite both;
}

.loader-dot:nth-child(1) { animation-delay: -0.32s; }
.loader-dot:nth-child(2) { animation-delay: -0.16s; }
.loader-dot:nth-child(3) { animation-delay: 0; }

@keyframes flowit-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.loading-text-container {
    text-align: center;
}

.loading-main-text {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    background: var(--flowit-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-sub-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Thinking Indicator */
.thinking-indicator {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 12px 20px;
    border-radius: 24px;
    box-shadow: var(--shadow-medium);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1500;
    border: 1px solid var(--border-light);
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--flowit-primary);
    animation: thinking-bounce 1.4s ease-in-out infinite both;
}

.thinking-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-dots span:nth-child(2) { animation-delay: -0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0; }

@keyframes thinking-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.thinking-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .header {
        padding: 15px 20px;
    }
    
    .mode-selection,
    .model-selection {
        padding: 15px 20px;
    }
    
    .chat-messages {
        padding: 20px;
    }
    
    .input-container {
        padding: 15px 20px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .mode-button {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .model-button {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .mode-selection {
        flex-direction: column;
    }
    
    .model-options {
        flex-direction: column;
    }
    
    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .logo-text {
        font-size: 1.5rem;
    }
}

/* RTL Support */
body[dir="rtl"] .header-left {
    flex-direction: row-reverse;
}

body[dir="rtl"] .header-right {
    flex-direction: row-reverse;
}

body[dir="rtl"] .mode-selection {
    flex-direction: row-reverse;
}

body[dir="rtl"] .model-options {
    flex-direction: row-reverse;
}

body[dir="rtl"] .input-wrapper {
    flex-direction: row-reverse;
}

body[dir="rtl"] .input-footer {
    flex-direction: row-reverse;
}

body[dir="rtl"] .message.user {
    flex-direction: row;
}

body[dir="rtl"] .radio-group label {
    flex-direction: row-reverse;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    }
    
    .modal-content,
    .header,
    .mode-selection,
    .model-selection,
    .input-container,
    .loading-content {
        background: #1e293b;
        color: #e2e8f0;
    }
    
    .chat-messages {
        background: #0f172a;
    }
    
    .message-content {
        background: #334155;
        color: #e2e8f0;
    }
    
    .message.system-message .message-content {
        background: #475569;
        border-color: #64748b;
    }
    
    .input-wrapper {
        background: #334155;
        border-color: #64748b;
    }
    
    .welcome-form input,
    .welcome-form select,
    .setting-group input,
    .setting-group select {
        background: #334155;
        border-color: #64748b;
        color: #e2e8f0;
    }
} 