/**
 * Swiss Sparkle Chatbot Styles
 * Luxury brand styling with premium aesthetics
 */

/* Chatbot Container — left side (WhatsApp + site chat) */
.chatbot-container {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    z-index: 9999;
    font-family: var(--font-sans, 'DM Sans', sans-serif);
}

/* WhatsApp above site chat: column-reverse → chat anchored bottom-left, WhatsApp stacked above */
.chatbot-fab-row {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 14px;
}

.chatbot-whatsapp-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #25d366;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35), 0 4px 12px rgba(37, 211, 102, 0.25);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chatbot-whatsapp-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(37, 211, 102, 0.45), 0 6px 16px rgba(37, 211, 102, 0.3);
}

.chatbot-whatsapp-icon {
    width: 34px;
    height: 34px;
    display: block;
}

/* Floating Toggle Button */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #155225;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(21, 82, 37, 0.35), 0 4px 12px rgba(21, 82, 37, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: all 0.3s ease;
    animation: chatbotPulse 2s ease-in-out infinite;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(21, 82, 37, 0.45), 0 6px 16px rgba(21, 82, 37, 0.3);
}

.chatbot-toggle-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.chatbot-icon {
    width: 28px;
    height: 28px;
    color: white;
    z-index: 2;
}

.chatbot-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    animation: chatbotPulseRing 2s ease-out infinite;
}

@keyframes chatbotPulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(21, 82, 37, 0.35), 0 4px 12px rgba(21, 82, 37, 0.25);
    }
    50% {
        box-shadow: 0 12px 32px rgba(21, 82, 37, 0.45), 0 6px 16px rgba(21, 82, 37, 0.3);
    }
}

