/* =====================================================
   WhatsApp Chat Widget — widget.css  v2.0
   ===================================================== */

#wac-wrapper *, #wac-wrapper *::before, #wac-wrapper *::after {
    box-sizing: border-box; margin: 0; padding: 0;
}

#wac-wrapper {
    position: fixed;
    bottom: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#wac-wrapper.wac-pos-right { right: 24px; }
#wac-wrapper.wac-pos-left  { left: 24px; }

/* ---- Toggle button ---- */
#wac-toggle {
    width: 60px; height: 60px;
    border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    transition: transform .2s, box-shadow .2s;
    color: #fff; position: relative; z-index: 2;
}
#wac-toggle:hover  { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,.35); }
#wac-toggle:active { transform: scale(.96); }
#wac-toggle svg { width: 28px; height: 28px; }

.wac-icon-close { display: none; }
.wac-open .wac-icon-open  { display: none; }
.wac-open .wac-icon-close { display: flex; }

.wac-badge {
    position: absolute; top: 2px; right: 2px;
    width: 14px; height: 14px;
    background: #ff3b30; border-radius: 50%; border: 2px solid #fff;
    display: none;
    animation: wac-pulse 1.5s infinite;
}
.wac-badge.visible { display: block; }
@keyframes wac-pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.2)} }

/* ---- CTA tooltip ---- */
.wac-cta {
    position: absolute; bottom: 70px;
    background: #fff; color: #333;
    font-size: 13px; font-weight: 600;
    padding: 8px 14px; border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    pointer-events: none;
    opacity: 0; transform: translateY(6px);
    transition: opacity .3s, transform .3s;
}
.wac-pos-right .wac-cta { right: 0; }
.wac-pos-left  .wac-cta { left: 0; }
.wac-cta.show { opacity: 1; transform: translateY(0); }

/* ---- Chat box ---- */
#wac-box {
    position: absolute;
    bottom: 76px;
    width: 360px;
    background: #ece5dd;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    max-height: 580px;
}
.wac-pos-right #wac-box { right: 0; }
.wac-pos-left  #wac-box { left: 0; }
#wac-box[hidden] { display: none !important; }

