/* ── Niche Chatbot — Full Page ──────────────────────────────────────── */

#nc-chatbot {
    --nc-primary: var(--anafp-primary, #667eea);
    --nc-secondary: var(--anafp-secondary, #764ba2);
    --nc-bg: #f7f7f8;
    --nc-surface: #ffffff;
    --nc-border: #e5e7eb;
    --nc-text: #1f2937;
    --nc-text-muted: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--nc-text);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 400px;
    background: var(--nc-bg);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--nc-border);
}

#nc-chatbot * { box-sizing: border-box; }

/* ── Messages Area ─────────────────────────────────────────────────── */

#nc-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#nc-messages::-webkit-scrollbar { width: 6px; }
#nc-messages::-webkit-scrollbar-track { background: transparent; }
#nc-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* Welcome screen */
.nc-welcome {
    text-align: center;
    padding: 48px 24px 32px;
    color: var(--nc-text-muted);
}

.nc-welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--nc-primary), var(--nc-secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nc-welcome h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--nc-text);
    margin: 0 0 8px;
}

.nc-welcome p {
    font-size: 14px;
    margin: 0;
    max-width: 400px;
    margin: 0 auto;
}

/* Message rows */
.nc-message {
    display: flex;
    gap: 14px;
    padding: 20px 24px;
    animation: nc-fade-in 0.25s ease;
}

@keyframes nc-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nc-message.nc-bot {
    background: var(--nc-surface);
    border-bottom: 1px solid var(--nc-border);
}

.nc-message.nc-user {
    background: var(--nc-bg);
    border-bottom: 1px solid var(--nc-border);
    justify-content: flex-end;
}

.nc-message.nc-user .nc-bubble {
    flex: 0 1 auto;
    max-width: 75%;
}

.nc-message.nc-user .nc-msg-text {
    background: linear-gradient(135deg, var(--nc-primary), var(--nc-secondary));
    color: #fff;
    padding: 10px 16px;
    border-radius: 16px 4px 16px 16px;
    display: inline-block;
    text-align: right;
}

/* Avatar */
.nc-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--nc-primary), var(--nc-secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.nc-message.nc-user .nc-avatar {
    background: #9ca3af;
}

/* Bubble */
.nc-bubble {
    flex: 1;
    min-width: 0;
    max-width: 720px;
}

.nc-msg-text {
    font-size: 15px;
    line-height: 1.65;
    word-wrap: break-word;
}

/* Typing indicator */
.nc-typing {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.nc-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: nc-bounce 1.4s infinite;
}

.nc-typing span:nth-child(2) { animation-delay: 0.2s; }
.nc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes nc-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ── Product Cards Grid ────────────────────────────────────────────── */

.nc-products-section {
    margin-top: 14px;
    max-width: 100%;
}

.nc-products-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--nc-primary);
    margin-bottom: 10px;
}

.nc-products-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-bottom: 8px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.nc-products-grid::-webkit-scrollbar { display: none; }

.nc-product-card {
    flex-shrink: 0;
    width: 200px;
    background: var(--nc-bg);
    border: 1px solid var(--nc-border);
    border-radius: 12px;
    overflow: hidden;
    scroll-snap-align: start;
    transition: box-shadow 0.2s, transform 0.2s;
}

.nc-product-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.nc-product-card-img {
    width: 100%;
    height: 140px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 8px;
}

.nc-product-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.nc-product-card-body {
    padding: 10px 14px 14px;
}

.nc-product-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--nc-text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.nc-product-card-price {
    font-size: 18px;
    font-weight: 800;
    color: #b12704;
    margin-bottom: 4px;
}

.nc-product-card-rating {
    font-size: 12px;
    color: #f59e0b;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.nc-product-card-rating span {
    color: var(--nc-text-muted);
    font-size: 11px;
}

.nc-product-card-btn {
    display: block;
    width: 100%;
    padding: 9px 0;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--nc-primary), var(--nc-secondary));
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    letter-spacing: 0.3px;
}

.nc-product-card-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    color: #fff !important;
    text-decoration: none;
}

/* ── Input Area ────────────────────────────────────────────────────── */

#nc-input-area {
    padding: 16px 24px 20px;
    background: var(--nc-surface);
    border-top: 1px solid var(--nc-border);
    flex-shrink: 0;
}

#nc-reset {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 auto 10px;
    padding: 5px 14px;
    border: 1px solid var(--nc-border);
    border-radius: 8px;
    background: var(--nc-surface);
    color: var(--nc-text-muted);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

#nc-reset:hover {
    background: #f3f4f6;
    color: var(--nc-text);
}

.nc-input-wrap {
    display: flex;
    align-items: center;
    max-width: 760px;
    margin: 0 auto;
    background: var(--nc-bg);
    border: 1px solid var(--nc-border);
    border-radius: 14px;
    padding: 4px 4px 4px 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.nc-input-wrap:focus-within {
    border-color: var(--nc-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

#nc-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 15px;
    padding: 10px 0;
    outline: none;
    color: var(--nc-text);
    font-family: inherit;
}

#nc-input::placeholder {
    color: #9ca3af;
}

#nc-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, var(--nc-primary), var(--nc-secondary));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}

#nc-send:hover { opacity: 0.9; transform: scale(1.05); }
#nc-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.nc-disclaimer {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
}

/* ── Mobile ────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    #nc-chatbot {
        height: calc(100vh - 140px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .nc-message {
        padding: 16px;
    }

    #nc-input-area {
        padding: 12px 16px 16px;
    }

    .nc-products-grid {
        gap: 8px;
    }

    .nc-product-card {
        width: 170px;
    }

    .nc-product-card-img {
        height: 110px;
    }
}
