/**
 * Product Q&A - AI Chat Interface
 * Styled to match Owleys product sidebar
 */

/* === CONTAINER === */
.owleys-qa-block {
    background: transparent;
    padding: 0;
    margin: 32px 0;
}

/* === HEADER === */
.owleys-qa-header {
    margin-bottom: 16px;
}

.owleys-qa-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: Cabin, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: var(--clr-prod-title, #1a1a1a);
    margin: 0;
}

.owleys-qa-badge {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    gap: 4px;
    background: linear-gradient(135deg, #ff8338 0%, #ff9a5a 100%);
    color: #fff;
    font-family: Cabin, sans-serif;
    font-size: 9px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.owleys-qa-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.25) 50%,
        transparent 100%
    );
    animation: qa-badge-shimmer 3s ease-in-out infinite;
}

@keyframes qa-badge-shimmer {
    0% {
        left: -100%;
    }
    50%, 100% {
        left: 150%;
    }
}

.owleys-qa-ai-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19 20'%3E%3Cpath d='M12.34 7.36L10.54 6.76C9.4 6.38 8.51 5.47 8.14 4.33L7.54 2.5C7.44 2.2 7.16 2 6.85 2C6.54 2 6.26 2.2 6.17 2.5L5.57 4.33C5.19 5.47 4.3 6.38 3.17 6.76L1.36 7.36C1.07 7.46 0.87 7.74 0.87 8.06C0.87 8.37 1.07 8.65 1.36 8.75L3.17 9.36C4.3 9.74 5.19 10.64 5.57 11.79L6.17 13.61C6.27 13.91 6.54 14.11 6.85 14.11C7.16 14.11 7.44 13.91 7.54 13.61L8.14 11.79C8.51 10.64 9.4 9.74 10.54 9.36L12.34 8.75C12.64 8.65 12.83 8.37 12.83 8.06C12.83 7.74 12.63 7.46 12.34 7.36ZM13.12 15.2L13.46 16.23C13.51 16.39 13.66 16.5 13.84 16.5C14.02 16.5 14.17 16.39 14.22 16.23L14.56 15.2C14.77 14.56 15.27 14.06 15.9 13.84L16.91 13.51C17.08 13.45 17.19 13.29 17.19 13.12C17.19 12.94 17.07 12.78 16.91 12.73L15.9 12.39C15.27 12.17 14.77 11.67 14.56 11.03L14.22 10.01C14.17 9.84 14.02 9.73 13.84 9.73C13.66 9.73 13.51 9.84 13.46 10.01L13.12 11.03C12.91 11.67 12.41 12.18 11.78 12.39L10.77 12.73C10.6 12.78 10.49 12.94 10.49 13.12C10.49 13.29 10.61 13.45 10.77 13.51L11.78 13.84C12.41 14.06 12.91 14.56 13.12 15.2Z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19 20'%3E%3Cpath d='M12.34 7.36L10.54 6.76C9.4 6.38 8.51 5.47 8.14 4.33L7.54 2.5C7.44 2.2 7.16 2 6.85 2C6.54 2 6.26 2.2 6.17 2.5L5.57 4.33C5.19 5.47 4.3 6.38 3.17 6.76L1.36 7.36C1.07 7.46 0.87 7.74 0.87 8.06C0.87 8.37 1.07 8.65 1.36 8.75L3.17 9.36C4.3 9.74 5.19 10.64 5.57 11.79L6.17 13.61C6.27 13.91 6.54 14.11 6.85 14.11C7.16 14.11 7.44 13.91 7.54 13.61L8.14 11.79C8.51 10.64 9.4 9.74 10.54 9.36L12.34 8.75C12.64 8.65 12.83 8.37 12.83 8.06C12.83 7.74 12.63 7.46 12.34 7.36ZM13.12 15.2L13.46 16.23C13.51 16.39 13.66 16.5 13.84 16.5C14.02 16.5 14.17 16.39 14.22 16.23L14.56 15.2C14.77 14.56 15.27 14.06 15.9 13.84L16.91 13.51C17.08 13.45 17.19 13.29 17.19 13.12C17.19 12.94 17.07 12.78 16.91 12.73L15.9 12.39C15.27 12.17 14.77 11.67 14.56 11.03L14.22 10.01C14.17 9.84 14.02 9.73 13.84 9.73C13.66 9.73 13.51 9.84 13.46 10.01L13.12 11.03C12.91 11.67 12.41 12.18 11.78 12.39L10.77 12.73C10.6 12.78 10.49 12.94 10.49 13.12C10.49 13.29 10.61 13.45 10.77 13.51L11.78 13.84C12.41 14.06 12.91 14.56 13.12 15.2Z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

