/* Dany — Widget de Atendimento */
/* Z-index alto pra ficar acima de modais existentes */

/* ─── Bubble flutuante (chamariz) — agora no canto inferior direito ─── */
.dany-bubble {
    position: fixed;
    bottom: var(--dany-bubble-bottom, 20px);
    right: 16px;
    z-index: 999997;
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 10px;
    background: linear-gradient(135deg, #1a3d2f 0%, #0f5132 100%);
    border: 1px solid rgba(110, 231, 168, 0.3);
    border-radius: 50px;
    box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 4px rgba(110, 231, 168, 0.08);
    cursor: pointer;
    animation: danyBubbleIn .35s cubic-bezier(.16,1,.3,1), danyBubblePulse 2s 1s infinite;
    max-width: 280px;
    user-select: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.dany-bubble.visible { display: inline-flex; }
.dany-bubble:hover { transform: translateY(-2px); }

@keyframes danyBubbleIn {
    from { transform: translateY(40px) scale(.85); opacity: 0; }
    to   { transform: translateY(0)    scale(1);   opacity: 1; }
}
@keyframes danyBubblePulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 4px rgba(110, 231, 168, 0.08); }
    50%      { box-shadow: 0 8px 32px rgba(0,0,0,.35), 0 0 0 10px rgba(110, 231, 168, 0.0); }
}

.dany-bubble-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: #6EE7A8;
    display: flex; align-items: center; justify-content: center;
    color: #0f1716; font-weight: 800; font-size: 17px;
    flex-shrink: 0;
    position: relative;
}
.dany-bubble-avatar::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #0f5132;
}

.dany-bubble-text {
    flex: 1; min-width: 0;
}
.dany-bubble-text .title {
    color: #fff; font-weight: 700; font-size: 13.5px; line-height: 1.2;
    margin-bottom: 2px;
}
.dany-bubble-text .sub {
    color: rgba(255,255,255,.85); font-size: 11.5px; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 200px;
}

.dany-bubble-close {
    background: rgba(0,0,0,.25);
    border: none; cursor: pointer;
    width: 22px; height: 22px; border-radius: 50%;
    color: #fff; font-size: 14px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
    margin-left: 4px;
}
.dany-bubble-close:hover { background: rgba(0,0,0,.45); }

@media (max-width: 480px) {
    .dany-bubble {
        right: 12px;
        bottom: var(--dany-bubble-bottom, 20px);
        max-width: 240px;
        padding: 8px 12px 8px 8px;
    }
    .dany-bubble-text .title { font-size: 12.5px; }
    .dany-bubble-text .sub   { font-size: 11px; max-width: 160px; }
    .dany-bubble-avatar      { width: 32px; height: 32px; font-size: 14px; }
}


/* Container fica ancorado no canto inferior direito — SEM backdrop, SEM blur.
   O usuário continua vendo a página por trás (UX de widget de atendimento).
   --dany-chat-bottom é setado via JS pra não sobrepor o navbar inferior. */
.dany-overlay {
    position: fixed;
    bottom: var(--dany-chat-bottom, 20px); right: 20px;
    z-index: 999998;
    display: none;
    pointer-events: none; /* deixa cliques passarem por fora do card */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.dany-overlay.open { display: block; }

.dany-card {
    width: 380px;
    height: 580px;
    max-height: calc(100vh - 40px);
    background: #0f1716;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.3);
    display: flex; flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    animation: danySlideUp .28s cubic-bezier(.16,1,.3,1);
    transform-origin: bottom right;
}
@keyframes danySlideUp {
    from { transform: translateY(20px) scale(.96); opacity: 0; }
    to   { transform: none; opacity: 1; }
}

/* Mobile: chat compacto no canto inferior direito (não tela cheia) */
@media (max-width: 480px) {
    .dany-overlay {
        bottom: var(--dany-chat-bottom, 20px);
        right: 12px;
        left: auto;
    }
    .dany-card {
        width: calc(100vw - 24px);
        max-width: 360px;
        height: 70vh;
        max-height: 560px;
        border-radius: 14px;
        margin: 0;
    }
}

/* Header */
.dany-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1a3d2f 0%, #0f5132 100%);
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.dany-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: #6EE7A8;
    display: flex; align-items: center; justify-content: center;
    color: #0f1716; font-weight: 800; font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(110,231,168,.3);
}
.dany-head-info { flex: 1; min-width: 0; }
.dany-head-info .name {
    color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2;
}
.dany-head-info .status {
    display: flex; align-items: center; gap: 4px;
    color: rgba(255,255,255,.7); font-size: 11px; margin-top: 2px;
}
.dany-head-info .status::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%;
    background: #6EE7A8; box-shadow: 0 0 6px #6EE7A8;
    display: inline-block;
}
.dany-close {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.7); font-size: 22px; padding: 4px 8px;
    line-height: 1; border-radius: 6px;
    transition: background .15s;
}
.dany-close:hover { background: rgba(255,255,255,.1); color: #fff; }

/* Menu ⋮ de opções */
.dany-menu-wrap { position: relative; flex-shrink: 0; }
.dany-menu-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.7); font-size: 20px; padding: 4px 8px;
    line-height: 1; border-radius: 6px;
    transition: background .15s;
}
.dany-menu-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.dany-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: #1a2420; border: 1px solid rgba(255,255,255,.1);
    border-radius: 10px; padding: 4px;
    min-width: 168px; z-index: 30;
    box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.dany-menu[hidden] { display: none; }
