/**
 * Zendesk Live Chat Launcher Styles
 *
 * Scoped styling for the floating Zendesk chat launcher button and widget integration.
 * Aligned with Zoca's brand chrome palette (deep navy / white contrast / Lucide iconography).
 *
 * @package Storefront_Child_New
 */

/* ==========================================================================
   1. Floating Chat Launcher (FAB / Pill)
   ========================================================================== */

.zc-chat-launcher,
#loadZendesk.chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    min-width: 46px;
    padding: 0 18px 0 14px;
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background-color: #0a1b29;
    color: #ffffff !important;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(10, 27, 41, 0.24), 0 2px 6px rgba(10, 27, 41, 0.12);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s ease,
                background-color 0.2s ease,
                border-color 0.2s ease,
                opacity 0.2s ease,
                visibility 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.zc-chat-launcher:hover,
#loadZendesk.chat-launcher:hover {
    background-color: #123a57;
    border-color: rgba(255, 255, 255, 0.28);
    color: #ffffff !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 22px rgba(10, 27, 41, 0.32), 0 3px 8px rgba(10, 27, 41, 0.16);
}

.zc-chat-launcher:active,
#loadZendesk.chat-launcher:active {
    background-color: #07131d;
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(10, 27, 41, 0.2);
}

.zc-chat-launcher:focus-visible,
#loadZendesk.chat-launcher:focus-visible {
    outline: 2px solid #199ae8;
    outline-offset: 3px;
}

/* ==========================================================================
   2. Icons & Sub-elements
   ========================================================================== */

.zc-chat-launcher__icon,
#loadZendesk .chat-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: #ffffff;
}

.zc-chat-launcher__icon svg,
#loadZendesk .chat-icon-wrapper svg {
    display: block;
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.zc-chat-launcher__text,
#loadZendesk .chat-text {
    display: inline-block;
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

/* Spinner element for loading state */
.zc-chat-launcher__spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: zc-zen-spin 0.75s linear infinite;
    flex-shrink: 0;
}

/* ==========================================================================
   3. Interactive States (Loading, Hidden, Disabled)
   ========================================================================== */

.zc-chat-launcher.is-loading,
#loadZendesk.is-loading {
    pointer-events: none;
    opacity: 0.92;
    cursor: wait;
}

.zc-chat-launcher.is-loading .zc-chat-launcher__icon,
#loadZendesk.is-loading .chat-icon-wrapper {
    display: none;
}

.zc-chat-launcher.is-loading .zc-chat-launcher__spinner {
    display: inline-block;
}

/* Complete removal from layout & visibility when hidden */
.zc-chat-launcher.hidden,
#loadZendesk.hidden,
.chat-launcher.hidden,
.zc-chat-launcher[hidden],
#loadZendesk[hidden] {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Keep the purchase drawer's primary actions unobstructed. */
body.zoca-purchase-open #loadZendesk,
body.zoca-purchase-open .zc-chat-launcher {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.zc-chat-launcher:disabled,
#loadZendesk:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ==========================================================================
   4. Responsive & Viewport Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .zc-chat-launcher,
    #loadZendesk.chat-launcher {
        bottom: max(20px, env(safe-area-inset-bottom, 20px));
        right: max(16px, env(safe-area-inset-right, 16px));
        height: 44px;
        min-width: 44px;
        padding: 0 16px 0 12px;
        font-size: 13.5px;
    }
}

/* Lift above PDP mobile sticky purchase dock when active */
body.zoca-pdp-mobile-bar-visible .zc-chat-launcher,
body.zoca-pdp-mobile-bar-visible #loadZendesk,
body.zoca-pdp-mobile-bar-visible #launcher {
    bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
}

/* ==========================================================================
   5. Keyframes & Accessibility
   ========================================================================== */

@keyframes zc-zen-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .zc-chat-launcher,
    #loadZendesk.chat-launcher,
    .zc-chat-launcher__spinner {
        transition: none !important;
        animation-duration: 0.01ms !important;
    }
}
