/* Chatbot Styles */
:root {
    --chatbot-direction: ltr;
}

/* Add DinNext font for Arabic text */
@font-face {
    font-family: 'DinNext';
    src: url('../fonts/DinNext-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* Arabic text specific class */
.arabic-text {
    font-family: 'DinNext', 'Poppins', sans-serif !important;
    font-weight: normal;
    text-align: right;
}

/* Container in RTL mode */
.chatbot-container.rtl-mode,
.chatbot-container.rtl-mode * {
    direction: rtl;
}

.chatbot-container.rtl-mode .chatbot-input {
    flex-direction: row-reverse;
}

.chatbot-container.rtl-mode #chatbot-send {
    margin-left: 0;
    margin-right: 10px;
}

.chatbot-container.rtl-mode .quick-topic-btn {
    text-align: right;
    display: flex;
    flex-direction: row-reverse;
}

.chatbot-container.rtl-mode .user-message {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 16px;
}

.chatbot-container.rtl-mode .bot-message {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 16px;
}

/* Override default font for RTL elements */
[dir="rtl"] h5,
[dir="rtl"] p,
[dir="rtl"] span,
[dir="rtl"] li,
[dir="rtl"] button,
[dir="rtl"] a {
    font-family: 'DinNext', 'Poppins', sans-serif !important;
}

/* Ensure RTL input field uses DinNext */
#chatbot-input-field[dir="rtl"] {
    font-family: 'DinNext', 'Poppins', sans-serif !important;
    text-align: right;
}

.chatbot-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
    font-family: 'Poppins', sans-serif;
}

.chatbot-toggle {
    position: absolute;
    bottom: 0;
    right: 0;
}

.chatbot-btn {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(var(--accent-rgb), 0.8) 100%);
    color: white;
    border: none;
    box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chatbot-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.8) 0%, var(--accent) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 50%;
}

.chatbot-btn:hover::before {
    opacity: 1;
}

.chatbot-btn i {
    position: relative;
    z-index: 2;
}

.chatbot-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 24px rgba(var(--accent-rgb), 0.35);
}

/* Pulse animation for toggle button */
@keyframes pulseAnimation {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(var(--accent-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0);
    }
}

.chatbot-btn.pulse {
    animation: pulseAnimation 1.5s ease-out;
}

.chat-tooltip {
    position: absolute;
    right: 80px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(5px);
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px 0 8px 8px;
    border-style: solid;
    border-color: transparent transparent transparent rgba(0, 0, 0, 0.85);
}

.chatbot-btn:hover .chat-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

/* Scale variations */
.chatbot-box {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 450px;
    height: 600px;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 10px 35px var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0);
    transform-origin: bottom right;
    opacity: 0;
    border: 1px solid rgba(var(--accent-rgb), 0.1);
}

.chatbot-box.open {
    transform: scale(1);
    opacity: 1;
}

.chatbot-box.scaled-down {
    width: 380px;
    height: 500px;
    font-size: 0.9em;
}

.chatbot-box.scaled-up {
    width: 500px;
    height: 800px;
}

.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #0072ff;
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .chatbot-header {
    background: #0056b3;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatbot-title i {
    font-size: 18px;
}

.chatbot-title h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.chatbot-actions {
    display: flex;
    gap: 8px;
}

.chatbot-action-btn, 
.chatbot-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.chatbot-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(10deg);
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chatbot-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(rgba(var(--accent-rgb), 0.03) 2px, transparent 2px),
        radial-gradient(rgba(var(--accent-rgb), 0.03) 2px, transparent 2px);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--accent-rgb), 0.3) transparent;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background-color: rgba(var(--accent-rgb), 0.3);
    border-radius: 20px;
}

.message {
    max-width: 85%;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 2px 5px var(--shadow);
    transition: all 0.2s ease;
    animation: messageAppear 0.3s forwards;
    opacity: 0;
    transform: translateY(10px);
}

/* Highlight animation for when conversation is cleared */
.message.highlight {
    animation: highlightPulse 1s ease-in-out;
}

@keyframes highlightPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 5px var(--shadow);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.2);
    }
}

@keyframes messageAppear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(var(--accent-rgb), 0.8) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.bot-message {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(var(--accent-rgb), 0.08);
}

/* Styling for HTML tags in bot responses */
.bot-message .message-content h5 {
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0 6px;
    color: var(--accent);
}

.bot-message .message-content p {
    margin: 0 0 6px;
    font-size: 14px;
    line-height: 1.5;
}

.bot-message .message-content p:last-of-type {
    margin-bottom: 0;
}

.bot-message .message-content ul {
    margin: 6px 0;
    padding-left: 20px;
}

.bot-message .message-content li {
    font-size: 14px;
    margin-bottom: 4px;
    line-height: 1.45;
}

.bot-message .message-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dotted;
    transition: all 0.2s ease;
}

.bot-message .message-content a:hover {
    opacity: 0.8;
}

.bot-message .message-content b {
    font-weight: 600;
    color: var(--accent);
}

/* Quick topics styling */
.quick-topics {
    list-style: none;
    padding: 0;
    margin: 6px 0 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quick-topic-btn {
    background: rgba(var(--accent-rgb), 0.1);
    color: var(--accent);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
}

.quick-topic-btn:hover {
    background: rgba(var(--accent-rgb), 0.15);
    border-color: rgba(var(--accent-rgb), 0.3);
    transform: translateX(3px);
}

.chatbot-input {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid rgba(var(--accent-rgb), 0.08);
    background: var(--bg-primary);
}

#chatbot-input-field {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid rgba(var(--accent-rgb), 0.1);
    border-radius: 20px;
    outline: none;
    font-family: 'Poppins', sans-serif;
    font-size: 13px;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px var(--shadow);
    background: var(--bg-secondary);
    color: var(--text-primary);
}

