:root {
    --chatbot-shadow: 0 20px 45px rgba(15, 32, 63, 0.25);
    --chatbot-radius: 18px;
    --chatbot-bot-bg: #f3f4f6;
    --chatbot-user-bg: #dff6ec;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

#tutorial-chatbot-root {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    z-index: 2147483647 !important;
    isolation: isolate !important;
    pointer-events: none;
}

.tutorial-chatbot-button {
    position: fixed !important;
    bottom: 24px !important;
    right: 32px !important;
    width: auto !important;
    min-width: 72px !important;
    height: 62px !important;
    border: none !important;
    padding: 6px 8px 6px 14px !important;
    background: #eceff3 !important;
    color: #1f2937 !important;
    border-radius: 999px !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22) !important;
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    cursor: pointer !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease !important;
    z-index: 2147483647 !important;
    /* Ensure button is not affected by parent containers */
    transform: none !important;
    pointer-events: auto !important;
}

/* When image loads successfully, adjust background but keep button visible */
.tutorial-chatbot-button:has(.tutorial-chatbot-icon) {
    background: #eceff3 !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.22) !important;
    border-radius: 999px !important;
}

.tutorial-chatbot-button:hover,
.tutorial-chatbot-button:focus {
    transform: none;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.24) !important;
    outline: none;
}

.tutorial-chatbot-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    pointer-events: none;
    filter: none;
    /* Ensure image is visible */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.tutorial-chatbot-cta-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
    min-width: 84px;
    margin-left: 2px;
    animation: chatbot-cta-text-enter 980ms cubic-bezier(0.2, 0.85, 0.25, 1) 160ms both;
}

.tutorial-chatbot-cta-title {
    font-size: 19px;
    font-weight: 500;
    color: #2d3748;
    letter-spacing: -0.2px;
}

.tutorial-chatbot-cta-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: #2d3748;
    margin-top: 2px;
}

.tutorial-chatbot-icon-wrap {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border: none;
}

.tutorial-chatbot-fallback {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 24px;
}