#wac-box.wac-animate-in {
    animation: wac-open .25s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes wac-open {
    from { opacity: 0; transform: scale(.92) translateY(10px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ---- Header ---- */
.wac-header {
    padding: 14px 16px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-shrink: 0;
}
.wac-header-inner { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.wac-back-btn {
    background: none; border: none; cursor: pointer;
    color: rgba(255,255,255,.85); display: flex; padding: 4px;
    flex-shrink: 0; transition: color .15s;
}
.wac-back-btn:hover { color: #fff; }
.wac-back-btn svg { width: 20px; height: 20px; }
.wac-back-btn[hidden] { display: none; }

.wac-header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden;
}
.wac-header-avatar svg   { width: 22px; height: 22px; fill: #fff; }
.wac-header-avatar img   { width: 100%; height: 100%; object-fit: cover; }
.wac-header-avatar span  { font-size: 17px; font-weight: 700; color: #fff; }

.wac-header-text { min-width: 0; }
.wac-header-title { font-size: 15px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wac-header-sub   { font-size: 11px; color: rgba(255,255,255,.8); margin-top: 1px; }

.wac-close-btn {
    background: none; border: none; cursor: pointer;
    padding: 4px; color: rgba(255,255,255,.8);
    display: flex; flex-shrink: 0; transition: color .2s;
}
.wac-close-btn:hover { color: #fff; }
.wac-close-btn svg { width: 20px; height: 20px; }

/* ---- Screens ---- */
.wac-screen { display: flex; flex-direction: column; }
.wac-screen[hidden], .wac-screen:not(.wac-screen--active):not([hidden]) { display: none; }
.wac-screen--active { display: flex; }

/* ---- Screen 1: agents ---- */
.wac-body-greeting {
    padding: 16px;
    background: #ece5dd;
}
.wac-greeting-bubble {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    padding: 12px 14px;
    max-width: 88%;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
    position: relative;
}
.wac-greeting-bubble::before {
    content: '';
    position: absolute; top: 0; left: -8px;
    border-top: 8px solid #fff; border-left: 8px solid transparent;
}
.wac-greeting-bubble p    { font-size: 14px; line-height: 1.5; color: #333; }
.wac-greeting-bubble .wac-time { display: block; font-size: 11px; color: #999; margin-top: 6px; text-align: right; }

.wac-agents-list { background: #fff; border-top: 1px solid #e8e8e8; }

.wac-agent-btn {
    width: 100%; display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; background: none; border: none;
    border-bottom: 1px solid #f0f0f0; cursor: pointer;
    text-align: left; transition: background .15s;
}
.wac-agent-btn:last-child { border-bottom: none; }
.wac-agent-btn:hover { background: #f9f9f9; }

.wac-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: #25D366;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; position: relative; overflow: hidden;
}
.wac-avatar img  { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.wac-avatar span { font-size: 18px; font-weight: 700; color: #fff; }
.wac-online-dot {
    width: 11px; height: 11px; background: #44b700;
    border-radius: 50%; border: 2px solid #fff;
    position: absolute; bottom: 1px; right: 1px;
}

.wac-agent-info        { flex: 1; }
.wac-agent-info strong { display: block; font-size: 14px; color: #111; font-weight: 600; }
.wac-agent-info small  { font-size: 12px; color: #777; }

.wac-agent-arrow { color: #ccc; width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Screen 2: chat ---- */
#wac-screen-chat { height: 440px; }

.wac-messages {
    flex: 1; overflow-y: auto;
    padding: 14px 12px;
    display: flex; flex-direction: column; gap: 6px;
    background: #ece5dd;
    scroll-behavior: smooth;
}
.wac-messages::-webkit-scrollbar { width: 4px; }
.wac-messages::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }

/* Bubbles */
.wac-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
    animation: wac-bubble .18s ease;
}
@keyframes wac-bubble { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:none} }

.wac-msg--agent {
    background: #fff;
    border-radius: 0 8px 8px 8px;
    align-self: flex-start;
    color: #222;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
}
.wac-msg--agent::before {
    content: '';
    position: absolute; top: 0; left: -7px;
    border-top: 7px solid #fff; border-left: 7px solid transparent;
}

.wac-msg--user {
    background: #dcf8c6;
    border-radius: 8px 0 8px 8px;
    align-self: flex-end;
    color: #222;
    box-shadow: 0 1px 1px rgba(0,0,0,.1);
}
.wac-msg--user::after {
    content: '';
    position: absolute; top: 0; right: -7px;
    border-top: 7px solid #dcf8c6; border-right: 7px solid transparent;
}

.wac-msg-time {
    display: block;
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}
.wac-msg--user .wac-msg-time { text-align: right; }

/* Read ticks */
.wac-ticks { font-size: 11px; color: #34b7f1; margin-left: 3px; }

/* Typing indicator */
.wac-typing {
    display: flex; gap: 4px; align-items: center;
    padding: 10px 14px;
    background: #fff;
    border-radius: 0 14px 14px 14px;
    width: fit-content;
    margin: 0 12px 8px;
    box-shadow: 0 1px 1px rgba(0,0,0,.08);
}
.wac-typing[hidden] { display: none; }
.wac-typing span {
    width: 7px; height: 7px; background: #aaa;
    border-radius: 50%;
    animation: wac-blink 1.2s infinite;
}
.wac-typing span:nth-child(2) { animation-delay: .2s; }
.wac-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes wac-blink { 0%,80%,100%{transform:scale(1);opacity:.4} 40%{transform:scale(1.2);opacity:1} }

/* ---- Input bar ---- */
.wac-input-bar {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px;
    background: #f0f0f0;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.wac-input {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 14px;
    background: #fff;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    color: #333;
}
.wac-input::placeholder { color: #aaa; }

.wac-send-btn {
    width: 40px; height: 40px; border-radius: 50%;
    border: none; cursor: pointer;
    background: #25D366;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .2s, transform .15s, opacity .2s;
    opacity: .45;
}
.wac-send-btn:not(:disabled) { opacity: 1; }
.wac-send-btn:not(:disabled):hover  { background: #1ebe5d; }
.wac-send-btn:not(:disabled):active { transform: scale(.92); }
.wac-send-btn svg { width: 18px; height: 18px; }

/* ---- Footer chat (open in WA) ---- */
.wac-footer-chat {
    background: #f0f0f0;
    border-top: 1px solid #e0e0e0;
    padding: 8px;
    text-align: center;
    flex-shrink: 0;
}
.wac-open-wa-btn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600;
    color: #075E54; text-decoration: none;
    padding: 5px 14px; border-radius: 20px;
    border: 1.5px solid #075E54;
    transition: background .15s, color .15s;
}
.wac-open-wa-btn svg { fill: #075E54; transition: fill .15s; }
.wac-open-wa-btn:hover { background: #075E54; color: #fff; }
.wac-open-wa-btn:hover svg { fill: #fff; }

/* ---- Responsive ---- */
@media (max-width: 400px) {
    #wac-box { width: calc(100vw - 20px); }
    #wac-wrapper { bottom: 16px; }
    #wac-wrapper.wac-pos-right { right: 10px; }
    #wac-wrapper.wac-pos-left  { left: 10px; }
    #wac-screen-chat { height: 400px; }
}

@media (prefers-reduced-motion: reduce) {
    #wac-box.wac-animate-in, .wac-msg { animation: none; }
    .wac-badge { animation: none; }
}
