/*
 * Nora Chatbot — Branded peeking direction
 * Matches the "branded" tweak from the prototype:
 *   ink:     #102C3F   navy
 *   accent:  #E63A8C   magenta (peek title, ring, badge, send, primary CTA)
 *   accent2: #14C8B2   teal (online dot, header ring, progress fill)
 *
 * Header is ink with avatar (teal ring), name, online indicator.
 * Progress bar continues on the ink surface — no separate light strip.
 * Avatar everywhere is rendered from --nora-avatar-url custom property.
 */

.nora-chatbot *,
.nora-chatbot *::before,
.nora-chatbot *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.nora-chatbot {
    /* DTCH brand palette — sampled from dtchdigitals.com */
    --nora-white:    #ffffff;
    --nora-cream:    #faf6f1;
    --nora-off:      #f1ede6;
    --nora-light:    #ece6dc;
    --nora-border:   #e2ddd3;
    --nora-mid:      #9b978d;
    --nora-ink2:     #1b3a52;
    --nora-ink:      #102c3f;
    --nora-accent:       #e63a8c;   /* magenta */
    --nora-accent-deep:  #c92676;
    --nora-accent-soft:  #fce0ee;
    --nora-teal:         #14c8b2;
    --nora-teal-deep:    #0fa797;
    --nora-teal-soft:    #d4f3ee;
    --nora-green:        #22c55e;

    --nora-shadow-sm: 0 2px 12px rgba(16,44,63,0.10);
    --nora-shadow-md: 0 12px 30px rgba(16,44,63,0.18);
    --nora-shadow-lg: 0 18px 50px rgba(16,44,63,0.22);

    --nora-radius-card:   22px;
    --nora-radius-bubble: 18px;
    --nora-radius-ctrl:   12px;
    --nora-radius-ava:    12px;     /* "rounded" avatar shape from tweaks */

    font-family: var(--nora-font-body, 'Inter', system-ui, sans-serif), sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--nora-ink);
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
}

/* ═══════════════════════════════════════════════════════════════════════
   LAUNCHER  ·  avatar with magenta ring + "1" badge + peek bubble
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-toggle {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    padding: 0;
    /* magenta ring around white inner ring around avatar */
    background: var(--nora-accent);
    box-shadow: var(--nora-shadow-lg);
    transition: transform 0.18s cubic-bezier(0.2,0,0.2,1), box-shadow 0.18s;
}

.nora-chatbot-toggle::before {
    /* white spacer ring */
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: var(--nora-white);
}

.nora-chatbot-toggle::after {
    /* the avatar */
    content: '';
    /* Explicit display so a theme's `button::after { display: none }` reset
       (e.g. Storefront) cannot hide the launcher avatar. This selector
       out-specifies the bare `button::after` rule. */
    display: block;
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    background-image: var(--nora-avatar-url);
    background-size: cover;
    background-position: center 25%;
    background-color: var(--nora-accent-soft);
}

.nora-chatbot-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 56px rgba(16,44,63,0.30);
}

/* online dot — sits on the ring at ~4-5 o'clock, mirroring the badge */
.nora-chatbot-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: var(--nora-green);
    border: 2.5px solid var(--nora-white);
    border-radius: 50%;
    z-index: 2;
}

/* "1 unread" badge top-right of launcher */
.nora-chatbot-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--nora-accent);
    color: var(--nora-white);
    font-size: 11px;
    font-weight: 800;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(16,44,63,0.20);
    z-index: 2;
    font-family: inherit;
}

/* ── Peek bubble ── white card with magenta title + dismiss × ─────── */

.nora-chatbot-peek {
    position: absolute;
    bottom: 4px;
    right: 80px;
    background: var(--nora-white);
    border: 1px solid var(--nora-border);
    border-radius: 18px 18px 4px 18px;
    padding: 12px 32px 12px 14px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--nora-ink);
    font-weight: 500;
    min-width: 260px;
    max-width: 320px;
    box-shadow: var(--nora-shadow-md);
    cursor: pointer;
    animation: nora-peekIn 0.5s 0.8s cubic-bezier(0.2,0,0.2,1) both;
    font-family: inherit;
}

