/* Virtual Shopping Assistant Styles */

/* Defensive: hide broken images that point to /synaptic-vsa/false */
img[src$="/synaptic-vsa/false"] { display: none !important; }

/* Floating Button Container - High Specificity to Override WordPress/Elementor */
#vsa-floating-button.vsa-floating-button,
body #vsa-floating-button,
html body #vsa-floating-button {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 999999 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    max-width: fit-content !important;
    display: block !important;
    right: auto !important;
}

/* Button Wrapper - Modern & Clean Design - Protected from Overrides */
#vsa-floating-button a,
#vsa-floating-button a:link,
#vsa-floating-button a:visited,
#vsa-floating-button a:hover,
#vsa-floating-button a:active,
.vsa-floating-button a,
.vsa-floating-button a:link,
.vsa-floating-button a:visited,
.vsa-floating-button a:hover,
.vsa-floating-button a:active,
body #vsa-floating-button a,
html body #vsa-floating-button a {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    background: #ffffff !important;
    padding: 12px 16px !important;
    border-radius: 50px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    text-decoration: none !important;
    transition: all 0.25s ease !important;
    border: 2px solid #f0f0f0 !important;
    position: relative !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    min-width: auto !important;
    min-height: auto !important;
    max-width: fit-content !important;
    max-height: none !important;
    flex-shrink: 0 !important;
    line-height: normal !important;
    font-family: inherit !important;
}

/* Icon Styling - Protected from Overrides */
#vsa-floating-button img,
#vsa-floating-button a img,
.vsa-floating-button img,
.vsa-floating-button a img,
body #vsa-floating-button img,
html body #vsa-floating-button img {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    flex-shrink: 0 !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    max-width: 40px !important;
    max-height: 40px !important;
}

/* SVG Fallback Icon - Protected from Overrides */
#vsa-floating-button svg,
#vsa-floating-button a svg,
.vsa-floating-button svg,
.vsa-floating-button a svg,
body #vsa-floating-button svg,
html body #vsa-floating-button svg {
    width: 40px !important;
    height: 40px !important;
    color: #667eea !important;
    flex-shrink: 0 !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    fill: currentColor !important;
}

/* Text Label - Protected from Overrides */
#vsa-floating-button .vsa-button-label,
.vsa-floating-button .vsa-button-label,
#vsa-floating-button a .vsa-button-label,
.vsa-floating-button a .vsa-button-label,
body #vsa-floating-button .vsa-button-label {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    white-space: nowrap !important;
    position: static !important;
    transform: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    z-index: auto !important;
    line-height: normal !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

/* Remove arrow from label (no longer needed with new design) */
#vsa-floating-button .vsa-button-label:after,
.vsa-floating-button .vsa-button-label:after,
#vsa-floating-button a .vsa-button-label:after,
.vsa-floating-button a .vsa-button-label:after {
    display: none !important;
    content: none !important;
}

/* Hover Effects - Protected from Overrides */
#vsa-floating-button a:hover,
.vsa-floating-button a:hover,
body #vsa-floating-button a:hover,
html body #vsa-floating-button a:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25) !important;
    border-color: #ddd !important;
    background: #ffffff !important;
    text-decoration: none !important;
}

/* Optional: Pulse Glow Animation (subtle attention-grabber) */
#vsa-floating-button a,
body #vsa-floating-button a {
    animation: vsa-pulse 2.5s infinite !important;
}

