/* ============================================================
   ATE CHAT WIDGET — ate-chat.css
   Enqueue via functions.php
   WhatsApp FAB: bottom-left
   Chat Widget:  bottom-right
   ============================================================ */

/* ── CSS Variables ── */
:root {
    --ate-green:       #0e8b25;
    --ate-green-deep:  #096319;
    --ate-green-light: #DDF9C1;
    --ate-white:       #ffffff;
    --ate-offwhite:    #f7f9f5;
    --ate-text:        #1a1a1a;
    --ate-text-muted:  #6b7280;
    --ate-shadow:      0 8px 32px rgba(0,0,0,0.18);
    --ate-radius:      16px;
    --ate-fab-size:    56px;
}

/* ════════════════════════════════════════
   WHATSAPP FAB — bottom-left
════════════════════════════════════════ */
.ate-whatsapp-fab {
    position: fixed;
    bottom: 28px;
    left: 24px;
    z-index: 9998;
    width: var(--ate-fab-size);
    height: var(--ate-fab-size);
    background-color: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(37,211,102,0.4);
    text-decoration: none;
    transition: transform 0.22s cubic-bezier(.34,1.56,.64,1),
                box-shadow 0.22s ease;
}

.ate-whatsapp-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(37,211,102,0.55);
}

.ate-whatsapp-fab svg {
    display: block;
}

/* Tooltip */
.ate-whatsapp-fab::after {
    content: 'Chat on WhatsApp';
    position: absolute;
    left: calc(100% + 12px);
    bottom: 50%;
    transform: translateY(50%);
    background: #1a1a1a;
    color: #fff;
    font-family: 'Public Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.ate-whatsapp-fab:hover::after {
    opacity: 1;
}


/* ════════════════════════════════════════
   CHAT LAUNCHER FAB — bottom-right
════════════════════════════════════════ */
.ate-chat-fab {
    position: fixed;
    bottom: 28px;
    right: 24px;
    z-index: 9998;
    width: var(--ate-fab-size);
    height: var(--ate-fab-size);
    background: var(--ate-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(14,139,37,0.4);
    border: none;
    outline: none;
    transition: transform 0.22s cubic-bezier(.34,1.56,.64,1),
                box-shadow 0.22s ease,
                background 0.18s ease;
}

.ate-chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(14,139,37,0.55);
    background: var(--ate-green-deep);
}

.ate-chat-fab .ate-chat-icon,
.ate-chat-fab .ate-close-icon {
    position: absolute;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ate-chat-fab .ate-close-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.ate-chat-fab.is-open .ate-chat-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.ate-chat-fab.is-open .ate-close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Tooltip */
.ate-chat-fab::after {
    content: 'Chat with us';
    position: absolute;
    right: calc(100% + 12px);
    bottom: 50%;
    transform: translateY(50%);
    background: #1a1a1a;
    color: #fff;
    font-family: 'Public Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 10px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.ate-chat-fab:not(.is-open):hover::after {
    opacity: 1;
}

/* Unread badge */
.ate-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
    font-family: 'Public Sans', sans-serif;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ate-chat-badge.visible {
    opacity: 1;
    transform: scale(1);
}


/* ════════════════════════════════════════
   CHAT WINDOW
════════════════════════════════════════ */
.ate-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9997;
    width: 360px;
    max-height: 520px;
    background: var(--ate-white);
    border-radius: var(--ate-radius);
    box-shadow: var(--ate-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease,
                transform 0.25s cubic-bezier(.34,1.4,.64,1);
    transform-origin: bottom right;
}

.ate-chat-window.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ── */
.ate-chat-header {
    background: var(--ate-green);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.ate-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ate-green-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.ate-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ate-chat-avatar-initials {
    font-family: 'Cinzel', serif;
    font-size: 15px;
    font-weight: 700;
    color: var(--ate-green-deep);
    line-height: 1;
}

.ate-chat-header-info {
    flex: 1;
    min-width: 0;
}

.ate-chat-header-name {
    font-family: 'Cinzel', serif;
    font-size: 14px;
    font-weight: 700;
    color: var(--ate-white);
    line-height: 1.2;
}

.ate-chat-header-status {
    font-family: 'Public Sans', sans-serif;
    font-size: 12px;
    color: var(--ate-green-light);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ate-chat-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
    animation: ate-pulse 2s infinite;
}

@keyframes ate-pulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
    50%       { box-shadow: 0 0 0 5px rgba(74,222,128,0.0); }
}

/* ── Messages area ── */
.ate-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--ate-offwhite);
    scroll-behavior: smooth;
}

