/* ==========================================================================
   Flash7 WooCommerce Agent — Public CSS
   Exact visual clone of the Flash7 SaaS chatbot:
   - Dark background #000 with orange/blue radial gradients
   - 3D Flip-Page open/close keyframes (perspective 800px rotateY)
   - Line-by-line zoom-out text reveal (scale 14 → 1)
   - Drag cursor on header
   - Orange FAB (#FF6B00)
   - Resize handles (left edge + top-left corner)
   - Pulsing glow on logo while AI thinks
   - Bouncing dots typing indicator
   ========================================================================== */

/* ─── Google Font ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Root tokens ─────────────────────────────────────────────────────────── */
:root {
    --f7-orange: #FF6B00;
    --f7-orange-dim: rgba(255, 107, 0, 0.55);
    --f7-blue-dim: rgba(20, 73, 148, 0.65);
    --f7-white-10: rgba(255, 255, 255, 0.10);
    --f7-white-20: rgba(255, 255, 255, 0.20);
    --f7-radius: 2rem;
    --f7-shadow: 0 32px 64px rgba(0,0,0,0.55), 0 8px 24px rgba(255,107,0,0.12);
    --f7-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ─── Wrapper ─────────────────────────────────────────────────────────────── */
#flash7-agent-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--f7-font);
}

/* ─── FAB ────────────────────────────────────────────────────────────────── */
#flash7-fab {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 1.25rem;
    background: var(--f7-orange);
    color: white;
    border: 2px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px rgba(255,107,0,0.45), 0 2px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275), box-shadow 0.3s ease;
    outline: none;
}

#flash7-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 40px rgba(255,107,0,0.6);
}

#flash7-fab:active {
    transform: scale(0.94);
}

/* "Need help?" bubble */
#flash7-help-bubble {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    background: #1a1a1a;
    color: white;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.12);
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    pointer-events: none;
}

/* ─── Animations ─────────────────────────────────────────────────────────── */

/* 3D Flip-Page OPEN — matches SaaS chatbotFlipPageOpen exactly */
@keyframes flash7FlipPageOpen {
    0% {
        opacity: 0;
        transform-origin: 50% 0;
        transform: perspective(800px) rotateY(180deg) translateZ(300px);
    }
    100% {
        opacity: 1;
        transform-origin: 0 0;
        transform: perspective(800px) rotateY(0deg) translateZ(0px);
    }
}

/* 3D Flip-Page CLOSE */
@keyframes flash7FlipPageClose {
    0% {
        opacity: 1;
        transform-origin: 0 0;
        transform: perspective(800px) rotateY(0deg) translateZ(0px);
    }
    100% {
        opacity: 0;
        transform-origin: 50% 0;
        transform: perspective(800px) rotateY(180deg) translateZ(300px);
    }
}

.flash7-open-anim {
    animation: flash7FlipPageOpen 1.3s both;
    transform-style: preserve-3d;
}

.flash7-close-anim {
    animation: flash7FlipPageClose 1.0s both;
    transform-style: preserve-3d;
}

/* FAB bounce */
@keyframes flash7Bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-12px); }
}

.flash7-bounce-elegant {
    animation: flash7Bounce 2.2s infinite;
}

/* Line-by-line zoom-out text reveal — matches SaaS chatbotZoomOutText exactly */
@keyframes flash7ZoomOutText {
    0%   { opacity: 0; transform: scale(14); }
    100% { opacity: 1; transform: scale(1); }
}

.flash7-msg-line {
    display: block;
    opacity: 0;
    animation: flash7ZoomOutText 0.3s cubic-bezier(0.0, 0.55, 0.45, 1) forwards;
    margin-bottom: 4px;
    transform-origin: center center;
}

/* Typing dots bounce */
@keyframes flash7DotBounce {
    0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
    40%           { transform: scale(1); opacity: 1; }
}

/* Logo pulse glow while AI is thinking */
@keyframes flash7LogoGlow {
    0%   { filter: drop-shadow(0 0 0px rgba(255,107,0,0)); }
    50%  { filter: drop-shadow(0 0 10px rgba(255,107,0,0.9)); }
    100% { filter: drop-shadow(0 0 0px rgba(255,107,0,0)); }
}