.nora-chatbot-peek-title {
    display: block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--nora-accent);
    margin-bottom: 4px;
}

.nora-chatbot-peek-dismiss {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: var(--nora-off);
    color: var(--nora-mid);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.nora-chatbot-peek-dismiss:hover {
    background: var(--nora-ink);
    color: var(--nora-white);
}

.nora-chatbot-peek-dismiss svg {
    width: 9px;
    height: 9px;
}

.nora-chatbot.nora-open .nora-chatbot-toggle,
.nora-chatbot.nora-open .nora-chatbot-peek,
.nora-chatbot.nora-open .nora-chatbot-online-dot,
.nora-chatbot.nora-open .nora-chatbot-badge,
.nora-chatbot.nora-peek-dismissed .nora-chatbot-peek {
    display: none;
}

/* ═══════════════════════════════════════════════════════════════════════
   CARD SHELL
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-card {
    display: none;
    width: var(--nora-card-width, 460px);
    max-width: calc(100vw - 48px);
    max-height: 680px;
    background: var(--nora-white);
    border-radius: var(--nora-radius-card);
    box-shadow: var(--nora-shadow-lg);
    overflow: hidden;
    flex-direction: column;
    animation: nora-slideUp 0.32s cubic-bezier(0.2,0,0.2,1);
}

.nora-chatbot.nora-open .nora-chatbot-card {
    display: flex;
}

/* ═══════════════════════════════════════════════════════════════════════
   HEADER  ·  ink surface with avatar (teal ring) + name + online dot
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-head {
    padding: 14px 16px;
    background: var(--nora-ink);
    color: var(--nora-white);
    display: flex;
    align-items: center;
    gap: 12px;
}

.nora-chatbot-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-image: var(--nora-avatar-url);
    background-size: cover;
    background-position: center 25%;
    background-color: var(--nora-accent-soft);
    flex-shrink: 0;
    /* white inner ring + teal outer ring */
    box-shadow: 0 0 0 2px var(--nora-white), 0 0 0 4px var(--nora-teal);
    /* hide any text content */
    font-size: 0;
    color: transparent;
}

.nora-chatbot-info {
    flex: 1;
    min-width: 0;
    margin-left: 4px;     /* compensate for avatar ring */
}

.nora-chatbot-info h2 {
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--nora-white);
    margin: 0;
    letter-spacing: -0.01em;
}

.nora-chatbot-info p {
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    margin: 1px 0 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.nora-chatbot-info p::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--nora-teal);
    border-radius: 50%;
}

.nora-chatbot-close {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255,255,255,0.15);
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nora-white);
    transition: background 0.18s;
    flex-shrink: 0;
}

.nora-chatbot-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ═══════════════════════════════════════════════════════════════════════
   PROGRESS  ·  continues the ink surface; teal fill on white-15% track
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-progress {
    padding: 10px 16px 12px;
    background: var(--nora-ink);
    color: var(--nora-white);
}

.nora-chatbot-progress-meta {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.6);
    margin-bottom: 6px;
}

.nora-chatbot-progress-meta span:last-child {
    color: var(--nora-teal);
}

.nora-chatbot-track {
    height: 3px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    overflow: hidden;
}

.nora-chatbot-fill {
    height: 100%;
    background: var(--nora-teal);
    border-radius: 3px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.2, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════════════════════════════
   MESSAGES
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-msgs {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--nora-border) transparent;
    background: var(--nora-cream);
}

.nora-chatbot-msgs::-webkit-scrollbar { width: 6px; }
.nora-chatbot-msgs::-webkit-scrollbar-thumb { background: var(--nora-border); border-radius: 3px; }

.nora-chatbot-msg {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    animation: nora-msgIn 0.3s cubic-bezier(0.2,0,0.2,1);
}

.nora-chatbot-msg.nora-user {
    flex-direction: row-reverse;
}

