/* Gulf Charter AI Assistant Styles with Complete RTL Support */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5aa0;
    --secondary-color: #1e3a72;
    --accent-color: #4a90e2;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --border-color: #e1e8ed;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --font-family-ar: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-family-en: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: var(--font-family-ar);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    transition: all 0.3s ease;
}

body:not(.rtl) {
    font-family: var(--font-family-en);
}

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

/* Header Styles - Always Left Aligned */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    direction: ltr;
    text-align: left;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-align: left;
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary-color);
}

.logo-text {
    text-align: left;
}

.logo-text h1 {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-align: left;
}

.logo-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: left;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    font-weight: 600;
}

.lang-btn:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success-color);
}

.status-dot.offline {
    background: var(--danger-color);
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* Main Content Layout */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    gap: 2rem;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RTL Layout (Arabic) */
body.rtl .main-content {
    direction: rtl;
    flex-direction: row-reverse;
}

body.rtl .sidebar {
    order: 1;
}

body.rtl .chat-section {
    order: 2;
}

/* LTR Layout (English) */
body:not(.rtl) .main-content {
    direction: ltr;
    flex-direction: row;
}

body:not(.rtl) .sidebar {
    order: 1;
}

body:not(.rtl) .chat-section {
    order: 2;
}

/* Sidebar */
.sidebar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    width: 320px;
    flex-shrink: 0;
    height: fit-content;
    box-shadow: var(--shadow);
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-topics h3,
.example-questions h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body.rtl .quick-topics h3,
body.rtl .example-questions h3 {
    direction: rtl;
    text-align: right;
}

.topic-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.topic-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    text-align: inherit;
    width: 100%;
    font-size: 0.9rem;
}

body.rtl .topic-btn {
    direction: rtl;
    text-align: right;
}

.topic-btn:hover {
    background: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.question-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.question-item {
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
    line-height: 1.4;
    border-left: 3px solid transparent;
}

body.rtl .question-item {
    border-left: none;
    border-right: 3px solid transparent;
    direction: rtl;
    text-align: right;
}

.question-item:hover {
    background: var(--accent-color);
    color: white;
    transform: translateY(-2px);
    border-left-color: var(--primary-color);
}

body.rtl .question-item:hover {
    border-left-color: transparent;
    border-right-color: var(--primary-color);
}

/* Chat Section */
.chat-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    overflow: hidden;
    flex: 1;
    min-height: 600px;
}

/* HeyGen Avatar Container */
.avatar-container {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    padding: 2rem;
    text-align: center;
    color: white;
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

.avatar-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.avatar-icon {
    font-size: 3.5rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.avatar-status {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 1rem;
    font-weight: 500;
    text-align: center;
}

body.rtl .avatar-status {
    direction: rtl;
    text-align: center;
}

.enable-avatar-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 0.875rem 1.75rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-size: 1rem;
    font-weight: 600;
}

.enable-avatar-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

/* HeyGen Video Container */
.heygen-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#avatarVideo {
    width: 100%;
    height: 200px;
    border-radius: 0;
    object-fit: cover;
    background: #000;
}

.avatar-controls-overlay {
    position: absolute;
    bottom: 15px;
    right: 15px;
    display: flex;
    gap: 0.5rem;
}

.avatar-control-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.avatar-control-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Chat Messages */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

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

/* RTL Message Layout */
body.rtl .user-message {
    align-self: flex-start;
    flex-direction: row;
}

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

/* LTR Message Layout */
body:not(.rtl) .user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

body:not(.rtl) .assistant-message {
    align-self: flex-start;
    flex-direction: row;
}

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

.user-message .message-avatar {
    background: var(--accent-color);
    color: white;
}