.dany-menu-item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    background: none; border: none; cursor: pointer;
    color: #e2e8f0; font-size: 13px; font-weight: 500;
    padding: 9px 11px; border-radius: 7px; text-align: left;
    transition: background .15s;
}
.dany-menu-item:hover { background: rgba(255,255,255,.07); }
.dany-menu-item svg { opacity: .75; flex-shrink: 0; }

/* Body — lista de mensagens */
.dany-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px 12px;
    background: #0a1110;
    display: flex; flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.15) transparent;
}
.dany-body::-webkit-scrollbar { width: 6px; }
.dany-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

/* Container que agrupa mensagem + horário */
.dany-row {
    display: flex; flex-direction: column;
    margin-bottom: 14px;
    max-width: 100%;
}
.dany-row.user { align-items: flex-end; }
.dany-row.assistant { align-items: flex-start; }
/* Espaçamento menor quando vem do mesmo lado seguido */
.dany-row + .dany-row.user.same { margin-top: -10px; }
.dany-row + .dany-row.assistant.same { margin-top: -10px; }

.dany-msg {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.dany-row.assistant .dany-msg {
    background: #1f2c2a;
    color: #e8f0ee;
    border-bottom-left-radius: 5px;
}
.dany-row.assistant.same .dany-msg {
    border-top-left-radius: 5px;
}
.dany-row.user .dany-msg {
    background: linear-gradient(135deg, #5db683, #3d8b5e);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.dany-row.user.same .dany-msg {
    border-top-right-radius: 5px;
}
.dany-msg img {
    max-width: 100%; max-height: 240px;
    border-radius: 10px; display: block; margin-top: 6px;
    cursor: zoom-in;
}
.dany-time {
    font-size: 10.5px;
    color: rgba(255,255,255,.42);
    margin-top: 4px;
    padding: 0 8px;
    letter-spacing: .2px;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.dany-row.same .dany-time { display: none; }

/* Ticks de visualização (estilo WhatsApp) — só aparecem em msgs do user */
.dany-tick {
    display: inline-flex;
    align-items: center;
    margin-left: 2px;
    color: rgba(255,255,255,.42); /* cinza = enviada */
    transition: color .25s ease;
    line-height: 0;
    position: relative;
    height: 11px;
}
.dany-tick svg {
    width: 14px;
    height: 11px;
    display: block;
    position: absolute;
    top: 0;
}
.dany-tick svg.t1 { left: 0; }
.dany-tick svg.t2 { left: 4px; opacity: 0; transition: opacity .25s ease; }
.dany-tick.read   { color: #4FC3F7; } /* azul WhatsApp = lida */
.dany-tick.read svg.t2 { opacity: 1; }
.dany-tick { width: 18px; }

/* ─── PIX Card (gerado pela Dany dentro do chat) ─── */
.dany-pix-card {
    background: linear-gradient(180deg, #0e1d18 0%, #0a1714 100%);
    border: 1px solid rgba(110,231,168,.35);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    width: 280px;
    max-width: 100%;
    color: #e8f0ee;
    box-sizing: border-box;
}
.dany-pix-card * { box-sizing: border-box; }

.dany-pix-card .head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid rgba(110,231,168,.18);
}
.dany-pix-card .head .icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: rgba(110,231,168,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6EE7A8;
    flex-shrink: 0;
}
.dany-pix-card .head .icon svg {
    width: 18px;
    height: 18px;
    display: block;
}
.dany-pix-card .head .info {
    flex: 1;
    min-width: 0;
}
.dany-pix-card .head .label {
    font-size: 10.5px;
    color: #6EE7A8;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .5px;
    line-height: 1;
}
.dany-pix-card .head .valor {
    font-size: 19px;
    font-weight: 800;
    color: #fff;
    line-height: 1.1;
    margin-top: 4px;
}

.dany-pix-card .qr {
    background: #fff;
    padding: 10px;
    border-radius: 10px;
    width: 172px;
    height: 172px;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dany-pix-card .qr canvas,
.dany-pix-card .qr img,
.dany-pix-card .qr table {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.dany-pix-card .codigo-wrap {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 10px;
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 10.5px;
    color: rgba(255,255,255,.6);
    line-height: 1.45;
    word-break: break-all;
    overflow-wrap: anywhere;
    max-height: 60px;
    overflow: hidden;
}

.dany-pix-card button.copy {
    width: 100%;
    background: linear-gradient(135deg, #4ec88a, #3aa572);
    color: #ffffff;
    border: none;
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 13.5px;
    letter-spacing: .2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(78,200,138,.25);
    transition: background .15s, transform .12s;
    margin-bottom: 10px;
}
.dany-pix-card button.copy svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.dany-pix-card button.copy:hover {
    background: linear-gradient(135deg, #5bd29b, #43b780);
    transform: translateY(-1px);
}
.dany-pix-card button.copy:active { transform: translateY(0); }
.dany-pix-card button.copy.copied {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}
.dany-pix-card button.copy.disabled,
.dany-pix-card.paid button.copy,
.dany-pix-card.expired button.copy,
.dany-pix-card.cancelled button.copy {
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.55);
    cursor: not-allowed;
    box-shadow: none;
    transform: none !important;
}

.dany-pix-card .footer-info {
    font-size: 11px;
    color: rgba(255,255,255,.45);
    text-align: center;
    margin: 0;
}

.dany-pix-card.paid {
    border-color: rgba(34,197,94,.5);
    background: linear-gradient(180deg, rgba(34,197,94,.08), #0a1714);
}
.dany-pix-card.paid .head .icon {
    background: rgba(34,197,94,.2);
    color: #22c55e;
}
.dany-pix-card.expired,
.dany-pix-card.cancelled {
    opacity: .7;
    border-color: rgba(255,255,255,.1);
}

.dany-typing {
    align-self: flex-start;
    display: inline-flex; gap: 4px; padding: 12px 14px;
    background: #1f2c2a; border-radius: 16px;
    border-bottom-left-radius: 5px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.dany-typing span {
    width: 7px; height: 7px; border-radius: 50%;
    background: #6EE7A8;
    animation: danyDot 1s infinite;
}
.dany-typing span:nth-child(2) { animation-delay: 0.15s; }
.dany-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes danyDot {
    0%, 60%, 100% { opacity: .3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* Footer — input */
.dany-foot {
    border-top: 1px solid rgba(255,255,255,.08);
    background: #131c1b;
    padding: 10px 12px;
    display: flex; align-items: flex-end; gap: 8px;
}
.dany-attach {
    background: none; border: none; cursor: pointer;
    color: #6EE7A8; font-size: 22px; padding: 4px 6px;
    border-radius: 6px; line-height: 1; flex-shrink: 0;
    transition: background .15s;
}
.dany-attach:hover { background: rgba(110,231,168,.1); }
.dany-attach input { display: none; }

.dany-input {
    flex: 1;
    background: #1c2725;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 18px;
    padding: 9px 14px;
    /* iOS Safari dá auto-zoom em input com font < 16px — força 16px com !important
       caso a página host tenha CSS conflitante */
    color: #fff;
    font-size: 16px !important;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    touch-action: manipulation;
    outline: none; resize: none;
    min-height: 40px; max-height: 100px;
    font-family: inherit;
    line-height: 1.4;
}
.dany-input:focus { border-color: rgba(110,231,168,.4); }

.dany-send {
    background: linear-gradient(135deg, #6EE7A8, #4ec88a);
    border: none; cursor: pointer;
    width: 38px; height: 38px; border-radius: 50%;
    color: #0f1716; font-size: 16px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform .12s;
}
.dany-send:hover { transform: scale(1.08); }
.dany-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Atalho — botão "Já paguei" / sugestões rápidas */
.dany-quick {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 0 14px 8px;
    background: #0a1110;
}
.dany-quick button {
    background: rgba(110,231,168,.12);
    border: 1px solid rgba(110,231,168,.3);
    color: #6EE7A8;
    padding: 6px 14px; border-radius: 16px;
    font-size: 12.5px; font-weight: 600; cursor: pointer;
    transition: all .15s;
}
.dany-quick button:hover {
    background: rgba(110,231,168,.2);
    border-color: rgba(110,231,168,.5);
}