#chatbot-input-field::placeholder {
    color: var(--text-secondary);
    font-size: 12px;
}

#chatbot-input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
}

#chatbot-send {
    width: 38px;
    height: 38px;
    margin-left: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, rgba(var(--accent-rgb), 0.8) 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 8px rgba(var(--accent-rgb), 0.25);
}

#chatbot-send:hover {
    transform: scale(1.05) rotate(5deg);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.35);
}

#chatbot-send:active {
    transform: scale(0.95);
}

/* Loading animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: var(--bg-secondary);
    border-radius: 14px;
    width: fit-content;
    margin-top: 5px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(var(--accent-rgb), 0.2);
}

.typing-icon {
    color: var(--accent);
    font-size: 1.2rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.typing-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 3px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite ease-in-out;
    opacity: 0.7;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-5px);
    }
}

/* Responsive design for smaller screens */
@media (max-width: 480px) {
    .chatbot-box {
        width: calc(100vw - 40px);
        right: 20px;
        bottom: 80px;
    }
    
    .chatbot-container {
        right: 20px;
        bottom: 20px;
    }
    
    .chatbot-box.scaled-down {
        width: calc(100vw - 40px);
        height: 350px;
    }
    
    .chatbot-box.scaled-up {
        width: calc(100vw - 40px);
        height: 80vh;
        max-height: 700px;
    }
}

/* Style for language toggle button */
#chatbot-lang-toggle {
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#lang-flag {
    font-size: 16px;
}

/* Animation for language toggle highlight */
.chatbot-action-btn.highlight {
    animation: highlightPulse 1s ease-in-out;
}

/* RTL direction modifications */
[dir="rtl"],
.message-content[dir="rtl"] {
    text-align: right;
}

/* Apply direction to chatbot elements */
.chatbot-messages .message-content h5,
.chatbot-messages .message-content p,
.chatbot-messages .message-content ul,
.chatbot-messages .message-content li {
    direction: var(--chatbot-direction);
}

/* Quick topic buttons for RTL */
.quick-topics[dir="rtl"] {
    padding-right: 0;
}

.quick-topic-btn[dir="rtl"] {
    text-align: right;
}

/* RTL specific font and direction controls */
[dir="rtl"],
.message-content[dir="rtl"],
.quick-topic-btn[dir="rtl"],
.quick-topics[dir="rtl"],
html[lang="ar"] .chatbot-messages .message-content * {
    font-family: 'DinNext', 'Poppins', sans-serif;
    text-align: right;
}

/* Apply direction to chatbot elements */
.chatbot-messages .message-content h5,
.chatbot-messages .message-content p,
.chatbot-messages .message-content ul,
.chatbot-messages .message-content li,
.chatbot-messages .message-content a,
.chatbot-messages .message-content b {
    direction: var(--chatbot-direction);
}

/* RTL specific input field */
html[lang="ar"] #chatbot-input-field,
#chatbot-input-field[dir="rtl"] {
    direction: rtl;
    text-align: right;
    font-family: 'DinNext', 'Poppins', sans-serif;
}

/* Quick topic buttons for RTL */
.quick-topics[dir="rtl"] {
    padding-right: 0;
}

.quick-topic-btn[dir="rtl"] {
    text-align: right;
    display: flex;
    flex-direction: row-reverse;
}

/* RTL specific input container */
html[lang="ar"] .chatbot-input {
    flex-direction: row-reverse;
}

html[lang="ar"] #chatbot-send {
    margin-left: 0;
    margin-right: 10px;
}

/* RTL user message alignment */
html[lang="ar"] .user-message {
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 16px;
}

/* RTL bot message alignment */
html[lang="ar"] .bot-message {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 16px;
}

/* Add specific RTL styles for quick topic buttons */
.chatbot-container.rtl-mode .quick-topics {
    padding-right: 0;
    padding-left: 0;
}

.chatbot-container.rtl-mode .quick-topic-btn {
    text-align: right;
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    padding-right: 15px;
}

.chatbot-container.rtl-mode .quick-topic-btn:hover {
    transform: translateX(-3px);
}

/* Ensure emoji alignment in RTL mode */
.chatbot-container.rtl-mode .quick-topic-btn::before {
    margin-left: 0;
    margin-right: auto;
}

/* Make sure list items align correctly */
.chatbot-container.rtl-mode .quick-topics li {
    text-align: right;
    direction: rtl;
}

/* Footer styles */
.chatbot-footer {
    padding: 6px 10px;
    text-align: center;
    font-size: 11px;
    color: var(--text-light);
    background: rgba(var(--accent-rgb), 0.05);
    border-top: 1px solid rgba(var(--accent-rgb), 0.1);
}

.chatbot-powered-by {
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 3px;
}

.chatbot-powered-by a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.scalexi-logo {
    height: 16px;
    width: auto;
    vertical-align: middle;
    margin-left: 3px;
}

.chatbot-container.rtl-mode .scalexi-logo {
    margin-left: 0;
    margin-right: 3px;
}

.chatbot-powered-by a:hover {
    text-decoration: underline;
}

.rtl-text {
    font-family: 'DinNext', 'Poppins', sans-serif;
    display: none;
}

[dir="rtl"] .rtl-text {
    display: inline;
}

[dir="rtl"] .ltr-text {
    display: none;
}

.chatbot-container.rtl-mode .chatbot-footer {
    direction: rtl;
}

.chatbot-container.rtl-mode .rtl-text {
    display: inline;
}

.chatbot-container.rtl-mode .ltr-text {
    display: none;
} 