/* === QUESTION CHIPS === */
.owleys-qa-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.owleys-qa-question-btn {
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 20px;
    padding: 8px 14px;
    font-family: Cabin, sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.owleys-qa-question-btn:hover {
    background: #fff;
    border-color: #ff8338;
    color: #ff8338;
}

.owleys-qa-question-btn.used {
    opacity: 0.4;
    pointer-events: none;
}

/* AI-generated question - same style as others, just with icon */
.owleys-qa-question-ai {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.owleys-qa-question-ai:hover {
    background: #fff;
    border-color: #ff8338;
}

.owleys-qa-ai-spark {
    display: inline-block;
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    vertical-align: middle;
    background-color: #ff8338;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19 20'%3E%3Cpath d='M12.34 7.36L10.54 6.76C9.4 6.38 8.51 5.47 8.14 4.33L7.54 2.5C7.44 2.2 7.16 2 6.85 2C6.54 2 6.26 2.2 6.17 2.5L5.57 4.33C5.19 5.47 4.3 6.38 3.17 6.76L1.36 7.36C1.07 7.46 0.87 7.74 0.87 8.06C0.87 8.37 1.07 8.65 1.36 8.75L3.17 9.36C4.3 9.74 5.19 10.64 5.57 11.79L6.17 13.61C6.27 13.91 6.54 14.11 6.85 14.11C7.16 14.11 7.44 13.91 7.54 13.61L8.14 11.79C8.51 10.64 9.4 9.74 10.54 9.36L12.34 8.75C12.64 8.65 12.83 8.37 12.83 8.06C12.83 7.74 12.63 7.46 12.34 7.36ZM13.12 15.2L13.46 16.23C13.51 16.39 13.66 16.5 13.84 16.5C14.02 16.5 14.17 16.39 14.22 16.23L14.56 15.2C14.77 14.56 15.27 14.06 15.9 13.84L16.91 13.51C17.08 13.45 17.19 13.29 17.19 13.12C17.19 12.94 17.07 12.78 16.91 12.73L15.9 12.39C15.27 12.17 14.77 11.67 14.56 11.03L14.22 10.01C14.17 9.84 14.02 9.73 13.84 9.73C13.66 9.73 13.51 9.84 13.46 10.01L13.12 11.03C12.91 11.67 12.41 12.18 11.78 12.39L10.77 12.73C10.6 12.78 10.49 12.94 10.49 13.12C10.49 13.29 10.61 13.45 10.77 13.51L11.78 13.84C12.41 14.06 12.91 14.56 13.12 15.2Z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 19 20'%3E%3Cpath d='M12.34 7.36L10.54 6.76C9.4 6.38 8.51 5.47 8.14 4.33L7.54 2.5C7.44 2.2 7.16 2 6.85 2C6.54 2 6.26 2.2 6.17 2.5L5.57 4.33C5.19 5.47 4.3 6.38 3.17 6.76L1.36 7.36C1.07 7.46 0.87 7.74 0.87 8.06C0.87 8.37 1.07 8.65 1.36 8.75L3.17 9.36C4.3 9.74 5.19 10.64 5.57 11.79L6.17 13.61C6.27 13.91 6.54 14.11 6.85 14.11C7.16 14.11 7.44 13.91 7.54 13.61L8.14 11.79C8.51 10.64 9.4 9.74 10.54 9.36L12.34 8.75C12.64 8.65 12.83 8.37 12.83 8.06C12.83 7.74 12.63 7.46 12.34 7.36ZM13.12 15.2L13.46 16.23C13.51 16.39 13.66 16.5 13.84 16.5C14.02 16.5 14.17 16.39 14.22 16.23L14.56 15.2C14.77 14.56 15.27 14.06 15.9 13.84L16.91 13.51C17.08 13.45 17.19 13.29 17.19 13.12C17.19 12.94 17.07 12.78 16.91 12.73L15.9 12.39C15.27 12.17 14.77 11.67 14.56 11.03L14.22 10.01C14.17 9.84 14.02 9.73 13.84 9.73C13.66 9.73 13.51 9.84 13.46 10.01L13.12 11.03C12.91 11.67 12.41 12.18 11.78 12.39L10.77 12.73C10.6 12.78 10.49 12.94 10.49 13.12C10.49 13.29 10.61 13.45 10.77 13.51L11.78 13.84C12.41 14.06 12.91 14.56 13.12 15.2Z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    animation: qa-spark-pulse 2s ease-in-out infinite;
}

@keyframes qa-spark-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === CHAT CONTAINER === */
.owleys-qa-chat {
    background: #fafafa;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    max-height: 480px;
    overflow-y: auto;
    scroll-behavior: smooth;
    border: 1px solid #eee;
}

.owleys-qa-chat:empty {
    display: none !important;
    margin: 0;
    padding: 0;
    min-height: 0;
    border: none;
}

/* Hide chat when no messages */
.owleys-qa-chat:not(:has(.owleys-qa-message)) {
    display: none !important;
}

/* === MESSAGE BUBBLES === */
.owleys-qa-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: qaSlideIn 0.3s ease;
}

.owleys-qa-message:last-child {
    margin-bottom: 0;
}

@keyframes qaSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User message - right aligned */
.owleys-qa-message.user {
    flex-direction: row-reverse;
}

.owleys-qa-message.user .owleys-qa-bubble {
    background: #ff8338;
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}

.owleys-qa-message.user .owleys-qa-bubble p {
    margin: 0;
    font-weight: 500;
}

/* AI message - left aligned */
.owleys-qa-message.ai {
    align-items: flex-start;
}

.owleys-qa-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    background: url('https://owleys.com/wp-content/uploads/2025/11/555822863_17848221642570460_3151353561849583456_n.jpg') center center / cover no-repeat;
    border: 2px solid #ff8338;
}

