/**
 * RAACO Custom AI Chatbot Stylesheet
 * Premium architectural blueprint theme with luxury glassmorphic details.
 */

:root {
    --raaco-chat-navy: #030812;
    --raaco-chat-navy-card: rgba(8, 20, 38, 0.85);
    --raaco-chat-navy-hover: rgba(12, 30, 56, 0.95);
    --raaco-chat-gold: #BC923E;
    --raaco-chat-gold-bright: #E5C158;
    --raaco-chat-gold-glow: rgba(188, 146, 62, 0.25);
    --raaco-chat-text-primary: #E8EDF2;
    --raaco-chat-text-muted: #8E9BAE;
    --raaco-chat-white: #FFFFFF;
    --raaco-chat-border: rgba(255, 255, 255, 0.08);
}

/* Chat Widget Container */
.raaco-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999999;
    font-family: 'Tajawal', 'Inter', sans-serif;
    box-sizing: border-box;
}

.raaco-chat-widget.rtl {
    right: auto;
    left: 30px;
    direction: rtl;
}

.raaco-chat-widget *, 
.raaco-chat-widget *::before, 
.raaco-chat-widget *::after {
    box-sizing: border-box;
}

/* Float Launch Button */
.raaco-chat-trigger-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    z-index: 1;
}

.raaco-chat-pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1.5px solid var(--raaco-chat-gold);
    box-shadow: 0 0 12px var(--raaco-chat-gold-glow);
    pointer-events: none;
    opacity: 0;
    animation: raacoRadarPulse 2.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.raaco-chat-pulse-ring.delay-1 {
    animation-delay: 1.25s;
}

@keyframes raacoRadarPulse {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.raaco-chat-widget.active .raaco-chat-pulse-ring {
    display: none;
}

.raaco-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--raaco-chat-navy-card);
    border: 1px solid var(--raaco-chat-gold);
    color: var(--raaco-chat-gold-bright);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3), 0 0 10px var(--raaco-chat-gold-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.raaco-chat-trigger:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 20px var(--raaco-chat-gold);
    color: var(--raaco-chat-white);
}

.raaco-chat-trigger svg.raaco-chat-svg {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.raaco-chat-trigger:hover svg.raaco-chat-svg {
    transform: rotate(5deg) scale(1.05);
}

.trigger-glow-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--raaco-chat-gold-glow) 0%, transparent 70%);
    opacity: 0.6;
    pointer-events: none;
}

.raaco-chat-trigger .trigger-icon {
    display: flex;
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.raaco-chat-trigger .trigger-close-icon {
    position: absolute;
    display: flex;
    opacity: 0;
    transform: scale(0.5) rotate(-45deg);
    transition: transform 0.4s ease, opacity 0.3s ease;
}

.raaco-chat-widget.active .raaco-chat-trigger {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.raaco-chat-widget.active .raaco-chat-trigger:hover {
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.6);
}

.raaco-chat-widget.active .raaco-chat-trigger .trigger-icon {
    opacity: 0;
    transform: scale(0.5) rotate(45deg);
}

.raaco-chat-widget.active .raaco-chat-trigger .trigger-close-icon {
    opacity: 1;
    transform: scale(1) rotate(0);
}

/* Chat Window Box */
.raaco-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: var(--raaco-chat-navy-card);
    border: 1px solid var(--raaco-chat-border);
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.8) translateY(30px);
    pointer-events: none;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.raaco-chat-widget.rtl .raaco-chat-window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.raaco-chat-widget.active .raaco-chat-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Header */
.chat-header {
    padding: 16px 20px;
    background: rgba(8, 20, 38, 0.6);
    border-bottom: 1px solid var(--raaco-chat-border);
    position: relative;
}

.header-brackets {
    position: absolute;
    width: 6px;
    height: 6px;
    border-color: var(--raaco-chat-gold);
    border-style: solid;
    border-width: 0;
    pointer-events: none;
}
.header-brackets.tl { top: 6px; left: 6px; border-top-width: 1px; border-left-width: 1px; }
.header-brackets.tr { top: 6px; right: 6px; border-top-width: 1px; border-right-width: 1px; }
.header-brackets.bl { bottom: 6px; left: 6px; border-bottom-width: 1px; border-left-width: 1px; }
.header-brackets.br { bottom: 6px; right: 6px; border-bottom-width: 1px; border-right-width: 1px; }

.chat-header-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

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

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(188, 146, 62, 0.1);
    border: 1px solid rgba(188, 146, 62, 0.3);
    color: var(--raaco-chat-gold-bright);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.status-indicator {
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--raaco-chat-navy);
    border-radius: 50%;
    position: absolute;
    bottom: -2px;
    right: -2px;
}

.raaco-chat-widget.rtl .status-indicator {
    right: auto;
    left: -2px;
}

.chat-header-info h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--raaco-chat-white);
}