.flash7-logo-thinking {
    animation: flash7LogoGlow 1.5s infinite ease-in-out;
}

/* Tooltip zoom in */
@keyframes flash7TooltipIn {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}

/* ─── Chat Card ───────────────────────────────────────────────────────────── */
#flash7-chat-card {
    /* Positioned by JS, but base styles here */
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--f7-radius);
    border: 1px solid var(--f7-white-20);
    box-shadow: var(--f7-shadow);
    background-color: #000000;
    color: white;
    font-family: var(--f7-font);
    z-index: 999998;
    /* Gradient background — matches SaaS exactly but with custom color support */
    background-image:
        radial-gradient(ellipse at 50% 15%, rgba(0,0,0,0.9) 0%, transparent 70%),
        radial-gradient(ellipse at 20% 80%, color-mix(in srgb, var(--f7-grad-1) 60%, transparent) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, color-mix(in srgb, var(--f7-grad-2) 65%, transparent) 0%, transparent 60%),
        radial-gradient(ellipse at 40% 30%, color-mix(in srgb, var(--f7-orange) 50%, transparent) 0%, transparent 70%);
}

/* ─── Resize handles ─────────────────────────────────────────────────────── */
#flash7-resize-corner {
    position: absolute;
    left: 0;
    top: 0;
    width: 16px;
    height: 16px;
    cursor: nw-resize;
    touch-action: none;
    z-index: 10;
}

#flash7-resize-left {
    position: absolute;
    left: 0;
    top: 16px;
    bottom: 0;
    width: 12px;
    cursor: ew-resize;
    touch-action: none;
    z-index: 10;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */
#flash7-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--f7-white-10);
    background: rgba(0,0,0,0.4);
    cursor: move;
    border-radius: var(--f7-radius) var(--f7-radius) 0 0;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
}

#flash7-logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
    flex-shrink: 0;
    transition: filter 0.3s;
}

.flash7-header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-grow: 1;
}

.flash7-status-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.6);
    background: rgba(16, 185, 129, 0.9); /* emerald-500 */
    flex-shrink: 0;
}

.flash7-status-check svg {
    width: 14px;
    height: 14px;
    stroke: white;
    stroke-width: 3;
    fill: none;
}

.flash7-status-labels {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.flash7-status-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.08);
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.2;
}

.flash7-header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* Icon buttons in header */
.flash7-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(0,0,0,0.3);
    color: white;
    cursor: pointer;
    transition: background 0.2s;
    pointer-events: auto;
    padding: 0;
    outline: none;
}

.flash7-icon-btn:hover {
    background: rgba(255,255,255,0.1);
}

.flash7-icon-btn.f7-orange-btn {
    border-color: rgba(255,107,0,0.4);
}

.flash7-icon-btn.f7-orange-btn:hover {
    background: rgba(255,107,0,0.2);
    color: #FF8C38;
}

.flash7-icon-btn.f7-danger-btn {
    border-color: rgba(239,68,68,0.3);
}

.flash7-icon-btn.f7-danger-btn:hover {
    background: rgba(239,68,68,0.2);
    color: #f87171;
}

#flash7-close-btn {
    font-size: 22px;
    font-weight: 300;
    opacity: 0.7;
    transition: opacity 0.2s;
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

#flash7-close-btn:hover {
    opacity: 1;
}

/* ─── Chat Body ───────────────────────────────────────────────────────────── */
#flash7-chat-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
#flash7-chat-body::-webkit-scrollbar {
    width: 4px;
}
#flash7-chat-body::-webkit-scrollbar-track {
    background: transparent;
}
#flash7-chat-body::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

/* ─── Messages ───────────────────────────────────────────────────────────── */
.flash7-message {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
    animation: flash7MsgIn 0.4s cubic-bezier(0.175,0.885,0.32,1.1) forwards;
    opacity: 0;
}

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

.flash7-msg-user {
    align-self: flex-end;
    background: var(--f7-orange);
    color: white;
    border-bottom-right-radius: 4px;
}

.flash7-msg-ai {
    align-self: flex-start;
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-bottom-left-radius: 4px;
    font-weight: 300;
}

