/* Modern Customer Support Agent UI */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --background: #0f1419;
    --sidebar-bg: #1a1f2e;
    --chat-bg: #ffffff;
    --message-user-bg: #6366f1;
    --message-assistant-bg: #f3f4f6;
    --border-color: #2d3748;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 4px;
}

.version {
    font-size: 12px;
    color: var(--text-light);
}

.sidebar-actions {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: rgba(139, 92, 246, 0.1);
    color: var(--secondary-color);
}

.btn-secondary:hover {
    background: rgba(139, 92, 246, 0.2);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-history h3 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: #ffffff;
}

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

.chat-item.active {
    background: var(--primary-color);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.stats {
    display: flex;
    justify-content: space-around;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.status-active {
    color: var(--success);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
}

.chat-header {
    padding: 20px 32px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-title p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle input[type="checkbox"] {
    width: 40px;
    height: 20px;
    appearance: none;
    background: #e5e7eb;
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.toggle input[type="checkbox"]:checked {
    background: var(--primary-color);
}

.toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.toggle input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f3f4f6;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    background: #f9fafb;
}

.welcome-screen {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.welcome-content {
    text-align: center;
    max-width: 600px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.welcome-content h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-content p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 32px;
}

.suggestion-card {
    padding: 20px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.suggestion-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.suggestion-icon {
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
}

.suggestion-card p {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

/* Messages */
.messages {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

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

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

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

.message.assistant .message-avatar {
    background: #f3f4f6;
}

.message-content {
    flex: 1;
    max-width: 70%;
}

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

.message-author {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-light);
}

.message-text {
    padding: 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
}

.message.user .message-text {
    background: var(--message-user-bg);
    color: white;
}

.message.assistant .message-text {
    background: white;
    color: var(--text-primary);
    border: 1px solid #e5e7eb;
}

/* RTL Support for Arabic Text */
.message-text[dir="rtl"],
.message-header[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

.message-text[dir="rtl"] strong,
.message-text[dir="rtl"] code {
    font-family: 'Inter', 'Arabic UI Display', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Ensure proper formatting for mixed content */
.message-text[dir="rtl"] ul,
.message-text[dir="rtl"] ol {
    padding-right: 20px;
    padding-left: 0;
}

.message-text[dir="rtl"] code {
    direction: ltr;
    display: inline-block;
}

.message-sources {
    margin-top: 12px;
    padding: 12px;
    background: #fef3c7;
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
}

.message-sources-title {
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 8px;
}

.source-item {
    font-size: 13px;
    color: #78350f;
    margin-bottom: 4px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Input Area */
.input-area {
    padding: 24px 32px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
    transition: border-color 0.2s;
}

.input-container:focus-within {
    border-color: var(--primary-color);
}

#messageInput {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    outline: none;
    color: var(--text-primary);
}

#messageInput::placeholder {
    color: var(--text-light);
}

.btn-send {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    margin-top: 8px;
    text-align: center;
}

.footer-text {
    font-size: 12px;
    color: var(--text-light);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease-out;
}

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

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

.upload-area {
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    padding: 48px;
    text-align: center;
    transition: all 0.2s;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.upload-progress {
    margin-top: 24px;
}

.upload-progress.hidden {
    display: none;
}

.progress-bar {
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
}

#uploadStatus {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
}

.uploaded-files {
    margin-top: 24px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-status {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.file-status.success {
    background: #d1fae5;
    color: #065f46;
}

.file-status.error {
    background: #fee2e2;
    color: #991b1b;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -280px;
        height: 100vh;
        z-index: 100;
        transition: left 0.3s;
    }
    
    .sidebar.active {
        left: 0;
    }
    
    .suggestion-cards {
        grid-template-columns: 1fr;
    }
    
    .message-content {
        max-width: 85%;
    }
}