.owleys-qa-bubble {
    background: #fff;
    border-radius: 16px 16px 16px 4px;
    padding: 12px 14px;
    max-width: calc(100% - 44px);
    font-family: Cabin, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    border: 1px solid #eee;
}

.owleys-qa-bubble p {
    margin: 0 0 10px;
}

.owleys-qa-bubble p:last-child {
    margin-bottom: 0;
}

.owleys-qa-bubble strong {
    color: #1a1a1a;
    font-weight: 600;
}

.owleys-qa-bubble ul,
.owleys-qa-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.owleys-qa-bubble li {
    margin-bottom: 4px;
}

.owleys-qa-bubble a {
    color: #ff8338;
    text-decoration: none;
}

.owleys-qa-bubble a:hover {
    text-decoration: underline;
}

/* Product recommendation links - colored text with underline */
.owleys-qa-bubble a.qa-product-link {
    color: #e85a00;
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(232, 90, 0, 0.3);
    text-underline-offset: 2px;
    transition: all 0.15s ease;
}

.owleys-qa-bubble a.qa-product-link:hover {
    color: #ff8338;
    text-decoration-color: #ff8338;
}

.owleys-qa-bubble a.qa-product-link strong {
    color: inherit;
    font-weight: 700;
}

/* === TYPING INDICATOR === */
.owleys-qa-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.owleys-qa-typing span {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: qaTypingBounce 1.4s ease-in-out infinite;
}

.owleys-qa-typing span:nth-child(1) { animation-delay: 0s; }
.owleys-qa-typing span:nth-child(2) { animation-delay: 0.15s; }
.owleys-qa-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes qaTypingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        background: #ccc;
    }
    30% {
        transform: translateY(-5px);
        background: #ff8338;
    }
}

/* === INPUT AREA === */
/* Form reset */
form.owleys-qa-input-wrap {
    margin: 0;
}

.owleys-qa-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: all 0.2s ease;
}

.owleys-qa-input-wrap:focus-within {
    background: #fff;
    border-color: #ff8338;
}

.owleys-qa-input {
    flex: 1;
    border: none;
    padding: 10px 0;
    font-family: Cabin, sans-serif;
    font-size: 16px; /* Prevents iOS zoom on focus */
    outline: none;
    background: transparent;
    min-width: 0;
    color: #333;
    touch-action: manipulation;
}

.owleys-qa-input::placeholder {
    color: #999;
}

.owleys-qa-submit {
    background: #fff;
    border: 1px solid #ff8338;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.owleys-qa-submit:hover {
    background: #ff8338;
}

.owleys-qa-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.owleys-qa-submit svg {
    width: 16px;
    height: 16px;
    stroke: #ff8338;
    transition: stroke 0.2s ease;
}

.owleys-qa-submit:hover svg {
    stroke: #fff;
}

/* === DISCLAIMER === */
.owleys-qa-disclaimer {
    font-family: Cabin, sans-serif;
    font-size: 11px;
    color: #999;
    margin: 12px 0 0;
    text-align: center;
}

/* === MOBILE === */
@media (max-width: 767px) {
    .owleys-qa-block {
        margin: 20px 0 0;
    }
    
    .owleys-qa-title {
        font-size: 20px;
    }
    
    .owleys-qa-questions {
        gap: 6px;
        flex-wrap: wrap;
        margin: 0 0 16px;
    }
    
    .owleys-qa-question-btn {
        padding: 7px 12px;
        font-size: 14px;
        white-space: normal;
    }
    
    .owleys-qa-chat {
        max-height: 400px;
        padding: 12px;
    }
    
    .owleys-qa-avatar {
        width: 28px;
        height: 28px;
    }
    
    .owleys-qa-bubble {
        padding: 10px 12px;
        font-size: 13px;
        max-width: calc(100% - 40px);
    }
    
    .owleys-qa-input-wrap {
        padding: 3px 3px 3px 14px;
    }
    
    .owleys-qa-submit {
        width: 32px;
        height: 32px;
    }
    
    .owleys-qa-submit svg {
        width: 14px;
        height: 14px;
    }
}