.flash7-msg-ai strong {
    font-weight: 600;
    color: rgba(255,165,100,0.95);
}

.flash7-msg-ai em {
    font-style: italic;
    color: rgba(255,255,255,0.9);
}

/* ─── Typing indicator ───────────────────────────────────────────────────── */
.flash7-typing-indicator {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 14px 18px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.flash7-dot {
    width: 8px;
    height: 8px;
    background: rgba(255,107,0,0.8);
    border-radius: 50%;
    animation: flash7DotBounce 1.4s infinite ease-in-out both;
}

.flash7-dot:nth-child(1) { animation-delay: -0.32s; }
.flash7-dot:nth-child(2) { animation-delay: -0.16s; }
.flash7-dot:nth-child(3) { animation-delay: 0s; }

/* ─── Chat Footer ────────────────────────────────────────────────────────── */
#flash7-chat-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--f7-white-10);
    background: rgba(0,0,0,0.5);
    flex-shrink: 0;
}

#flash7-chat-input {
    flex-grow: 1;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 15px;
    color: white;
    font-family: var(--f7-font);
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}

#flash7-chat-input::placeholder {
    color: rgba(255,255,255,0.35);
}

#flash7-chat-input:focus {
    border-color: var(--f7-orange);
    box-shadow: 0 0 0 3px rgba(255,107,0,0.15);
}

#flash7-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--f7-orange);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: filter 0.2s, transform 0.2s;
    outline: none;
}

#flash7-send-btn:hover {
    filter: brightness(1.15);
    transform: scale(1.06);
}

#flash7-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Navigation consent bar (Take me there) ─────────────────────────────── */
.flash7-consent-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-top: 1px solid rgba(255,107,0,0.2);
    background: rgba(255,107,0,0.08);
    flex-shrink: 0;
}

.flash7-consent-bar button {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: filter 0.2s;
}

.flash7-consent-yes {
    background: var(--f7-orange);
    color: white;
}

.flash7-consent-no {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
}

/* ─── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 639px) {
    #flash7-chat-card {
        left: 12px !important;
        width: calc(100vw - 24px) !important;
        max-width: none !important;
        bottom: 0 !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }

    #flash7-agent-wrapper {
        bottom: 20px;
        right: 20px;
    }
}

/* ─── Product Card ───────────────────────────────────────────────────────── */
.f7-product-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 14px;
    margin-top: 10px;
    margin-bottom: 10px;
    display: grid;
    grid-template-columns: 130px 1fr;
    grid-template-areas:
        "img price"
        "img desc"
        "title btns";
    gap: 8px 16px;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.f7-product-card > br { display: none; }

.f7-grid-img { grid-area: img; display: flex; align-items: center; justify-content: center; }
.f7-grid-title { grid-area: title; text-decoration: none; color: inherit; text-align: center; }
.f7-grid-price { grid-area: price; align-self: end; }
.f7-grid-desc { grid-area: desc; align-self: start; }
.f7-grid-btns { grid-area: btns; }

/* Grid View Modifier (Vertical Single Column) */
.f7-grid-view .f7-product-card {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "img"
        "title"
        "price"
        "desc"
        "btns";
    width: 100%;
    margin-top: 10px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.f7-grid-view .f7-grid-title { text-align: left; }

.f7-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    border-color: rgba(255,107,0,0.3);
}

.f7-product-card img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
    padding: 8px;
}

.f7-grid-title h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.f7-price {
    font-size: 14px;
    font-weight: 700;
    color: #FFB76F;
}

.f7-grid-desc {
    margin: 0;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    line-height: 1.4;
}

.f7-btn-group {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.f7-view-btn, .f7-add-cart-btn {
    flex: 1;
    padding: 8px 16px;
    background: rgba(255,107,0,0.15);
    color: #ff8c38;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    text-align: center;
    transition: background 0.2s, color 0.2s;
    border: 1px solid rgba(255,107,0,0.2);
}

.f7-add-cart-btn {
    background: var(--f7-orange);
    color: white;
    border: 1px solid var(--f7-orange);
}

.f7-view-btn:hover, .f7-add-cart-btn:hover {
    background: #e66000;
    color: white;
}