@keyframes chatbot-cta-text-enter {
    0% {
        opacity: 0;
        transform: translate3d(24px, 0, 0);
    }
    70% {
        opacity: 1;
        transform: translate3d(-3px, 0, 0);
    }
    100% {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Mobile: remove shadow/halo around the floating icon */
@media (max-width: 768px) {
    .tutorial-chatbot-button,
    .tutorial-chatbot-button:has(.tutorial-chatbot-icon) {
        right: 12px !important;
        bottom: 12px !important;
        box-shadow: 0 6px 16px rgba(15, 23, 42, 0.2) !important;
        border: none !important;
        padding: 6px 8px 6px 12px !important;
        height: 56px !important;
        gap: 8px !important;
    }

    .tutorial-chatbot-panel {
        right: 12px !important;
        bottom: 92px !important;
    }

    .tutorial-chatbot-icon {
        width: 42px;
        height: 42px;
        border: none !important;
    }

    .tutorial-chatbot-cta-title {
        font-size: 16px;
    }

    .tutorial-chatbot-cta-subtitle {
        font-size: 11px;
        margin-top: 2px;
    }

    .tutorial-chatbot-icon-wrap {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
}

/* When image is present, style button differently */
.tutorial-chatbot-button .tutorial-chatbot-icon ~ * {
    display: none;
}

/* Style for when image is present (hide fallback styling) */
.tutorial-chatbot-icon + span {
    display: none;
}

.tutorial-chatbot-panel {
    position: fixed;
    bottom: 100px;
    right: 32px;
    width: min(410px, calc(100vw - 32px));
    max-height: 75vh;
    background: #ffffff !important;
    border-radius: var(--chatbot-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2147483647 !important;
}

.tutorial-chatbot-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.tutorial-chatbot-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.tutorial-chatbot-header p {
    margin: 0;
    font-weight: 600;
}

.tutorial-chatbot-header small {
    color: #64748b;
}

.tutorial-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tutorial-chatbot-new-session {
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    height: 32px;
    padding: 0 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.tutorial-chatbot-new-session:hover,
.tutorial-chatbot-new-session:focus {
    background: #f9fafb;
    border-color: #9ca3af;
    outline: none;
}

.tutorial-chatbot-help {
    border: none;
    background: rgba(99, 102, 241, 0.1);
    color: #4f46e5;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.tutorial-chatbot-help:hover,
.tutorial-chatbot-help:focus {
    background: rgba(99, 102, 241, 0.2);
    color: #312e81;
    outline: none;
}

.tutorial-chatbot-clear {
    border: none;
    background: transparent;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease, background 0.2s ease;
}

.tutorial-chatbot-clear:hover,
.tutorial-chatbot-clear:focus {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
    outline: none;
}

.tutorial-chatbot-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #475569;
}

.tutorial-chatbot-messages {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    gap: 12px;
    display: flex;
    flex-direction: column;
}

.tutorial-chatbot-message {
    padding: 12px 14px;
    border-radius: 14px;
    line-height: 1.4;
    font-size: 0.95rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
    animation: fadeInUp 0.2s ease;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
}

.tutorial-chatbot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: contain;
}

.tutorial-chatbot-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tutorial-chatbot-message.bot {
    background: var(--chatbot-bot-bg);
    border-top-left-radius: 4px;
    align-self: flex-start;
}

.tutorial-chatbot-message.user {
    background: var(--chatbot-user-bg);
    border-top-right-radius: 4px;
    align-self: flex-end;
}

.tutorial-chatbot-dots {
    display: flex;
    gap: 4px;
    font-size: 1.4rem;
    line-height: 1;
    color: #6366f1;
}

.tutorial-chatbot-dots span {
    animation: dotPulse 1.4s infinite ease-in-out both;
}

.tutorial-chatbot-dots span:nth-child(1) {
    animation-delay: 0s;
}

.tutorial-chatbot-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.tutorial-chatbot-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

.tutorial-chatbot-help-dialog {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    border-radius: inherit;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    z-index: 2;
}

.tutorial-chatbot-help-dialog.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.tutorial-chatbot-help-content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: calc(100% - 32px);
    overflow-y: auto;
    padding: 20px 22px;
    box-shadow: 0 25px 70px rgba(15, 23, 42, 0.35);
}

.tutorial-chatbot-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.tutorial-chatbot-help-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #111827;
}

.tutorial-chatbot-help-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
}

.tutorial-chatbot-help-close:hover,
.tutorial-chatbot-help-close:focus {
    color: #ef4444;
    outline: none;
}

.tutorial-chatbot-help-intro {
    margin: 0 0 14px;
    font-size: 0.9rem;
    color: #4b5563;
}

.tutorial-chatbot-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.tutorial-chatbot-help-grid section {
    background: rgba(99, 102, 241, 0.08);
    border-radius: 12px;
    padding: 12px 14px;
}

.tutorial-chatbot-help-grid h4 {
    margin: 0 0 6px;
    font-size: 0.95rem;
    color: #312e81;
}

.tutorial-chatbot-help-grid ul {
    margin: 0;
    padding-left: 16px;
    font-size: 0.85rem;
    color: #1f2937;
}

.tutorial-chatbot-help-grid li {
    margin-bottom: 4px;
}

.tutorial-chatbot-help-grid code {
    background: rgba(15, 23, 42, 0.08);
    padding: 1px 4px;
    border-radius: 6px;
    font-size: 0.8rem;
}

.tutorial-chatbot-text {
    white-space: pre-line;
    word-break: break-word;
    overflow-wrap: break-word;
}

.tutorial-chatbot-links {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tutorial-chatbot-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2563eb;
    text-decoration: underline;
}

.tutorial-chatbot-link:hover,
.tutorial-chatbot-link:focus {
    color: #1d4ed8;
    outline: none;
}

.tutorial-chatbot-products {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    overflow: hidden;
}

.tutorial-chatbot-products th,
.tutorial-chatbot-products td {
    padding: 6px 8px;
    text-align: left;
}

.tutorial-chatbot-products thead {
    background: rgba(79, 70, 229, 0.08);
    font-weight: 600;
    color: #312e81;
}

.tutorial-chatbot-products tbody tr:nth-child(odd) {
    background: rgba(15, 23, 42, 0.03);
}

.tutorial-chatbot-product-complete td {
    background: rgba(16, 185, 129, 0.15);
}

.tutorial-chatbot-product-empty td {
    background: rgba(239, 68, 68, 0.12);
}

.tutorial-chatbot-product-partial td {
    background: rgba(251, 146, 60, 0.18);
}

.tutorial-chatbot-entity-select {
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(99, 102, 241, 0.08);
}

.tutorial-chatbot-entity-select p {
    margin: 0 0 6px;
    font-size: 0.92rem;
    color: #312e81;
}

.tutorial-chatbot-entity-hint {
    font-size: 0.82rem;
    color: #4b5563;
}

.tutorial-chatbot-entity-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.tutorial-chatbot-entity-btn {
    border: none;
    border-radius: 999px;
    padding: 8px 18px;
    font-weight: 600;
    font-size: 0.85rem;
    background: #eef2ff;
    color: #312e81;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.tutorial-chatbot-entity-btn:hover,
.tutorial-chatbot-entity-btn:focus {
    background: #c7d2fe;
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
    outline: none;
}

.tutorial-chatbot-tracking-link {
    display: inline-block;
    margin-top: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.tutorial-chatbot-tracking-link:hover,
.tutorial-chatbot-tracking-link:focus {
    box-shadow: 0 8px 20px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
    outline: none;
}

/* Support ticket links inside bot messages (no background/button styling) */
.tutorial-chatbot-message .chatbot-ticket-link {
    display: inline;
    background: transparent !important;
    color: #2563eb;
    text-decoration: underline;
    font-weight: 600;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.tutorial-chatbot-message .chatbot-ticket-link:hover,
.tutorial-chatbot-message .chatbot-ticket-link:focus {
    color: #1d4ed8;
    outline: none;
}

.tutorial-chatbot-model-label {
    align-self: flex-start;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(79, 70, 229, 0.1);
    color: #4f46e5;
    border-radius: 6px;
    padding: 2px 6px;
}
}

.tutorial-chatbot-results {
    margin-top: 8px;
    padding-left: 16px;
}

.tutorial-chatbot-results li {
    margin-bottom: 8px;
}

.tutorial-chatbot-result-link {
    font-weight: 600;
}

.tutorial-chatbot-result-excerpt {
    display: block;
    margin-top: 2px;
    font-size: 0.85rem;
    color: #475569;
}

.tutorial-chatbot-score {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #0f766e;
}

.tutorial-chatbot-person-options {
    margin-top: 8px;
    padding: 6px 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tutorial-chatbot-person-title {
    margin: 0;
    font-weight: 600;
    color: #312e81;
}

.tutorial-chatbot-person-option button {
    width: 100%;
    border: none;
    background: linear-gradient(120deg, #dde3ff 0%, #ede9fe 100%);
    color: #312e81;
    font-weight: 600;
    padding: 14px 46px 14px 16px;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tutorial-chatbot-person-option button:hover,
.tutorial-chatbot-person-option button:focus {
    box-shadow: 0 10px 22px rgba(99, 102, 241, 0.25);
    transform: translateY(-1px);
    outline: none;
}

.tutorial-chatbot-person-name {
    font-size: 0.95rem;
    font-weight: 700;
}

.tutorial-chatbot-person-id {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(49, 46, 129, 0.75);
    margin-top: 2px;
}

.tutorial-chatbot-person-meta {
    font-size: 0.85rem;
    color: rgba(49, 46, 129, 0.8);
}

.tutorial-chatbot-person-chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: rgba(49, 46, 129, 0.7);
    transition: transform 0.15s ease;
}

.tutorial-chatbot-person-option button:hover .tutorial-chatbot-person-chevron,
.tutorial-chatbot-person-option button:focus .tutorial-chatbot-person-chevron {
    transform: translateY(-50%) translateX(2px);
}

.tutorial-chatbot-person-hint {
    margin: 0;
    font-size: 0.85rem;
    color: #4b5563;
}

.tutorial-chatbot-form {
    border-top: 1px solid #e5e7eb;
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#tutorial-chatbot-input {
    width: 100%;
    resize: none;
    border: 1px solid #cbd5f5;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    min-height: 64px;
}

.tutorial-chatbot-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tutorial-chatbot-enter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #475569;
    user-select: none;
}

.tutorial-chatbot-enter-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.tutorial-chatbot-loading {
    font-style: italic;
    color: #475569;
}

/* Send button styling */
.tutorial-chatbot-send-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
    text-decoration: none;
    white-space: nowrap;
    background: var(--shop-primary-btn, #3b82f6);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.tutorial-chatbot-send-btn:hover,
.tutorial-chatbot-send-btn:focus {
    filter: brightness(0.92);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.22);
    outline: none;
}

.tutorial-chatbot-send-btn:active {
    transform: translateY(1px);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .tutorial-chatbot-button {
        bottom: 16px;
        right: 16px;
        width: 60px;
        height: 60px;
    }

    .tutorial-chatbot-icon {
        width: 52px;
        height: 52px;
    }

    .tutorial-chatbot-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 86px;
    }

    .tutorial-chatbot-help-content {
        max-width: 100%;
        padding: 18px;
    }
}

/* ───────────── Search modal (floating async search panel) ───────────── */
.chatbot-search-modal {
    position: fixed;
    bottom: 120px;
    right: 32px;
    width: 280px;
    max-height: 340px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .15);
    z-index: 2147483647 !important;
    font-family: inherit;
    font-size: 13px;
    overflow: hidden;
    animation: chatbot-search-fadein .2s ease;
}

@keyframes chatbot-search-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chatbot-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 13px;
    color: #334155;
}

.chatbot-search-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #94a3b8;
    line-height: 1;
    padding: 0 2px;
    transition: color .15s;
}

.chatbot-search-close:hover {
    color: #334155;
}

.chatbot-search-body {
    padding: 10px 14px;
    overflow-y: auto;
    max-height: 260px;
}

.chatbot-search-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    color: #475569;
    line-height: 1.4;
    border-bottom: 1px solid #f1f5f9;
}

.chatbot-search-item:last-child {
    border-bottom: none;
}

.chatbot-search-item .search-icon {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    font-size: 14px;
    line-height: 1.4;
}

.chatbot-search-item .search-text {
    flex: 1;
    word-break: break-word;
}

.chatbot-search-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: chatbot-search-spin .6s linear infinite;
    vertical-align: middle;
}

@keyframes chatbot-search-spin {
    to { transform: rotate(360deg); }
}

.chatbot-search-item.is-done .search-icon {
    color: #22c55e;
}

.chatbot-search-item.is-done .search-text {
    color: #94a3b8;
    text-decoration: line-through;
}

@media (max-width: 800px) {
    .chatbot-search-modal {
        right: auto;
        left: 12px;
        bottom: 86px;
        width: calc(100vw - 24px);
        max-width: 300px;
    }
}