@keyframes vsa-pulse {
    0% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    70% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

/* Assistant Page Layout */
.vsa-assistant-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

.vsa-layout { display: grid; grid-template-columns: 320px 1fr; gap: 24px; min-height: 740px; }

/* Cart Column */
.vsa-cart-column {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e9ecef;
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.vsa-cart-header {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.vsa-cart-header h3 { margin: 0 0 10px 0; color: #333; font-size: 22px; display: flex; align-items: center; gap: 8px; }
.vsa-cart-header h3:before { content: "\f07a"; font-family: "Dashicons"; font-size: 20px; color: #333; display: inline-block; }

.vsa-cart-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #666;
}


.vsa-cart-items {
    min-height: 200px;
}

.vsa-cart-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f3f4;
}

.vsa-cart-item:last-child {
    border-bottom: none;
}

.vsa-cart-item-thumb {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 12px;
}

.vsa-cart-item-details {
    flex: 1;
}

.vsa-cart-item-name {
    font-weight: 500;
    color: #333;
    text-decoration: none;
    margin-bottom: 4px;
    display: block;
}

.vsa-cart-item-name:hover {
    color: #007cba;
}

.vsa-cart-item-price {
    color: #666;
    font-size: 14px;
}

.vsa-cart-item-qty {
    color: #999;
    font-size: 12px;
}

.vsa-cart-actions {
    margin-top: 20px;
    text-align: center;
}

.vsa-bom-panel {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #dee2e6;
}

.vsa-bom-header h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: #2c3e50;
}

.vsa-bom-header p {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #6c757d;
}

.vsa-bom-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
}

.vsa-bom-item {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px;
    background: #fff;
}

.vsa-bom-item.is-invalid {
    border-color: #f59e0b;
    background: #fffaf0;
}

.vsa-bom-item-title {
    font-weight: 600;
    font-size: 13px;
    color: #111827;
}

.vsa-bom-item-meta {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.vsa-bom-invalid-badge {
    display: inline-block;
    margin-top: 6px;
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 9999px;
    padding: 2px 8px;
}

.vsa-bom-item-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.vsa-bom-item-controls button {
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
}

.vsa-bom-item-controls button:hover {
    background: #f3f4f6;
}

.vsa-bom-summary {
    margin-top: 10px;
    font-size: 12px;
    color: #374151;
}

.vsa-bom-summary-warning {
    margin-top: 4px;
    color: #92400e;
}

.vsa-bom-replace-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #374151;
}

.vsa-bom-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.vsa-bom-actions .button {
    flex: 1;
}

.vsa-review-cart-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #cf9d30;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.3s ease;
}

.vsa-review-cart-btn:hover {
    background: #b58629;
    color: white;
}

.vsa-cart-empty {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.vsa-cart-empty svg {
    width: 64px;
    height: 64px;
    color: #ccc;
    margin-bottom: 15px;
}

/* Chat Column */
.vsa-chat-column { background: #ffffff; border-radius: 8px; padding: 16px; color: #2c3e50; display: flex; flex-direction: column; max-height: 86vh; overflow: hidden; border: 1px solid #e5e5e5; box-shadow: 0 10px 30px rgba(0,0,0,0.08); }

.vsa-chat-header {
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e5e5e5;
}

.vsa-chat-header h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
    font-size: 24px;
}

.vsa-chat-helper {
    margin: 0;
    color: #7f8c8d;
    font-size: 16px;
}

/* Single scrollable area wrapping messages + suggestions */
.vsa-scroll-area { flex: 1 1 auto; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }

.vsa-messages { flex: 0 0 auto; display: flex; flex-direction: column; }

/* Floating typing indicator next to assistant icon */
.vsa-typing-indicator { position: relative; height: 0; margin-left: 8px; }

.vsa-typing-avatar { position: absolute; left: 0; bottom: 0; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.vsa-typing-avatar img { width: 100%; height: 100%; object-fit: cover; }
.vsa-typing-avatar svg { width: 100%; height: 100%; color: #95a5a6; background: #ecf0f1; border-radius: 50%; }

.vsa-typing-bubble {
    position: absolute;
    left: 44px;
    bottom: 4px;
    background: #ffffff;
    color: #2c3e50;
    border-radius: 16px;
    padding: 8px 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(0,0,0,0.06);
}

.vsa-typing-bubble:before { content: none; display: none; }

.vsa-typing-dot {
    width: 8px;
    height: 8px;
    background: #bdc3c7;
    border-radius: 50%;
    display: inline-block;
    animation: vsa-typing 1.4s infinite ease-in-out;
}

.vsa-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.vsa-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes vsa-typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.6; }
    40% { transform: scale(1); opacity: 1; }
}

.vsa-message {
    margin-bottom: 15px;
    display: flex;
}

.vsa-message.user {
    justify-content: flex-end;
    display: flex !important; /* Force display */
    visibility: visible !important; /* Force visibility */
    opacity: 1 !important; /* Force opacity */
}

.vsa-message.assistant {
    justify-content: flex-start;
}

.vsa-message-bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 16px;
}