/* === ACCESSIBILITY === */
.owleys-qa-question-btn:focus,
.owleys-qa-submit:focus {
    outline: 2px solid #ff8338;
    outline-offset: 2px;
}

.owleys-qa-question-btn:focus:not(:focus-visible),
.owleys-qa-submit:focus:not(:focus-visible) {
    outline: none;
}

.owleys-qa-input:focus {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    .owleys-qa-message,
    .owleys-qa-typing span {
        animation: none;
    }
}

/* Accessibility - visually hidden but screen reader accessible */
.owleys-qa-block .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Subscribe Form in Q&A answers - compact version - isolated from nicelabel */
.owleys-qa-block .owleys-qa-bubble .owleys-qa-subscribe-form,
.owleys-qa-block .owleys-qa-subscribe-form {
    background: linear-gradient(135deg, #fff8f5 0%, #fff 100%) !important;
    border: 1px solid #ffe4d6 !important;
    border-radius: 10px !important;
    padding: 12px !important;
    margin: 10px 0 4px !important;
    all: unset !important;
    display: block !important;
    background: linear-gradient(135deg, #fff8f5 0%, #fff 100%) !important;
    border: 1px solid #ffe4d6 !important;
    border-radius: 10px !important;
    padding: 12px !important;
    margin: 10px 0 4px !important;
    box-sizing: border-box !important;
}

.owleys-qa-block .owleys-qa-bubble .owleys-qa-subscribe-intro,
.owleys-qa-block .owleys-qa-subscribe-intro {
    all: unset !important;
    display: block !important;
    font-size: 13px !important;
    color: #555 !important;
    margin: 0 0 10px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    font-family: Cabin, sans-serif !important;
}

.owleys-qa-block .owleys-qa-bubble .owleys-qa-subscribe-fields,
.owleys-qa-block .owleys-qa-subscribe-fields {
    all: unset !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
}

.owleys-qa-block .owleys-qa-bubble input.owleys-qa-sub-name,
.owleys-qa-block .owleys-qa-bubble input.owleys-qa-sub-email,
.owleys-qa-block input.owleys-qa-sub-name,
.owleys-qa-block input.owleys-qa-sub-email {
    all: unset !important;
    display: block !important;
    width: 100% !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 6px !important;
    font-family: Cabin, sans-serif !important;
    font-size: 13px !important;
    color: #333 !important;
    background: #fff !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    line-height: 1.4 !important;
}

.owleys-qa-block .owleys-qa-bubble input.owleys-qa-sub-name:focus,
.owleys-qa-block .owleys-qa-bubble input.owleys-qa-sub-email:focus,
.owleys-qa-block input.owleys-qa-sub-name:focus,
.owleys-qa-block input.owleys-qa-sub-email:focus {
    outline: none !important;
    border-color: #ff8338 !important;
}

.owleys-qa-block .owleys-qa-bubble button.owleys-qa-sub-btn,
.owleys-qa-block button.owleys-qa-sub-btn {
    all: unset !important;
    display: block !important;
    width: 100% !important;
    padding: 10px 16px !important;
    background: linear-gradient(135deg, #ff8338 0%, #ff9a5a 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    font-family: Cabin, sans-serif !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 3px 10px rgba(255, 131, 56, 0.25) !important;
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

.owleys-qa-block .owleys-qa-bubble button.owleys-qa-sub-btn:hover,
.owleys-qa-block button.owleys-qa-sub-btn:hover {
    box-shadow: 0 5px 14px rgba(255, 131, 56, 0.35) !important;
}

.owleys-qa-block .owleys-qa-bubble button.owleys-qa-sub-btn:disabled,
.owleys-qa-block button.owleys-qa-sub-btn:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

.owleys-qa-block .owleys-qa-bubble .owleys-qa-subscribe-note,
.owleys-qa-block .owleys-qa-subscribe-note {
    all: unset !important;
    display: block !important;
    font-size: 10px !important;
    color: #999 !important;
    margin: 6px 0 0 !important;
    text-align: center !important;
    font-family: Cabin, sans-serif !important;
}

.owleys-qa-subscribe-success {
    text-align: center;
    padding: 16px;
}

.owleys-qa-subscribe-success h4 {
    color: #2e7d32;
    margin: 0 0 8px;
    font-size: 16px;
}

.owleys-qa-subscribe-success p {
    color: #555;
    margin: 0;
    font-size: 13px;
}

.owleys-qa-subscribe-error {
    color: #d32f2f;
    font-size: 12px;
    margin: 8px 0 0;
    text-align: center;
}
