/* ============================================================
   ZUPI CHAT WIDGET (prefix: zcw-)  2026-09-03
   Floating WhatsApp launcher + assistant panel (marketing pages).
   Pairs with js/zupi-chat-widget.js + partials/zupi-chat-widget.blade.php
   Revert: bash /root/zupichat-chatwidget-revert.sh
   ============================================================ */
.zcw {
    --zcw-teal: #0a474c;
    --zcw-teal-ink: #073539;
    --zcw-green: #25d366;
    --zcw-green-ink: #1da851;
    --zcw-ink: #12282a;
    --zcw-muted: #6a7c7d;
    --zcw-line: #dfe8e7;
    --zcw-tint: #e6f0ef;
    --zcw-bg: #f3f7f6;
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--zcw-ink);
    -webkit-font-smoothing: antialiased;
}
.zcw *, .zcw *::before, .zcw *::after { box-sizing: border-box; }
.zcw button { font: inherit; }

/* ---------- Button row: [robot = AI panel] [green = WhatsApp direct] ---------- */
.zcw-btns {
    display: flex;
    flex-direction: column; /* robot upar, WhatsApp neeche */
    align-items: flex-end;
    gap: 12px;
}
.zcw-launcher,
.zcw-wa {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.18s ease-out, box-shadow 0.18s ease-out, background-color 0.18s ease-out;
}
.zcw-launcher {
    background: var(--zcw-teal);
    box-shadow: 0 1px 2px rgba(10, 71, 76, 0.2), 0 10px 24px -6px rgba(10, 71, 76, 0.55);
}
.zcw-wa {
    background: var(--zcw-green);
    box-shadow: 0 1px 2px rgba(10, 71, 76, 0.18), 0 10px 24px -6px rgba(37, 211, 102, 0.55);
}
.zcw-launcher::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--zcw-teal);
    opacity: 0;
    animation: zcwPulse 2.6s ease-out 1.2s 3;
    pointer-events: none;
}
@keyframes zcwPulse {
    0%   { transform: scale(1);   opacity: 0.7; }
    100% { transform: scale(1.7); opacity: 0; }
}
.zcw-launcher:hover { transform: translateY(-2px) scale(1.04); background: var(--zcw-teal-ink); box-shadow: 0 2px 4px rgba(10, 71, 76, 0.2), 0 16px 32px -8px rgba(10, 71, 76, 0.6); }
.zcw-wa:hover { transform: translateY(-2px) scale(1.04); background: var(--zcw-green-ink); box-shadow: 0 2px 4px rgba(10, 71, 76, 0.18), 0 16px 32px -8px rgba(37, 211, 102, 0.6); text-decoration: none; color: #fff; }
.zcw-launcher:active, .zcw-wa:active { transform: scale(0.96); }
.zcw-launcher:focus-visible { outline: 3px solid rgba(10, 71, 76, 0.4); outline-offset: 3px; }
.zcw-wa:focus-visible { outline: 3px solid rgba(37, 211, 102, 0.45); outline-offset: 3px; }
.zcw-launcher svg, .zcw-wa svg { width: 30px; height: 30px; fill: #fff; transition: opacity 0.18s ease-out, transform 0.18s ease-out; }
.zcw-launcher .zcw-ic-bot { width: 32px; height: 32px; }
.zcw-eye { fill: var(--zcw-teal); }
.zcw-launcher .zcw-ic-x { position: absolute; width: 22px; height: 22px; opacity: 0; transform: rotate(-90deg) scale(0.6); }
.zcw.is-open .zcw-launcher::before { animation: none; }
.zcw.is-open .zcw-launcher .zcw-ic-bot { opacity: 0; transform: rotate(90deg) scale(0.6); }
.zcw.is-open .zcw-launcher .zcw-ic-x { opacity: 1; transform: rotate(0) scale(1); }
.zcw-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--zcw-teal);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid #fff;
}
.zcw-badge[hidden] { display: none !important; }

/* ---------- Teaser label ---------- */
.zcw-label {
    position: absolute;
    right: 72px;
    bottom: 84px; /* robot button (upar wala) ke beech me */
    padding: 9px 14px;
    border-radius: 12px;
    background: #fff;
    color: var(--zcw-ink);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid var(--zcw-line);
    box-shadow: 0 1px 2px rgba(10, 71, 76, 0.06), 0 8px 20px -6px rgba(10, 71, 76, 0.25);
    opacity: 0;
    transform: translateX(6px);
    pointer-events: none;
    transition: opacity 0.22s ease-out, transform 0.22s ease-out;
}
.zcw-label::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    width: 10px;
    height: 10px;
    margin-top: -5px;
    background: #fff;
    border-right: 1px solid var(--zcw-line);
    border-top: 1px solid var(--zcw-line);
    transform: rotate(45deg);
}
.zcw-label.is-on { opacity: 1; transform: translateX(0); pointer-events: auto; cursor: pointer; }
.zcw-label[hidden] { display: none !important; }