.nora-chatbot-msg-ava {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    background-image: var(--nora-avatar-url);
    background-size: cover;
    background-position: center 25%;
    background-color: var(--nora-accent-soft);
    /* hide any emoji content */
    font-size: 0;
    color: transparent;
    overflow: hidden;
}

/* user avatar slot kept for layout symmetry but invisible */
.nora-chatbot-msg.nora-user .nora-chatbot-msg-ava {
    background: transparent;
    background-image: none;
    width: 0;
}

.nora-chatbot-bubble {
    max-width: 78%;
    padding: 10px 13px;
    border-radius: 14px 14px 14px 4px;
    font-size: 13.5px;
    line-height: 1.55;
}

.nora-chatbot-msg.nora-ai .nora-chatbot-bubble {
    background: var(--nora-white);
    border: 1px solid var(--nora-border);
    color: var(--nora-ink);
}

.nora-chatbot-msg.nora-user .nora-chatbot-bubble {
    background: var(--nora-ink);
    color: var(--nora-white);
    border-radius: 14px 14px 4px 14px;
}

.nora-chatbot-bubble strong { font-weight: 700; }
.nora-chatbot-bubble a { color: var(--nora-accent); text-decoration: underline; }

/* ── Typing dots ── */
.nora-chatbot-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.nora-chatbot-typing span {
    width: 6px;
    height: 6px;
    background: var(--nora-mid);
    border-radius: 50%;
    animation: nora-dot 1.3s ease-in-out infinite;
}

.nora-chatbot-typing span:nth-child(2) { animation-delay: 0.16s; }
.nora-chatbot-typing span:nth-child(3) { animation-delay: 0.32s; }

/* ═══════════════════════════════════════════════════════════════════════
   MULTIPLE CHOICE OPTIONS
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-options {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--nora-cream);
}

.nora-chatbot-opt {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    background: var(--nora-white);
    border: 1.5px solid var(--nora-border);
    border-radius: var(--nora-radius-ctrl);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: var(--nora-ink);
    text-align: left;
    transition: border-color 0.18s, background 0.15s, color 0.15s, transform 0.18s;
    animation: nora-optIn 0.25s ease both;
}

.nora-chatbot-opt:hover {
    border-color: var(--nora-accent);
    transform: translateX(3px);
}

.nora-chatbot-opt:hover .nora-chatbot-opt-letter {
    background: var(--nora-accent);
    color: var(--nora-white);
}

/* selected (post-click) */
.nora-chatbot-opt.is-selected {
    background: var(--nora-accent);
    color: var(--nora-white);
    border-color: var(--nora-accent);
    transform: none;
}

.nora-chatbot-opt.is-selected .nora-chatbot-opt-letter {
    background: rgba(255,255,255,0.2);
    color: var(--nora-white);
}

.nora-chatbot-opt-letter {
    width: 24px;
    height: 24px;
    background: var(--nora-off);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: var(--nora-mid);
    flex-shrink: 0;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
}

