/*
 * Neurodor Intent — Home Widget
 *
 * Launcher flutuante + painel slide-in. Escopo CSS isolado por prefixo
 * .nd-home-widget__ para evitar conflitos com o tema.
 *
 * z-index: 1100 (acima do cookie banner=999, abaixo de modal preview=9999).
 */

.nd-home-widget {
    --ndhw-primary: #00c68c;
    --ndhw-accent: #ffb100;
    --ndhw-whatsapp: #25d366;
    --ndhw-text: #1f2933;
    --ndhw-muted: #5a6470;
    --ndhw-border: #e3e7ec;
    --ndhw-bg: #ffffff;
    --ndhw-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
    position: fixed;
    z-index: 1100;
    pointer-events: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--ndhw-text);
}
.nd-home-widget--pos-bottom-right { right: var(--ndhw-x); bottom: var(--ndhw-y); }
.nd-home-widget--pos-bottom-left  { left:  var(--ndhw-x); bottom: var(--ndhw-y); }
.nd-home-widget--pos-top-right    { right: var(--ndhw-x); top:    var(--ndhw-y); }
.nd-home-widget--pos-top-left     { left:  var(--ndhw-x); top:    var(--ndhw-y); }

/* ---------- Launcher ---------- */
.nd-home-widget__launcher {
    pointer-events: auto;
    width: var(--ndhw-size);
    height: var(--ndhw-size);
    border: none;
    border-radius: var(--ndhw-radius);
    background: var(--ndhw-primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ndhw-shadow);
    padding: 0;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .2s ease;
    position: relative;
}
.nd-home-widget__launcher:hover {
    transform: scale(1.06);
    box-shadow: 0 22px 56px rgba(15, 23, 42, 0.24);
}
.nd-home-widget__launcher:focus-visible {
    outline: 3px solid var(--ndhw-accent);
    outline-offset: 3px;
}
.nd-home-widget__launcher:active { transform: scale(0.96); }
.nd-home-widget__launcher-icon {
    width: 60%;
    height: 60%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nd-home-widget__launcher-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}
.nd-home-widget__launcher-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Animações */
@keyframes nd-home-widget-pulse {
    0%   { box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 0 0 0 rgba(0, 198, 140, 0.55); }
    70%  { box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 0 0 18px rgba(0, 198, 140, 0); }
    100% { box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 0 0 0 rgba(0, 198, 140, 0); }
}
@keyframes nd-home-widget-glow {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(0, 198, 140, 0.4)); }
    50%      { filter: drop-shadow(0 0 14px rgba(0, 198, 140, 0.85)); }
}
@keyframes nd-home-widget-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}
.nd-home-widget--anim-pulse  .nd-home-widget__launcher { animation: nd-home-widget-pulse 2.4s ease-out infinite; }
.nd-home-widget--anim-glow   .nd-home-widget__launcher { animation: nd-home-widget-glow 2.6s ease-in-out infinite; }
.nd-home-widget--anim-bounce .nd-home-widget__launcher { animation: nd-home-widget-bounce 2.2s ease-in-out infinite; }
.nd-home-widget--anim-none   .nd-home-widget__launcher { animation: none; }

/* Esconde launcher quando painel está aberto (visualmente "vira" no painel) */
.nd-home-widget[data-state="open"] .nd-home-widget__launcher {
    transform: scale(0.6);
    opacity: 0.65;
    pointer-events: none;
    animation: none;
}

/* ---------- Painel ---------- */
.nd-home-widget__panel {
    pointer-events: auto;
    position: fixed;
    top: 0;
    bottom: 0;
    width: clamp(320px, 30vw, 480px);
    background: var(--ndhw-bg);
    box-shadow: -18px 0 48px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform .32s cubic-bezier(.2, .8, .2, 1);
    will-change: transform;
}
.nd-home-widget__panel--side-right { right: 0; }
.nd-home-widget__panel--side-left  { left: 0; transform: translateX(-100%); box-shadow: 18px 0 48px rgba(15, 23, 42, 0.22); }

.nd-home-widget[data-state="open"] .nd-home-widget__panel {
    transform: translateX(0);
}

@media (max-width: 768px) {
    .nd-home-widget__panel {
        width: 100vw;
        left: 0;
        right: 0;
        max-width: 100%;
    }
}

/* Header */
.nd-home-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    background: linear-gradient(135deg, var(--ndhw-primary), var(--ndhw-accent));
    color: #fff;
}
.nd-home-widget__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
}
.nd-home-widget__close {
    /* Posicionado à ESQUERDA do header pra não colidir com .nd-user-menu-floating
       (top-right). Flex order=-1 coloca antes do título. */
    order: -1;
    margin-right: 12px;
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .18s ease;
    flex-shrink: 0;
}
.nd-home-widget__header { justify-content: flex-start; }
.nd-home-widget__title { flex: 1; }
.nd-home-widget__close:hover { background: rgba(255, 255, 255, 0.32); }
.nd-home-widget__close svg { width: 16px; height: 16px; }