/* ---------- Panel ---------- */
.zcw-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 148px; /* dono buttons (60+12+60) + 16 gap */
    width: 372px;
    max-width: calc(100vw - 24px);
    height: min(600px, calc(100vh - 180px));
    flex-direction: column;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--zcw-line);
    box-shadow: 0 2px 6px rgba(10, 71, 76, 0.08), 0 28px 64px -18px rgba(10, 71, 76, 0.4);
    transform-origin: bottom right;
}
.zcw.is-open .zcw-panel { display: flex; animation: zcwIn 0.22s ease-out; }
@keyframes zcwIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.zcw-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: var(--zcw-teal);
    color: #fff;
}
.zcw-avatar {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.zcw-avatar svg { width: 24px; height: 24px; fill: var(--zcw-teal); }
.zcw-avatar .zcw-eye { fill: #fff; }
.zcw-avatar::after {
    content: '';
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--zcw-green);
    border: 2px solid var(--zcw-teal);
}
.zcw-title { flex: 1; min-width: 0; }
.zcw-title b { display: block; font-size: 15px; font-weight: 700; line-height: 1.2; }
.zcw-title span { display: block; font-size: 12px; opacity: 0.78; margin-top: 2px; }
.zcw-close {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease-out, transform 0.15s ease-out;
}
.zcw-close:hover { background: rgba(255, 255, 255, 0.12); }
.zcw-close:active { transform: scale(0.94); }
.zcw-close:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.7); outline-offset: 1px; }
.zcw-close svg { width: 16px; height: 16px; fill: #fff; }

.zcw-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 14px 8px;
    background: var(--zcw-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}
.zcw-msg {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-line;
    word-wrap: break-word;
    animation: zcwMsg 0.2s ease-out;
}
@keyframes zcwMsg {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.zcw-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: var(--zcw-ink);
    border: 1px solid var(--zcw-line);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(10, 71, 76, 0.05);
}
.zcw-msg.user {
    align-self: flex-end;
    background: var(--zcw-teal);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.zcw-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid var(--zcw-line);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.zcw-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--zcw-muted);
    opacity: 0.5;
    animation: zcwDot 1s ease-in-out infinite;
}
.zcw-typing i:nth-child(2) { animation-delay: 0.15s; }
.zcw-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes zcwDot {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50%      { transform: translateY(-4px); opacity: 1; }
}
.zcw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 0 6px;
    animation: zcwMsg 0.2s ease-out;
}
.zcw-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 7px 13px;
    border-radius: 999px;
    border: 1px solid rgba(10, 71, 76, 0.35);
    background: #fff;
    color: var(--zcw-teal);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease-out, border-color 0.15s ease-out, transform 0.15s ease-out, color 0.15s ease-out;
}
.zcw-chip:hover { background: var(--zcw-tint); border-color: var(--zcw-teal); color: var(--zcw-teal); text-decoration: none; }
.zcw-chip:active { transform: scale(0.97); }
.zcw-chip:focus-visible { outline: 2px solid var(--zcw-teal); outline-offset: 2px; }
.zcw-chip.wa { background: var(--zcw-green); border-color: var(--zcw-green); color: #fff; }
.zcw-chip.wa:hover { background: var(--zcw-green-ink); border-color: var(--zcw-green-ink); color: #fff; }
.zcw-chip svg { width: 15px; height: 15px; fill: currentColor; }

.zcw-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px 10px 14px;
    border-top: 1px solid var(--zcw-line);
    background: #fff;
}
.zcw-input {
    flex: 1;
    min-width: 0;
    height: 40px;
    padding: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--zcw-ink);
    font: inherit;
    font-size: 14px;
}
.zcw-input::placeholder { color: var(--zcw-muted); }
.zcw-send {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--zcw-teal);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease-out, transform 0.15s ease-out, opacity 0.15s ease-out;
}
.zcw-send:hover { background: var(--zcw-teal-ink); }
.zcw-send:active { transform: scale(0.94); }
.zcw-send:disabled { opacity: 0.45; cursor: default; transform: none; }
.zcw-send:focus-visible { outline: 2px solid var(--zcw-teal); outline-offset: 2px; }
.zcw-send svg { width: 18px; height: 18px; fill: #fff; margin-left: 2px; }
.zcw-note {
    padding: 0 14px 10px;
    background: #fff;
    font-size: 11px;
    color: var(--zcw-muted);
    text-align: center;
}

/* ---------- Scroll-to-top button: keep it clear of the launcher ---------- */
@media (min-width: 601px) {
    .scroll-top { bottom: 34px !important; right: 104px !important; } /* WhatsApp button ke baayein */
}
body:has(.zcw.is-open) .scroll-top { opacity: 0 !important; pointer-events: none !important; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
    .zcw { right: 14px; bottom: 16px; }
    .zcw-btns { gap: 10px; }
    .zcw-launcher, .zcw-wa { width: 52px; height: 52px; }
    .zcw-launcher svg, .zcw-wa svg { width: 26px; height: 26px; }
    .zcw-launcher .zcw-ic-bot { width: 28px; height: 28px; }
    .zcw-launcher .zcw-ic-x { width: 20px; height: 20px; }
    .zcw-label { right: 62px; bottom: 71px; }
    .zcw-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 146px; /* .zcw bottom 16 + buttons 52+10+52 + 16 gap */
        width: auto;
        max-width: none;
        height: auto;
        max-height: calc(100vh - 162px);
        max-height: calc(100dvh - 162px);
    }
    .zcw-input { font-size: 16px; } /* iOS zoom guard */
    .zcw-msg { max-width: 90%; }
}

/* ---------- App screens / print / reduced motion ---------- */
body:has(.chatbox-area) .zcw,
body:has(.zc-sidebar) .zcw { display: none !important; }
@media print { .zcw { display: none !important; } }
@media (prefers-reduced-motion: reduce) {
    .zcw-launcher::before { animation: none; }
    .zcw.is-open .zcw-panel, .zcw-msg, .zcw-chips { animation: none; }
    .zcw-typing i { animation: none; opacity: 0.7; }
    .zcw-launcher, .zcw-label, .zcw-chip, .zcw-send, .zcw-close { transition: none; }
    .zcw-body { scroll-behavior: auto; }
}
