/* ================================================================
   UMT WhatsApp Multi-Agent — style.css  v1.2.4
   Critical fix: removed will-change and inset from FAB — these
   break position:fixed rendering on real Android Chrome.
   ================================================================ */

/* ── Reset ────────────────────────────────────────────────── */
#umt-wa-wrapper,
#umt-wa-wrapper * {
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ── Wrapper ──────────────────────────────────────────────── */
/* NOTE: position, display, bottom, right/left are set as INLINE
   styles in PHP (public-display.php) so no cache plugin can hide
   them. This block only adds non-critical CSS-only properties.   */
#umt-wa-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    /* No will-change, no transform here — keeps position:fixed intact */
}

/* ── FAB ──────────────────────────────────────────────────── */
.umt-wa-fab {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #25D366;
    border: none;
    cursor: pointer;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    /* NO will-change here — it creates a new stacking context inside
       position:fixed which breaks rendering on Android Chrome        */
    -webkit-box-shadow:
        0 4px 16px rgba(37, 211, 102, 0.50),
        0 2px 6px  rgba(0, 0, 0, 0.18);
    box-shadow:
        0 4px 16px rgba(37, 211, 102, 0.50),
        0 2px 6px  rgba(0, 0, 0, 0.18);
    -webkit-transition: -webkit-transform 0.20s cubic-bezier(0.34, 1.56, 0.64, 1),
                        box-shadow 0.18s ease;
    transition: transform 0.20s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    -webkit-align-self: flex-end;
    align-self: flex-end;
}
#umt-wa-wrapper.umt-wa-pos-left .umt-wa-fab {
    -webkit-align-self: flex-start;
    align-self: flex-start;
}
.umt-wa-fab:hover {
    -webkit-transform: scale(1.08);
    transform: scale(1.08);
}
.umt-wa-fab:active {
    -webkit-transform: scale(0.94);
    transform: scale(0.94);
}

/* Pulse ring — using top/left/right/bottom instead of inset
   (inset is not supported in older Android WebView / Chrome 86-)  */
.umt-wa-fab::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: 50%;
    background: rgba(37, 211, 102, 0.40);
    -webkit-animation: umt-pulse 2.8s ease-out infinite;
    animation: umt-pulse 2.8s ease-out infinite;
    pointer-events: none;
    /* NO will-change — causes compositor layer issues on Android */
}
.umt-wa-fab.is-open::before {
    -webkit-animation: none;
    animation: none;
    opacity: 0;
}
@-webkit-keyframes umt-pulse {
    0%   { -webkit-transform: scale(1);   opacity: 0.75; }
    70%  { -webkit-transform: scale(1.7); opacity: 0;    }
    100% { -webkit-transform: scale(1.7); opacity: 0;    }
}
@keyframes umt-pulse {
    0%   { transform: scale(1);   opacity: 0.75; }
    70%  { transform: scale(1.7); opacity: 0;    }
    100% { transform: scale(1.7); opacity: 0;    }
}

/* FAB icons */
.umt-wa-fab-icon {
    position: absolute;
    -webkit-transition: opacity 0.18s ease,
                        -webkit-transform 0.20s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: opacity 0.18s ease,
                transform 0.20s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* NO will-change */
}
.umt-wa-fab-icon--open {
    opacity: 1;
    -webkit-transform: rotate(0deg) scale(1);
    transform: rotate(0deg) scale(1);
}
.umt-wa-fab-icon--close {
    opacity: 0;
    -webkit-transform: rotate(-90deg) scale(0.4);
    transform: rotate(-90deg) scale(0.4);
}
.umt-wa-fab.is-open .umt-wa-fab-icon--open {
    opacity: 0;
    -webkit-transform: rotate(90deg) scale(0.4);
    transform: rotate(90deg) scale(0.4);
}
.umt-wa-fab.is-open .umt-wa-fab-icon--close {
    opacity: 1;
    -webkit-transform: rotate(0deg) scale(1);
    transform: rotate(0deg) scale(1);
}

/* Badge */
.umt-wa-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e53935;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    border: 2px solid #fff;
    -webkit-transition: -webkit-transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s;
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s;
    pointer-events: none;
}
.umt-wa-fab.is-open .umt-wa-badge {
    -webkit-transform: scale(0);
    transform: scale(0);
    opacity: 0;
}

/* ── Dialog ───────────────────────────────────────────────── */
#umt-wa-dialog {
    width: 350px;
    max-width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #f0f2f5;
    -webkit-box-shadow: 0 12px 40px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.10);
    box-shadow: 0 12px 40px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.10);
    opacity: 0;
    -webkit-transform: translateY(14px) scale(0.96);
    transform: translateY(14px) scale(0.96);
    -webkit-transform-origin: bottom right;
    transform-origin: bottom right;
    pointer-events: none;
    /* NO will-change on dialog either */
    -webkit-transition: opacity 0.24s ease,
                        -webkit-transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: opacity 0.24s ease,
                transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#umt-wa-wrapper.umt-wa-pos-left #umt-wa-dialog {
    -webkit-transform-origin: bottom left;
    transform-origin: bottom left;
}
#umt-wa-dialog.is-visible {
    opacity: 1;
    -webkit-transform: translateY(0) scale(1);
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header — padding set inline by PHP; these are fallbacks ── */
.umt-wa-header {
    padding: 22px 16px 18px 22px;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: flex-start;
    align-items: flex-start;
    -webkit-justify-content: space-between;
    justify-content: space-between;
    gap: 12px;
}
.umt-wa-header-text {
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 4px;
}
.umt-wa-header-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
}
.umt-wa-header-subtitle {
    font-size: 12px;
    font-weight: 400;
    opacity: 0.88;
    line-height: 1.45;
    margin-top: 2px;
}
.umt-wa-header-question {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    margin-top: 7px;
}
.umt-wa-close-btn {
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    opacity: 0.85;
    color: inherit;
    -webkit-transition: opacity 0.15s, background 0.15s;
    transition: opacity 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
    margin-top: -6px;
    margin-right: -4px;
    padding: 0;
}
.umt-wa-close-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.22);
}