.vsa-message.user .vsa-message-bubble {
    background: #3498db !important; /* Force blue background */
    color: white !important; /* Force white text */
    display: block !important; /* Force display */
    visibility: visible !important; /* Force visibility */
    opacity: 1 !important; /* Force opacity */
}

.vsa-message.assistant .vsa-message-bubble {
    background: #f0f2f5;
    color: #2c3e50;
    line-height: 1.45;
}

.vsa-product-suggestions { flex: 0 0 auto; }

/* Collapsible suggestions inside message stream */
.vsa-suggestions-block { align-self: flex-start; width: 100%; }
.vsa-suggestions-toggle { cursor: pointer; border: 1px solid #e5e5e5; background: #f7f8fa; color: #2c3e50; border-radius: 9999px; padding: 8px 12px; font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,0.06); display: inline-flex; align-items: center; gap: 8px; }
.vsa-sugg-caret { display: inline-block; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid #2c3e50; transition: transform 0.15s ease; }
.vsa-suggestions-block.open .vsa-sugg-caret { transform: rotate(180deg); }
.vsa-suggestions-list { margin-top: 10px; }

.vsa-product-suggestion {
    background: #f5f7f9;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.vsa-product-suggestion-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 15px;
}

.vsa-product-suggestion-details {
    flex: 1;
}

.vsa-product-suggestion-name {
    font-weight: 500;
    margin-bottom: 5px;
    color: #2c3e50;
    text-decoration: none;
    display: block;
}

.vsa-product-suggestion-name:hover {
    color: #007cba;
    text-decoration: none;
}

.vsa-product-suggestion-price {
    color: #666;
    font-size: 14px;
}

.vsa-product-suggestion-code {
    color: #888;
    font-size: 12px;
    font-style: italic;
    margin-top: 2px;
}

.vsa-product-suggestion-add {
    background: #e53935;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.vsa-product-suggestion-add:hover {
    background: #c62828;
}

.vsa-product-suggestion-bom {
    margin-left: 8px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #1f2937;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.vsa-product-suggestion-bom:hover {
    background: #f3f4f6;
}

.vsa-product-suggestion-add svg {
    width: 18px;
    height: 18px;
    margin-right: 6px;
}

/* Add to Cart label next to icon */
.vsa-add-label {
    font-size: 14px;
    font-weight: 500;
}

/* Knowledge citations block */
.vsa-citations-block{align-self:flex-start;width:100%;margin:8px 0;padding:10px 14px;background:#f8f9fa;border-left:3px solid #6c757d;border-radius:4px;font-size:13px}
.vsa-citations-label{font-weight:600;color:#495057;margin-bottom:6px;font-size:12px;text-transform:uppercase;letter-spacing:.5px}
.vsa-citations-list{display:flex;flex-direction:column;gap:6px}
.vsa-citation-item{display:flex;align-items:flex-start;gap:8px}
.vsa-citation-icon{flex-shrink:0;color:#6c757d;margin-top:2px}
.vsa-citation-details{display:flex;flex-wrap:wrap;gap:4px 10px;align-items:baseline}
a.vsa-citation-title{color:#0d6efd;text-decoration:none;font-weight:500}
a.vsa-citation-title:hover{text-decoration:underline}
span.vsa-citation-title{color:#495057;font-weight:500}
.vsa-citation-section{color:#6c757d;font-style:italic}
.vsa-citation-jurisdiction{color:#6c757d;font-size:12px}
.vsa-citations-disclaimer{margin-top:8px;font-size:11px;color:#adb5bd;font-style:italic}

/* New Chat toolbar removed */

.vsa-input-row { display: flex; align-items: center; padding: 12px; background: #fff; border-radius: 30px; gap: 12px; border: 1px solid #e5e5e5; flex: 0 0 auto; }

.vsa-input-row input { flex: 1; padding: 14px 18px; border: none; border-radius: 20px; background: transparent; color: #2c3e50; font-size: 16px; }

.vsa-input-row input::placeholder { color: #7f8c8d; }

.vsa-input-row input:focus { outline: none; }

.vsa-input-row button { padding: 12px 22px; background: #e50914; color: white; border: none; border-radius: 9999px; cursor: pointer; font-size: 16px; transition: background 0.2s ease; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }

.vsa-input-row button:hover { background: #c40812; }

.vsa-input-row button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

/* Loading Indicator */
.vsa-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10000;
}

.vsa-loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error States */
.vsa-error {
    background: #e74c3c;
    color: white;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    margin: 20px 0;
}

.vsa-cart-unavailable {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-style: italic;
}

/* Cart Button States */
.vsa-review-cart-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.vsa-review-cart-btn.disabled:hover {
    transform: none;
    box-shadow: 0 4px 12px rgba(18, 120, 209, 0.25);
}

/* Responsive Design */
@media (max-width: 768px) {
    .vsa-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .vsa-cart-column {
        order: 2;
    }
    
    .vsa-chat-column {
        order: 1;
    }
    
    .vsa-floating-button {
        bottom: 0 !important;
        left: 0 !important;
    }
    
    /* Mobile: Make it a round icon-only button - Protected from Overrides */
    #vsa-floating-button a,
    .vsa-floating-button a,
    body #vsa-floating-button a {
        padding: 12px !important;
        border-radius: 50% !important;
        width: 56px !important;
        height: 56px !important;
        justify-content: center !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }
    
    #vsa-floating-button img,
    .vsa-floating-button img,
    body #vsa-floating-button img {
        width: 32px !important;
        height: 32px !important;
        max-width: 32px !important;
        max-height: 32px !important;
    }
    
    #vsa-floating-button svg,
    .vsa-floating-button svg,
    body #vsa-floating-button svg {
        width: 32px !important;
        height: 32px !important;
    }
    
    #vsa-floating-button .vsa-button-label,
    .vsa-floating-button .vsa-button-label,
    body #vsa-floating-button .vsa-button-label {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .vsa-assistant-container {
        padding: 15px;
    }
    
    .vsa-cart-column,
    .vsa-chat-column {
        padding: 15px;
    }
    
    .vsa-input-row {
        flex-direction: column;
    }
    
    .vsa-input-row button {
        width: 100%;
    }
}

/* Variation Selector Styles - In-Chat Product Options */
.vsa-variation-selector {
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 16px;
    margin: 12px 0;
    max-width: 100%;
}

.vsa-variation-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}

.vsa-variation-subtitle {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 16px;
}

.vsa-variation-attribute {
    margin-bottom: 16px;
}

.vsa-variation-attribute label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 6px;
}

.vsa-variation-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: #2c3e50;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.vsa-variation-select:hover {
    border-color: #667eea;
}

.vsa-variation-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.vsa-variation-add-btn {
    width: 100%;
    padding: 12px 20px;
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 12px;
}

.vsa-variation-add-btn:hover:not(:disabled) {
    background: #5568d3;
}

.vsa-variation-bom-btn {
    width: 100%;
    padding: 10px 20px;
    background: #ffffff;
    color: #2c3e50;
    border: 1px solid #cfd8e3;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 8px;
}

.vsa-variation-bom-btn:hover:not(:disabled) {
    background: #f8fafc;
}

.vsa-variation-bom-btn:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.vsa-variation-add-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    opacity: 0.6;
}

.vsa-variation-link {
    margin-top: 12px;
    text-align: center;
    font-size: 13px;
}

.vsa-variation-link a {
    color: #667eea;
    text-decoration: none;
}

.vsa-variation-link a:hover {
    text-decoration: underline;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .vsa-variation-selector {
        padding: 12px;
    }
    
    .vsa-variation-title {
        font-size: 15px;
    }
    
    .vsa-variation-subtitle {
        font-size: 13px;
    }
}