.chat-header-info .status-text {
    margin: 3px 0 0;
    font-size: 11px;
    color: var(--raaco-chat-text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-header-info .status-text .dot {
    width: 5px;
    height: 5px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
    animation: pulseGlow 1.5s infinite;
}

/* Messages Area */
.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.005) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.005) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(188, 146, 62, 0.2);
    border-radius: 2px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--raaco-chat-gold);
}

/* Individual Message Bubble */
.chat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    position: relative;
    word-break: break-word;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    animation: messageSlideIn 0.3s ease forwards;
}

/* Bot Message */
.chat-msg.bot {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--raaco-chat-text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.raaco-chat-widget.rtl .chat-msg.bot {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 4px;
    align-self: flex-start;
}

/* User Message */
.chat-msg.user {
    background: rgba(188, 146, 62, 0.08);
    border: 1px solid rgba(188, 146, 62, 0.2);
    color: var(--raaco-chat-gold-bright);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.raaco-chat-widget.rtl .chat-msg.user {
    border-bottom-right-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-end;
}

/* Typing / Waiting Indicator */
.chat-msg.typing {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.02);
    align-self: flex-start;
    padding: 10px 15px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-msg.typing span {
    width: 6px;
    height: 6px;
    background: var(--raaco-chat-text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.4s infinite both;
}

.chat-msg.typing span:nth-child(2) {
    animation-delay: .2s;
}

.chat-msg.typing span:nth-child(3) {
    animation-delay: .4s;
}

/* WhatsApp Conversion Button */
.chat-msg a.wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #25D366;
    color: #fff;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    margin-top: 10px;
    font-size: 12px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
}

.chat-msg a.wa-btn:hover {
    background: #128C7E;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.5);
}

/* Input Panel */
.chat-input-panel {
    padding: 12px 16px;
    background: rgba(3, 8, 18, 0.7);
    border-top: 1px solid var(--raaco-chat-border);
}

.chat-input-panel form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-panel input {
    flex-grow: 1;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--raaco-chat-text-primary);
    padding: 0 15px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s ease;
}

.chat-input-panel input:focus {
    border-color: var(--raaco-chat-gold);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 8px rgba(188, 146, 62, 0.15);
}

.chat-input-panel button {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(188, 146, 62, 0.1);
    border: 1px solid rgba(188, 146, 62, 0.3);
    color: var(--raaco-chat-gold-bright);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-input-panel button:hover {
    background: var(--raaco-chat-gold);
    color: var(--raaco-chat-white);
    box-shadow: 0 0 10px var(--raaco-chat-gold-glow);
}

/* Animations */
@keyframes pulseGlow {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

/* Quick Replies (Suggested Choices) */
.chat-quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 5px 0 10px;
    padding: 0 10px;
    align-self: flex-start;
    max-width: 95%;
    animation: messageSlideIn 0.3s ease forwards;
}

.raaco-chat-widget.rtl .chat-quick-replies-container {
    align-self: flex-start;
}

.quick-reply-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(188, 146, 62, 0.3);
    color: var(--raaco-chat-gold-bright);
    padding: 8px 14px;
    border-radius: 18px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.quick-reply-btn:hover {
    background: var(--raaco-chat-gold);
    color: var(--raaco-chat-white);
    border-color: var(--raaco-chat-gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px var(--raaco-chat-gold-glow);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .raaco-chat-widget {
        bottom: 20px;
        right: 20px;
    }
    
    .raaco-chat-widget.rtl {
        left: 20px;
    }
    
    .raaco-chat-window {
        width: calc(100vw - 40px);
        height: 450px;
        bottom: 70px;
    }
}

/* Onboarding Screen Overlay */
.raaco-chat-onboarding {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #030812 0%, #081225 50%, #030812 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 24px;
    box-sizing: border-box;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 12px;
    overflow: hidden;
}

/* Onboarding Header close button */
.raaco-chat-onboarding-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.raaco-chat-onboarding-close:hover {
    color: #ef4444;
    transform: rotate(90deg);
}

/* Avatar Wrapper and Glow Animations */
.onboarding-avatar-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-avatar-glow {
    position: absolute;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, rgba(229, 193, 88, 0.35) 0%, rgba(229, 193, 88, 0) 70%);
    filter: blur(10px);
    animation: pulseGlow 3s ease-in-out infinite;
}

.onboarding-avatar-orbit {
    position: absolute;
    width: 86px;
    height: 86px;
    border: 1.5px dashed rgba(229, 193, 88, 0.4);
    border-radius: 50%;
    animation: rotateOrbit 12s linear infinite;
}

.onboarding-avatar {
    position: relative;
    width: 70px;
    height: 70px;
    background: rgba(3, 8, 18, 0.8);
    border: 2px solid var(--raaco-chat-gold);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: var(--raaco-chat-gold);
    box-shadow: 0 4px 15px rgba(229, 193, 88, 0.25);
    animation: floatingBot 3s ease-in-out infinite;
}

@keyframes rotateOrbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes pulseGlow {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}
@keyframes floatingBot {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

/* Typography */
.onboarding-welcome {
    font-size: 19px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px;
    font-family: 'Tajawal', sans-serif;
    letter-spacing: 0.5px;
    background: linear-gradient(to right, #fff 20%, #E5C158 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.onboarding-subtitle {
    font-size: 12px;
    color: var(--raaco-chat-text-muted);
    margin: 0 0 20px;
    line-height: 1.4;
    max-width: 90%;
    font-family: 'Tajawal', sans-serif;
}

/* Disclaimer Cards Layout */
.onboarding-disclaimer {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(229, 193, 88, 0.15);
    border-radius: 14px;
    padding: 18px 16px;
    margin-bottom: 25px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
}

.disclaimer-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* Ensure proper alignment depending on direction class */
.rtl .disclaimer-item {
    direction: rtl;
    text-align: right;
}
.ltr .disclaimer-item {
    direction: ltr;
    text-align: left;
}

.disclaimer-icon {
    font-size: 16px;
    color: var(--raaco-chat-gold);
    background: rgba(229, 193, 88, 0.1);
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(229, 193, 88, 0.2);
}

.disclaimer-text {
    flex: 1;
}

.disclaimer-text strong {
    display: block;
    font-size: 12.5px;
    color: #fff;
    margin-bottom: 3px;
    font-family: 'Tajawal', sans-serif;
}

.disclaimer-text p {
    margin: 0;
    font-size: 11px;
    color: var(--raaco-chat-text-muted);
    line-height: 1.4;
    font-family: 'Tajawal', sans-serif;
}

/* Call-to-action Button Styles */
.raaco-chat-onboarding-start {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, #BC923E 0%, #E5C158 50%, #BC923E 100%);
    border: none;
    color: #030812;
    font-size: 14px;
    font-weight: 700;
    padding: 13px 20px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(229, 193, 88, 0.35);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: 'Tajawal', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    overflow: hidden;
}

.raaco-chat-onboarding-start i {
    font-size: 14px;
    transition: transform 0.3s ease;
}

/* Rotate arrow for LTR vs RTL */
.rtl .raaco-chat-onboarding-start i {
    transform: scaleX(-1);
}

.raaco-chat-onboarding-start:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(229, 193, 88, 0.5);
}

.raaco-chat-onboarding-start:hover i {
    transform: translateX(4px);
}
.rtl .raaco-chat-onboarding-start:hover i {
    transform: scaleX(-1) translateX(4px);
}

.raaco-chat-onboarding-start:active {
    transform: translateY(0);
}

.raaco-chat-reset {
    background: none;
    border: none;
    color: var(--raaco-chat-gold);
    cursor: pointer;
    font-size: 16px;
    padding: 6px;
    transition: color 0.2s, transform 0.2s;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
}
.raaco-chat-reset:hover {
    color: #fff;
    transform: rotate(180deg);
}

/* Speech Bubble Tooltip Hint - Always on the left of the trigger button */
.raaco-chat-tooltip {
    position: absolute;
    top: 5px;
    right: 75px;
    left: auto !important;
    background: rgba(3, 8, 18, 0.95);
    border: 1.5px solid var(--raaco-chat-gold);
    border-radius: 12px;
    padding: 10px 16px 10px 24px;
    font-size: 13px;
    color: #ffffff;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25), 0 0 10px rgba(188, 146, 62, 0.15);
    cursor: pointer;
    z-index: 100000;
    opacity: 0;
    transform: scale(0.85) translateX(15px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    font-family: 'Tajawal', sans-serif;
}

.raaco-chat-tooltip.active {
    opacity: 1;
    transform: scale(1) translateX(0);
    pointer-events: auto;
}

/* Tooltip Arrow pointing to trigger (on the right of the tooltip) */
.raaco-chat-tooltip::after,
.raaco-chat-tooltip::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    transition: all 0.4s ease;
    left: auto !important;
}

.raaco-chat-tooltip::before {
    right: -8px;
    border-left: 8px solid var(--raaco-chat-gold);
    border-right: none !important;
}
.raaco-chat-tooltip::after {
    right: -6px;
    border-left: 8px solid #030812;
    border-right: none !important;
}

/* Tooltip Close Button (always on the left of the tooltip) */
.raaco-chat-tooltip .tooltip-close {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 16px;
    font-weight: 300;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    left: 8px;
    right: auto !important;
}

.raaco-chat-tooltip .tooltip-close:hover {
    color: #ef4444;
}

/* Hide when active widget is open */
.raaco-chat-widget.active .raaco-chat-tooltip {
    display: none !important;
}