.ate-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.ate-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ate-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* Individual message bubbles */
.ate-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: ate-msg-in 0.2s ease forwards;
}

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

.ate-msg.ate-msg--agent {
    align-self: flex-start;
    align-items: flex-start;
}

.ate-msg.ate-msg--visitor {
    align-self: flex-end;
    align-items: flex-end;
}

.ate-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-family: 'Public Sans', sans-serif;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ate-text);
}

.ate-msg--agent .ate-msg-bubble {
    background: var(--ate-white);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.ate-msg--visitor .ate-msg-bubble {
    background: var(--ate-green);
    color: var(--ate-white);
    border-bottom-right-radius: 4px;
}

.ate-msg-time {
    font-family: 'Public Sans', sans-serif;
    font-size: 11px;
    color: var(--ate-text-muted);
    margin-top: 4px;
    padding: 0 4px;
}

/* Typing indicator */
.ate-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ate-white);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.ate-typing-indicator span {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: ate-typing 1.2s infinite ease-in-out;
}

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

@keyframes ate-typing {
    0%, 60%, 100% { transform: translateY(0); background: #9ca3af; }
    30%            { transform: translateY(-5px); background: var(--ate-green); }
}

/* ── Input form ── */
.ate-chat-form-wrap {
    flex-shrink: 0;
    border-top: 1px solid #e5e7eb;
    background: var(--ate-white);
}

/* Pre-form: Name + Email capture */
.ate-chat-precapture {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ate-chat-precapture p {
    font-family: 'Public Sans', sans-serif;
    font-size: 12.5px;
    color: var(--ate-text-muted);
    margin: 0 0 4px;
}

.ate-chat-field {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-family: 'Public Sans', sans-serif;
    font-size: 13px;
    color: var(--ate-text);
    background: var(--ate-offwhite);
    outline: none;
    transition: border-color 0.18s ease;
    box-sizing: border-box;
}

.ate-chat-field:focus {
    border-color: var(--ate-green);
    background: #fff;
}

.ate-chat-start-btn {
    width: 100%;
    padding: 10px;
    background: var(--ate-green);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Public Sans', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease;
    margin-top: 2px;
}

.ate-chat-start-btn:hover {
    background: var(--ate-green-deep);
}

/* Message input row */
.ate-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
}

.ate-chat-input {
    flex: 1;
    resize: none;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    padding: 9px 12px;
    font-family: 'Public Sans', sans-serif;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--ate-text);
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.18s ease;
    background: var(--ate-offwhite);
}

.ate-chat-input:focus {
    border-color: var(--ate-green);
    background: #fff;
}

.ate-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--ate-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.18s ease, transform 0.15s ease;
}

.ate-chat-send-btn:hover {
    background: var(--ate-green-deep);
    transform: scale(1.05);
}

.ate-chat-send-btn:active {
    transform: scale(0.95);
}

/* Success / error notices */
.ate-chat-notice {
    padding: 10px 16px;
    font-family: 'Public Sans', sans-serif;
    font-size: 12.5px;
    text-align: center;
    display: none;
}

.ate-chat-notice.success { color: var(--ate-green-deep); }
.ate-chat-notice.error   { color: #dc2626; }
.ate-chat-notice.visible { display: block; }

/* ── Powered-by footer ── */
.ate-chat-footer {
    padding: 6px 16px 8px;
    text-align: center;
    font-family: 'Public Sans', sans-serif;
    font-size: 10.5px;
    color: #d1d5db;
    border-top: 1px solid #f3f4f6;
}

.ate-chat-footer a {
    color: #9ca3af;
    text-decoration: none;
}


/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 480px) {
    .ate-chat-window {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-height: 75vh;
        border-radius: var(--ate-radius) var(--ate-radius) 0 0;
    }

    .ate-chat-fab {
        right: 16px;
        bottom: 20px;
    }

    .ate-whatsapp-fab {
        left: 16px;
        bottom: 20px;
    }

    .ate-whatsapp-fab::after,
    .ate-chat-fab::after {
        display: none;
    }
}