/* Views — hidden HTML attribute forçado a display:none independente de display:flex/etc */
.nd-home-widget [hidden] { display: none !important; }
.nd-home-widget__view {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px 24px;
}

/* View: menu */
.nd-home-widget__option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    text-align: left;
    background: #f7f9fb;
    border: 1px solid var(--ndhw-border);
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
    color: var(--ndhw-text);
    font-family: inherit;
}
.nd-home-widget__option:hover {
    transform: translateY(-1px);
    border-color: var(--ndhw-primary);
    box-shadow: 0 8px 18px rgba(0, 198, 140, 0.14);
}
.nd-home-widget__option-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 198, 140, 0.12);
    color: var(--ndhw-primary);
}
.nd-home-widget__option-icon--whatsapp {
    background: rgba(37, 211, 102, 0.16);
    color: var(--ndhw-whatsapp);
}
.nd-home-widget__option-icon--whatsapp svg {
    animation: nd-home-widget-pulse-icon 2s ease-in-out infinite;
}
@keyframes nd-home-widget-pulse-icon {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.1); }
}
.nd-home-widget__option-icon svg { width: 24px; height: 24px; }
.nd-home-widget__option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.3;
}
.nd-home-widget__option-text strong {
    font-size: 15px;
    font-weight: 600;
    color: var(--ndhw-text);
}
.nd-home-widget__option-text small {
    font-size: 12.5px;
    color: var(--ndhw-muted);
    font-weight: 400;
}
.nd-home-widget__option--whatsapp:hover {
    border-color: var(--ndhw-whatsapp);
    box-shadow: 0 8px 18px rgba(37, 211, 102, 0.18);
}

/* View: form leve */
.nd-home-widget__back {
    background: none;
    border: none;
    color: var(--ndhw-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 0 0 12px 0;
    margin-bottom: 8px;
}
.nd-home-widget__back svg { width: 16px; height: 16px; }
.nd-home-widget__back:hover { color: var(--ndhw-primary); }

.nd-home-widget__form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.nd-home-widget__field { display: flex; flex-direction: column; gap: 4px; }
.nd-home-widget__label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ndhw-muted);
    letter-spacing: .02em;
    text-transform: uppercase;
}
.nd-home-widget__form input[type="text"],
.nd-home-widget__form input[type="email"],
.nd-home-widget__form input[type="tel"],
.nd-home-widget__form select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--ndhw-border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ndhw-text);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
}
.nd-home-widget__form input:focus,
.nd-home-widget__form select:focus {
    outline: none;
    border-color: var(--ndhw-primary);
    box-shadow: 0 0 0 3px rgba(0, 198, 140, 0.16);
}
.nd-home-widget__honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.nd-home-widget__consent {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 12px;
    color: var(--ndhw-muted);
    line-height: 1.4;
    margin-top: 2px;
}
.nd-home-widget__consent input { margin-top: 2px; flex-shrink: 0; }
.nd-home-widget__submit {
    margin-top: 8px;
    padding: 13px 18px;
    background: var(--ndhw-primary);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease, transform .12s ease;
    font-family: inherit;
}
.nd-home-widget__submit:hover { filter: brightness(0.92); transform: translateY(-1px); }
.nd-home-widget__submit:active { transform: translateY(0); }
.nd-home-widget__submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.nd-home-widget__error {
    margin-top: 8px;
    padding: 10px 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #b91c1c;
    font-size: 13px;
}

/* View: success */
.nd-home-widget__view[data-view="success"] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
}
.nd-home-widget__success-icon {
    width: 64px;
    height: 64px;
    background: var(--ndhw-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    margin-bottom: 16px;
    animation: nd-home-widget-success-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes nd-home-widget-success-pop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}
.nd-home-widget__success-msg {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ndhw-text);
}
.nd-home-widget__close-success {
    padding: 11px 20px;
    background: var(--ndhw-bg);
    color: var(--ndhw-text);
    border: 1px solid var(--ndhw-border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: border-color .15s ease;
}
.nd-home-widget__close-success:hover { border-color: var(--ndhw-primary); color: var(--ndhw-primary); }

/* Trigger oculto que frontend.js encontra (logado) */
.nd-intent-trigger-hidden {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .nd-home-widget__launcher,
    .nd-home-widget__panel,
    .nd-home-widget__option,
    .nd-home-widget__option-icon--whatsapp svg,
    .nd-home-widget__success-icon {
        animation: none !important;
        transition: none !important;
    }
}
