/* ========================================
   TROPHY CHATBOT STYLES
   Bolt-inspired design with Arabic RTL support
   Dark/Light theme compatible
   ======================================== */

:root {
    --chatbot-primary: var(--primary-color, #FF6900);
    --chatbot-secondary: var(--secondary-color, #A48111);
    --chatbot-bg: var(--bg-card, #ffffff);
    --chatbot-text: var(--text-primary, #1a1a1a);
    --chatbot-text-secondary: var(--text-secondary, #666666);
    --chatbot-border: var(--border-color, #e5e7eb);
    --chatbot-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.1));
    --chatbot-radius: 20px;
}

[data-theme="dark"] {
    --chatbot-bg: var(--bg-card, #1e293b);
    --chatbot-text: var(--text-primary, #f1f5f9);
    --chatbot-text-secondary: var(--text-secondary, #94a3b8);
    --chatbot-border: var(--border-color, #334155);
    --chatbot-shadow: var(--shadow-lg, 0 10px 40px rgba(0, 0, 0, 0.5));
}

/* ========================================
   CHATBOT CONTAINER
   ======================================== */

.chatbot-container {
    position: fixed;
    bottom: 24px;
    left: 30px; /* Left side for RTL layout */
    z-index: 9998; /* Below mobile menu (9999) */
    font-family: 'IBM Plex Sans Arabic', 'Cairo', 'Segoe UI', sans-serif;
    direction: rtl;
}

/* ========================================
   TOGGLE BUTTON - AI Chatbot Style
   ======================================== */

.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); /* Purple gradient */
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #5a67d8 0%, #6b46a0 100%);
}

.chatbot-toggle.active {
    transform: rotate(360deg) scale(0.95);
    background: linear-gradient(135deg, #4c51bf 0%, #553c9a 100%);
}

.chatbot-toggle i {
    animation: pulse 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Badge */
.chatbot-badge {
    position: absolute;
    top: -8px;
    left: -8px; /* Left side for badge in RTL */
    background: #ef4444;
    color: white;
    font-size: 10px;
    padding: 3px 6px;
    border-radius: 10px;
    font-weight: 700;
    animation: bounce 1s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ========================================
   CHATBOT WINDOW
   ======================================== */

.chatbot-window {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--chatbot-bg);
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(30px) scale(0.9);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid var(--chatbot-border);
    overflow: hidden;
}

.chatbot-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ========================================
   HEADER
   ======================================== */

.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--chatbot-radius) var(--chatbot-radius) 0 0;
}

.chatbot-header.scrolled {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--chatbot-border);
    transition: background 0.3s ease, backdrop-filter 0.3s ease;
}

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

.chatbot-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.chatbot-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
}

.chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
}
.chatbot-contact-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    animation: statusPulse 2s ease-in-out infinite;
}

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

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

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

/* ========================================
   MESSAGES AREA
   ======================================== */

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-surface, var(--chatbot-bg));
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-text-secondary);
}

/* ========================================
   MESSAGE BUBBLES
   ======================================== */

.chatbot-message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: messageSlide 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.message-content {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.message-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.message-text {
    background: var(--chatbot-bg);
    color: var(--chatbot-text);
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
    border: 1px solid var(--chatbot-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chatbot-message-user .message-content {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.chatbot-message-user .message-text {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    color: white;
    border: none;
    margin-right: auto;
}

/* ========================================
   FEEDBACK
   ======================================== */

.message-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--chatbot-text-secondary);
    margin-left: 42px;
}

.feedback-btn {
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    color: var(--chatbot-text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
    transform: scale(1.1);
}

.feedback-thanks {
    color: var(--chatbot-primary);
    font-weight: 600;
}

/* ========================================
   SUGGESTIONS
   ======================================== */

.chatbot-suggestions {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.suggestions-title {
    font-size: 12px;
    color: var(--chatbot-text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

.suggestion-btn {
    background: var(--chatbot-bg);
    border: 1px solid var(--chatbot-border);
    color: var(--chatbot-text);
    padding: 10px 14px;
    border-radius: 12px;
    text-align: right;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-family: inherit;
}

.suggestion-btn:hover {
    background: var(--chatbot-primary);
    color: white;
    border-color: var(--chatbot-primary);
    transform: translateX(4px);
}

/* ========================================
   INPUT AREA
   ======================================== */

.chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 16px 20px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-input {
    flex: 1;
    background: var(--bg-surface, var(--chatbot-bg));
    border: 2px solid var(--chatbot-border);
    border-radius: 16px;
    padding: 12px 16px;
    color: var(--chatbot-text);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: all 0.3s ease;
    line-height: 1.5;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(255, 105, 0, 0.1);
}

.chatbot-input::placeholder {
    color: var(--chatbot-text-secondary);
}

.chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-secondary));
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(255, 105, 0, 0.4);
}

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

/* ========================================
   FOOTER
   ======================================== */

.chatbot-footer {
    padding: 12px 20px;
    text-align: center;
    background: var(--bg-surface, var(--chatbot-bg));
    border-top: 1px solid var(--chatbot-border);
    color: var(--chatbot-text-secondary);
    font-size: 11px;
}

/* ========================================
   LOADER
   ======================================== */

.typing-indicator {
    display: none;
    align-items: flex-start;
}

.typing-indicator .message-text { padding: 14px 18px; }

.loader-dots {
    display: flex;
    gap: 6px;
}

.loader-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-text-secondary);
    animation: loaderPulse 1.2s cubic-bezier(0.2, 0.68, 0.18, 1.08) infinite;
}

.loader-dots span:nth-child(1) { animation-delay: 0s; }
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .chatbot-container {
        bottom: 80px; /* Above bottom navbar */
        left: 16px;
        right: auto;
    }

    .chatbot-window {
        width: calc(100vw - 32px);
        max-width: none;
        height: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
        bottom: 72px;
        left: 0;
        transform: translateY(30px) scale(0.9);
    }

    .chatbot-window.active {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: all;
    }

    .chatbot-toggle {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    .chatbot-header {
        padding: 16px;
    }

    .chatbot-avatar {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .chatbot-info h3 {
        font-size: 16px;
    }

    .message-text {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        bottom: 16px;
        left: 16px;
        right: auto;
    }

    .chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 180px);
        max-height: calc(100vh - 180px);
        bottom: 72px;
        left: 0;
        border-radius: var(--chatbot-radius);
    }

    .chatbot-messages {
        padding: 16px;
    }

    .chatbot-input-wrapper {
        padding: 12px 16px;
    }
}

/* ========================================
   DARK THEME ENHANCEMENTS
   ======================================== */

[data-theme="dark"] .chatbot-window {
    background: var(--bg-card);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .message-text {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .chatbot-input {
    background: var(--bg-secondary);
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.chatbot-toggle:focus-visible,
.chatbot-close:focus-visible,
.chatbot-send:focus-visible,
.feedback-btn:focus-visible,
.suggestion-btn:focus-visible {
    outline: 3px solid var(--chatbot-primary);
    outline-offset: 2px;
}

.chatbot-input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 105, 0, 0.3);
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .chatbot-container {
        display: none !important;
    }
}