.assistant-message .message-avatar {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.message-content {
    flex: 1;
}

.message-text {
    background: var(--bg-primary);
    padding: 1.125rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    line-height: 1.6;
    font-size: 0.95rem;
}

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

/* Perfect RTL Text Alignment */
body.rtl .message-text {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: embed;
}

body.rtl .message-text p,
body.rtl .message-text div,
body.rtl .message-text span,
body.rtl .message-text strong,
body.rtl .message-text em {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: embed;
}

body.rtl .message-text ol,
body.rtl .message-text ul {
    direction: rtl !important;
    text-align: right !important;
    padding-right: 2rem;
    padding-left: 0;
    margin-right: 0;
    margin-left: 0;
}

body.rtl .message-text li {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: embed;
    margin-right: 0;
    margin-left: 0;
}

/* English text alignment */
body:not(.rtl) .message-text {
    direction: ltr !important;
    text-align: left !important;
}

body:not(.rtl) .message-text ol,
body:not(.rtl) .message-text ul {
    padding-left: 2rem;
    padding-right: 0;
}

/* Content wrapper classes */
.arabic-content {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: embed;
}

.arabic-content * {
    direction: rtl !important;
    text-align: right !important;
    unicode-bidi: embed;
}

.english-content {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: embed;
}

.english-content * {
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: embed;
}

.welcome-ar {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    direction: rtl;
    text-align: right;
}

.welcome-en {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--secondary-color);
    margin-bottom: 0.5rem;
    direction: ltr;
    text-align: left;
}

.welcome-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

body.rtl .welcome-subtitle {
    direction: rtl;
    text-align: right;
}

body:not(.rtl) .welcome-subtitle {
    direction: ltr;
    text-align: left;
}

.message-metadata {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

body.rtl .message-metadata {
    direction: rtl;
    text-align: right;
}

.agent-info,
.references {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

body.rtl .agent-info,
body.rtl .references {
    direction: rtl;
    justify-content: flex-start;
}

.confidence-badge {
    background: var(--accent-color);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

body.rtl .confidence-badge {
    margin-right: 0.5rem;
    margin-left: 0;
}

body:not(.rtl) .confidence-badge {
    margin-left: 0.5rem;
    margin-right: 0;
}

/* Enhanced AI badge */
.enhanced-badge {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
    animation: shimmer 2s infinite;
}

body.rtl .enhanced-badge {
    margin-left: 0;
    margin-right: 0.5rem;
}

@keyframes shimmer {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.reference-link {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
}

.reference-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
    background-color: rgba(74, 144, 226, 0.1);
    border-color: rgba(74, 144, 226, 0.2);
    transform: translateY(-1px);
}

/* Chat Input */
.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    background: var(--bg-primary);
}

.input-wrapper {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 0.75rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    transition: border-color 0.3s ease;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 120px;
    line-height: 1.5;
}

body.rtl #messageInput {
    text-align: right;
    direction: rtl;
}

body:not(.rtl) #messageInput {
    text-align: left;
    direction: ltr;
}

.input-actions {
    display: flex;
    gap: 0.5rem;
}

.voice-btn,
.send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1rem;
}

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

.voice-btn:hover {
    background: #e67e22;
    transform: scale(1.1);
}

.voice-btn.listening {
    background: var(--danger-color);
    animation: pulse 1s infinite;
}

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

.send-btn:hover {
    background: var(--secondary-color);
    transform: scale(1.1);
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

body.rtl .input-footer {
    direction: rtl;
}

.agent-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body.rtl .agent-status {
    direction: rtl;
}

.status-text.processing {
    color: var(--accent-color);
    font-weight: 500;
}

.char-count {
    color: var(--text-secondary);
}

/* Footer */
.app-footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    padding: 1rem 0;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

body.rtl .footer-content {
    direction: rtl;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

.footer-links a:hover {
    color: var(--primary-color);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: var(--shadow);
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 1rem;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* HeyGen Integration Styles */
#heygen-streaming-embed {
    z-index: 8888 !important;
}

#heygen-streaming-embed.show {
    animation: avatarAppear 0.5s ease;
}

@keyframes avatarAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column !important;
        padding: 1rem;
        gap: 1rem;
    }

    .sidebar {
        width: 100% !important;
        order: 1 !important;
    }

    .chat-section {
        order: 2 !important;
        min-height: 500px;
    }

    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .chat-container {
        min-height: 350px;
    }

    .message {
        max-width: 95%;
    }

    .avatar-container {
        padding: 1.5rem;
        min-height: 160px;
    }

    .avatar-icon {
        font-size: 2.5rem;
    }

    .enable-avatar-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        padding: 0 0.5rem;
    }

    .main-content {
        padding: 0.5rem;
    }

    .sidebar {
        padding: 1rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .chat-input-container {
        padding: 1rem;
    }
}