/* ═══════════════════════════════════════════════════════════════════════
   FREE-TEXT INPUT
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-input-area {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
    background: var(--nora-cream);
}

.nora-chatbot-text-input {
    flex: 1;
    padding: 11px 14px;
    background: var(--nora-white);
    border: 1.5px solid var(--nora-border);
    border-radius: var(--nora-radius-ctrl);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--nora-ink);
    outline: none;
    transition: border-color 0.18s;
}

.nora-chatbot-text-input:focus {
    border-color: var(--nora-accent);
}

.nora-chatbot-text-input::placeholder {
    color: var(--nora-mid);
}

.nora-chatbot-send-btn {
    width: 42px;
    height: 42px;
    background: var(--nora-accent);
    border: none;
    border-radius: var(--nora-radius-ctrl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--nora-white);
    transition: background 0.18s, transform 0.15s;
    flex-shrink: 0;
}

.nora-chatbot-send-btn:hover {
    background: var(--nora-accent-deep);
    transform: scale(1.05);
}

.nora-chatbot-send-btn svg {
    width: 16px;
    height: 16px;
}

/* ═══════════════════════════════════════════════════════════════════════
   YES / NO
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-yn-area {
    padding: 0 16px 16px;
    display: flex;
    gap: 8px;
    background: var(--nora-cream);
}

.nora-chatbot-yn-btn {
    flex: 1;
    padding: 12px;
    border-radius: var(--nora-radius-ctrl);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid var(--nora-border);
    transition: all 0.18s;
}

.nora-chatbot-yn-yes {
    background: var(--nora-accent);
    color: var(--nora-white);
    border-color: var(--nora-accent);
}

.nora-chatbot-yn-yes:hover {
    background: var(--nora-accent-deep);
    border-color: var(--nora-accent-deep);
}

.nora-chatbot-yn-no {
    background: var(--nora-white);
    color: var(--nora-ink);
}

.nora-chatbot-yn-no:hover {
    border-color: var(--nora-ink);
    background: var(--nora-off);
}

/* ═══════════════════════════════════════════════════════════════════════
   CONSENT  ·  name + email + checkbox + submit
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-consent-area {
    padding: 0 16px 16px;
    background: var(--nora-cream);
}

.nora-chatbot-consent-fields {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.nora-chatbot-consent-fields input {
    flex: 1;
    padding: 10px 12px;
    background: var(--nora-white);
    border: 1.5px solid var(--nora-border);
    border-radius: 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--nora-ink);
    outline: none;
    transition: border-color 0.18s;
    min-width: 0;
}

.nora-chatbot-consent-fields input[type="email"] {
    flex: 1.2;
}

.nora-chatbot-consent-fields input:focus {
    border-color: var(--nora-accent);
}

.nora-chatbot-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--nora-ink);
    cursor: pointer;
    margin-bottom: 12px;
}

.nora-chatbot-consent-label input[type="checkbox"] {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--nora-accent);
    width: 15px;
    height: 15px;
}

.nora-chatbot-consent-submit {
    width: 100%;
    padding: 12px;
    background: var(--nora-accent);
    color: var(--nora-white);
    border: none;
    border-radius: var(--nora-radius-ctrl);
    font-size: 13.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.18s;
}

.nora-chatbot-consent-submit:hover {
    background: var(--nora-accent-deep);
}

.nora-chatbot-consent-skip {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 8px;
    font-size: 12px;
    color: var(--nora-mid);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nora-chatbot-consent-skip:hover {
    color: var(--nora-ink);
    text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════════════
   COMPLETION SCREEN
   ═══════════════════════════════════════════════════════════════════════ */

.nora-chatbot-done {
    padding: 28px 20px;
    text-align: center;
    background: var(--nora-cream);
    flex: 1;
}

.nora-chatbot-done-check {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--nora-teal);
    color: var(--nora-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.nora-chatbot-done-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--nora-ink);
    letter-spacing: -0.02em;
}

.nora-chatbot-done-body {
    font-size: 13px;
    color: var(--nora-ink2);
    margin-top: 8px;
    line-height: 1.55;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* ═══════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════ */

@keyframes nora-slideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes nora-msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes nora-optIn {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes nora-peekIn {
    from { opacity: 0; transform: translateX(8px) scale(0.92); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes nora-dot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40%           { transform: translateY(-4px); opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE  ·  bottom-sheet
   ═══════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .nora-chatbot {
        right: 16px;
        bottom: 16px;
    }

    .nora-chatbot.nora-open {
        right: 0;
        bottom: 0;
        left: 0;
    }

    .nora-chatbot.nora-open .nora-chatbot-card {
        width: 100%;
        max-height: calc(100vh - 80px);
        border-radius: 22px 22px 0 0;
    }

    .nora-chatbot-peek {
        right: 80px;
        max-width: calc(100vw - 110px);
    }
}

/* Debug banner (only injected when config.debug is true) */
.nora-chatbot .nora-chatbot-debug-banner {
    padding: 6px 12px;
    background: #fff3cd;
    color: #664d03;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    border-bottom: 1px solid #ffe69c;
}