@keyframes chatbotPulseRing {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Chat Window — opens from bottom-left */
.chatbot-window {
    position: fixed;
    bottom: 24px;
    left: 24px;
    right: auto;
    width: 400px;
    height: 650px;
    max-height: calc(100vh - 48px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 24px 72px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(139, 41, 66, 0.2), 0 0 0 1px rgba(139, 41, 66, 0.05);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    backdrop-filter: blur(10px);
}

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

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--color-primary, #8B2942) 0%, var(--color-primary-dark, #6B1F32) 100%);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

.chatbot-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chatbot-avatar svg {
    width: 24px;
    height: 24px;
}

.chatbot-header-text {
    color: white;
}

.chatbot-title {
    font-family: var(--font-serif, 'Playfair Display', serif);
    font-size: 19px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.chatbot-subtitle {
    font-size: 13px;
    opacity: 0.95;
    margin: 0;
    margin-top: 3px;
    font-weight: 400;
    letter-spacing: 0.01em;
}

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

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

.chatbot-close svg {
    width: 18px;
    height: 18px;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--color-background, #FDFCFB);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--color-gray-medium, #E5E5E5);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, #6B6B6B);
}

/* Message Bubbles */
.chatbot-message {
    display: flex;
    animation: chatbotFadeIn 0.3s ease;
}

.chatbot-message-bot {
    justify-content: flex-start;
}

.chatbot-message-user {
    justify-content: flex-end;
}

.chatbot-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chatbot-message-bot .chatbot-message-content {
    background: linear-gradient(135deg, var(--color-accent-light, #FAF6F0) 0%, rgba(201, 169, 98, 0.08) 100%);
    color: var(--color-text-primary, #2D2D2D);
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(201, 169, 98, 0.15);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
}

.chatbot-message-user .chatbot-message-content {
    background: linear-gradient(135deg, var(--color-primary, #8B2942) 0%, var(--color-primary-dark, #6B1F32) 100%);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(139, 41, 66, 0.2);
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.chatbot-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted, #6B6B6B);
    animation: chatbotTyping 1.4s ease-in-out infinite;
}

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

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

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

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

/* Options Container */
.chatbot-options {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid var(--color-gray-medium, #E5E5E5);
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 240px;
    overflow-y: auto;
}

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

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

.chatbot-options::-webkit-scrollbar-thumb {
    background: var(--color-gray-medium, #E5E5E5);
    border-radius: 3px;
}

/* Option Buttons */
.chatbot-option-btn {
    width: 100%;
    padding: 14px 18px;
    background: white;
    border: 1.5px solid var(--color-primary, #8B2942);
    color: var(--color-primary, #8B2942);
    border-radius: 10px;
    font-family: var(--font-sans, 'DM Sans', sans-serif);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chatbot-option-btn::after {
    content: '';
    position: absolute;
    right: 18px;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-top: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.3s ease;
}

.chatbot-option-btn:hover {
    background: linear-gradient(135deg, var(--color-primary, #8B2942) 0%, var(--color-primary-dark, #6B1F32) 100%);
    color: white;
    transform: translateX(6px);
    box-shadow: 0 6px 20px rgba(139, 41, 66, 0.25);
    border-color: var(--color-primary-dark, #6B1F32);
}

.chatbot-option-btn:hover::after {
    transform: rotate(45deg) translate(2px, -2px);
}

.chatbot-option-btn:active {
    transform: translateX(3px);
}

/* Info Content */
.chatbot-info {
    padding: 16px;
    background: var(--color-accent-light, #FAF6F0);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-primary, #2D2D2D);
}

.chatbot-info-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-primary, #2D2D2D);
}

.chatbot-info-content ul,
.chatbot-info-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.chatbot-info-content li {
    margin: 8px 0;
}

.chatbot-info-content strong {
    color: var(--color-primary, #8B2942);
    font-weight: 600;
}

.chatbot-info-content a {
    color: var(--color-primary, #8B2942);
    text-decoration: none;
    font-weight: 600;
}

.chatbot-info-content a:hover {
    text-decoration: underline;
}

.chatbot-product-recommendations {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--color-gray-medium, #E5E5E5);
}

.chatbot-product-recommendations ul {
    list-style: none;
    padding-left: 0;
}

.chatbot-product-recommendations li {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-gray-light, #F5F5F5);
}

.chatbot-product-recommendations li:last-child {
    border-bottom: none;
}

.chatbot-note {
    margin-top: 12px;
    padding: 12px;
    background: rgba(201, 169, 98, 0.1);
    border-left: 3px solid var(--color-accent, #C9A962);
    border-radius: 4px;
    font-size: 13px;
    font-style: italic;
}

/* Link Button */
.chatbot-link-btn {
    display: inline-block;
    width: 100%;
    padding: 12px 16px;
    background: var(--color-primary, #8B2942);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: var(--font-sans, 'DM Sans', sans-serif);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chatbot-link-btn:hover {
    background: var(--color-primary-dark, #6B1F32);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 41, 66, 0.3);
}

/* Back Button */
.chatbot-back {
    padding: 12px 20px;
    background: var(--color-gray-light, #F5F5F5);
    border-top: 1px solid var(--color-gray-medium, #E5E5E5);
}

.chatbot-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 2px solid var(--color-gray-medium, #E5E5E5);
    color: var(--color-text-primary, #2D2D2D);
    border-radius: 8px;
    font-family: var(--font-sans, 'DM Sans', sans-serif);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chatbot-back-btn:hover {
    border-color: var(--color-primary, #8B2942);
    color: var(--color-primary, #8B2942);
    transform: translateX(-4px);
}

.chatbot-back-btn svg {
    width: 18px;
    height: 18px;
}

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

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

    .chatbot-fab-row {
        gap: 10px;
    }

    .chatbot-whatsapp-fab {
        width: 56px;
        height: 56px;
    }

    .chatbot-whatsapp-icon {
        width: 30px;
        height: 30px;
    }

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

    .chatbot-icon {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        left: 0;
        right: auto;
        border-radius: 0;
    }

    .chatbot-messages {
        padding: 16px;
    }

    .chatbot-options {
        padding: 12px 16px;
    }
}

/* Accessibility */
.chatbot-whatsapp-fab:focus,
.chatbot-toggle:focus,
.chatbot-close:focus,
.chatbot-option-btn:focus,
.chatbot-back-btn:focus {
    outline: 2px solid var(--color-accent, #C9A962);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .chatbot-container {
        display: none;
    }
}

/* Product PDP: lift FABs above sticky buy bar (mobile always; desktop when strip is revealed) */
@media (max-width: 1023px) {
    body.page-pdp-mobile-sticky .chatbot-container {
        bottom: calc(7.25rem + env(safe-area-inset-bottom, 0px) + 12px);
        left: max(12px, env(safe-area-inset-left, 0px));
        right: auto;
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    body.page-pdp-mobile-sticky .chatbot-container {
        bottom: calc(7.25rem + env(safe-area-inset-bottom, 0px) + 12px);
    }
}

@media (min-width: 1024px) {
    body.page-pdp-mobile-sticky .chatbot-container {
        bottom: 24px;
        left: 24px;
        right: auto;
    }

    body.page-pdp-mobile-sticky.pdp-sticky-foot-revealed .chatbot-container {
        bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px) + 16px);
        left: max(24px, env(safe-area-inset-left, 0px));
        right: auto;
    }
}

/* Back to top — bottom-right */
.back-to-top-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-dark, #041F57);
    color: #fff;
    box-shadow: 0 8px 28px rgba(4, 31, 87, 0.35), 0 4px 12px rgba(4, 31, 87, 0.2);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(14px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.back-to-top-fab--visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.back-to-top-fab:hover {
    background: var(--color-brand-green, #155225);
    box-shadow: 0 12px 32px rgba(21, 82, 37, 0.35), 0 6px 16px rgba(21, 82, 37, 0.2);
    transform: translateY(-3px);
}

.back-to-top-fab--visible:hover {
    transform: translateY(-3px);
}

.back-to-top-fab svg {
    width: 22px;
    height: 22px;
    display: block;
}

@media (max-width: 768px) {
    .back-to-top-fab {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .back-to-top-fab svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 1023px) {
    body.page-pdp-mobile-sticky .back-to-top-fab {
        bottom: calc(7.25rem + env(safe-area-inset-bottom, 0px) + 12px);
        right: max(12px, env(safe-area-inset-right, 0px));
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    body.page-pdp-mobile-sticky .back-to-top-fab {
        bottom: calc(7.25rem + env(safe-area-inset-bottom, 0px) + 12px);
    }
}

@media (min-width: 1024px) {
    body.page-pdp-mobile-sticky.pdp-sticky-foot-revealed .back-to-top-fab {
        bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px) + 16px);
        right: max(24px, env(safe-area-inset-right, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .back-to-top-fab {
        transition: opacity 0.15s ease, visibility 0.15s ease;
    }
}

.back-to-top-fab:focus {
    outline: 2px solid var(--color-accent, #155225);
    outline-offset: 2px;
}

@media print {
    .back-to-top-fab {
        display: none;
    }
}