/* ── Body ─────────────────────────────────────────────────── */
.umt-wa-body {
    padding: 10px 10px 6px;
    background: #f0f2f5;
}
.umt-wa-empty {
    text-align: center;
    font-size: 13px;
    color: #888;
    padding: 20px 0;
}

/* ── Agents list ──────────────────────────────────────────── */
.umt-wa-agents {
    list-style: none;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.umt-wa-agents::-webkit-scrollbar { width: 3px; }
.umt-wa-agents::-webkit-scrollbar-track { background: transparent; }
.umt-wa-agents::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Agent card */
.umt-wa-agent-link {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #efefef;
    border-radius: 12px;
    padding: 12px 14px;
    text-decoration: none;
    color: inherit;
    -webkit-box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    -webkit-transition: box-shadow 0.15s ease, border-color 0.15s ease;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}
.umt-wa-agent-link:hover {
    -webkit-box-shadow: 0 4px 14px rgba(37, 211, 102, 0.18);
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.18);
    border-color: rgba(37, 211, 102, 0.45);
}
.umt-wa-agent-link:active {
    background: #f6fef8;
}

/* Avatar */
.umt-wa-avatar {
    position: relative;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
}
.umt-wa-avatar img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.umt-wa-avatar-initial {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: -webkit-linear-gradient(135deg, #25a244 0%, #1a7a33 100%);
    background: linear-gradient(135deg, #25a244 0%, #1a7a33 100%);
    color: #fff;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1;
}
.umt-wa-online-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    background: #44b700;
    border-radius: 50%;
    border: 2px solid #fff;
    -webkit-animation: umt-blink 2.2s ease-in-out infinite;
    animation: umt-blink 2.2s ease-in-out infinite;
}
@-webkit-keyframes umt-blink {
    0%, 100% { opacity: 1;   }
    50%       { opacity: 0.4; }
}
@keyframes umt-blink {
    0%, 100% { opacity: 1;   }
    50%       { opacity: 0.4; }
}

/* Agent info */
.umt-wa-agent-info {
    -webkit-flex: 1;
    flex: 1;
    min-width: 0;
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: column;
    flex-direction: column;
    gap: 4px;
}
.umt-wa-agent-name {
    font-size: 14px;
    font-weight: 700;
    color: #111111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.umt-wa-agent-role {
    font-size: 11.5px;
    color: #666666;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* WA icon */
.umt-wa-wa-icon {
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
}

/* ── Status bar ───────────────────────────────────────────── */
.umt-wa-status-bar {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px 12px;
    background: #f0f2f5;
    font-size: 11.5px;
    color: #666;
}
.umt-wa-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #44b700;
    -webkit-flex-shrink: 0;
    flex-shrink: 0;
    -webkit-animation: umt-blink 2.2s ease-in-out infinite;
    animation: umt-blink 2.2s ease-in-out infinite;
}
.umt-wa-status-text  { font-weight: 500; color: #444; }
.umt-wa-status-sep   { opacity: 0.35; }
.umt-wa-privacy-link {
    color: #555;
    text-decoration: none;
    font-weight: 500;
    -webkit-transition: color 0.15s;
    transition: color 0.15s;
}
.umt-wa-privacy-link:hover { color: #25a244; text-decoration: underline; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 480px) {
    #umt-wa-dialog {
        width: 100%;
        border-radius: 14px;
    }
    .umt-wa-fab { width: 54px; height: 54px; }
    .umt-wa-header { padding: 18px 12px 15px 18px; }
    .umt-wa-header-title    { font-size: 14px; }
    .umt-wa-header-subtitle { font-size: 11.5px; }
    .umt-wa-header-question { font-size: 12.5px; margin-top: 5px; }
    .umt-wa-body { padding: 8px 8px 4px; }
    .umt-wa-agent-link { padding: 10px 11px; gap: 10px; }
    .umt-wa-avatar,
    .umt-wa-avatar img,
    .umt-wa-avatar-initial { width: 46px; height: 46px; }
    .umt-wa-avatar-initial  { font-size: 19px; }
    .umt-wa-wa-icon svg     { width: 32px; height: 32px; }
    .umt-wa-agent-name      { font-size: 13px; }
    .umt-wa-agent-role      { font-size: 11px; }
    .umt-wa-status-bar      { font-size: 11px; padding: 8px 12px 10px; }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .umt-wa-fab::before,
    .umt-wa-online-dot,
    .umt-wa-status-dot { -webkit-animation: none; animation: none; }
    #umt-wa-dialog,
    .umt-wa-fab,
    .umt-wa-fab-icon,
    .umt-wa-badge,
    .umt-wa-agent-link {
        -webkit-transition: none;
        transition: none;
    }
}
