/**
 * ZapTeam - Front-end styles.
 *
 * @package zapteam
 */

/* ########
   Reset & Container
   ######## */

.zapteam-widget,
.zapteam-widget *,
.zapteam-widget *::before,
.zapteam-widget *::after {
    box-sizing: border-box !important;
    margin: 0;
    padding: 0;
}

/* Micro-reset cirúrgico — exclui elementos que têm classe sc- própria */
.zapteam-widget a:not([class]),
.zapteam-widget a:not([class^="sc-"]) {
    text-decoration: none;
    color: inherit;
}

.zapteam-widget p,
.zapteam-widget span:not([class^="sc-"]) {
    font-family: inherit;
    line-height: inherit;
    color: inherit;
    letter-spacing: normal;
    word-break: normal;
}

.zapteam-widget div:not([class^="sc-"]):not([class^="zapteam-"]) {
    max-width: 100%;
}

.zapteam-widget img {
    max-width: 100%;
    display: block;
}

.zapteam-widget {
    position: fixed;
    bottom: var(--sc-offset-y, 20px);
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.4;
    overflow: visible;
}

.zapteam--right {
    right: var(--sc-offset-x, 20px);
}

.zapteam--left {
    left: var(--sc-offset-x, 20px);
}

/* Hide by device (JS driven, CSS fallback) */
@media (max-width: 768px) {
    .zapteam-widget[data-show-mobile="0"] {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .zapteam-widget[data-show-desktop="0"] {
        display: none !important;
    }
}

/* ########
   FAB Button
   ######## */

.sc-button-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zapteam--right .sc-button-row {
    flex-direction: row;
    justify-content: flex-end;
}

.zapteam--left .sc-button-row {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.sc-fab-wrap {
    position: relative;
    display: inline-flex;
    overflow: visible;
}

.sc-fab {
    width: var(--sc-btn-size, 56px);
    height: var(--sc-btn-size, 56px);
    border-radius: 50%;
    background: var(--sc-btn-color, #2db742);
    border: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    outline: none !important;
    transition: transform 0.2s ease, background-color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.sc-fab:hover,
.sc-fab:focus {
    background: var(--sc-btn-color, #2db742);
    color: #fff !important;
    outline: none !important;
}

.sc-fab:active {
    transform: scale(0.92);
}

/* Notification badge */
.sc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    padding: 0 4px;
    z-index: 2;
    pointer-events: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    animation: sc-badge-bounce 0.4s ease-out;
}

.sc--open .sc-badge {
    display: none;
}

@keyframes sc-badge-bounce {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.sc-fab__icon {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.sc-fab__icon--whatsapp svg {
    width: var(--sc-icon-size, 30px);
    height: var(--sc-icon-size, 30px);
}

.sc-fab__icon--close svg {
    width: var(--sc-close-size, 14px);
    height: var(--sc-close-size, 14px);
}
/* State: closed (default) */
.sc-fab__icon--whatsapp {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.sc-fab__icon--close {
    opacity: 0;
    transform: scale(0) rotate(-360deg);
}

/* State: open */
.zapteam-widget.sc--open .sc-fab__icon--whatsapp {
    opacity: 0;
    transform: scale(0) rotate(360deg);
}

.zapteam-widget.sc--open .sc-fab__icon--close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* ########
   Label tooltip
   ######## */

.sc-label {
    background: var(--sc-label-bg);
    color: var(--sc-label-color);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: opacity 0.3s ease;
}

.zapteam-widget.sc--open .sc-label {
    opacity: 0;
    pointer-events: none;
}

/* ########
   Popup
   ######## */

.sc-popup {
    position: absolute;
    bottom: calc(var(--sc-btn-size, 56px) + 12px);
    width: 350px; /* Base container (overwritten by dynamic CSS ID) */
    min-width: 300px; /* Nuclear fallback against cache strippers */
    max-width: calc(100vw - 40px);
    border-radius: var(--sc-popup-radius, 8px);
    overflow: hidden;
    box-shadow: 0 10px 25px 4px rgba(0, 0, 0, 0.12),
        0 4px 10px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.zapteam--right .sc-popup {
    right: 0;
}

.zapteam--left .sc-popup {
    left: 0;
}

.zapteam-widget.sc--open .sc-popup {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.sc-popup[aria-hidden="true"] {
    visibility: hidden;
}

.zapteam-widget.sc--open .sc-popup[aria-hidden="false"] {
    visibility: visible;
}

/* Header */
.sc-popup__header {
    background: var(--sc-header-bg, #2db742);
    color: var(--sc-header-color, #ffffff);
    padding: 18px 20px 20px;
}

.sc-popup__header-top {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sc-icon-whatsapp--header {
    flex-shrink: 0;
    color: var(--sc-header-color, #ffffff);
}

.sc-popup__title {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.sc-popup__subtitle {
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    padding-top: 8px;
    opacity: 0.9;
}

/* Body */
.sc-popup__body {
    background: var(--sc-body-bg, #f0f2f5);
    padding: 14px 16px 18px;
    max-height: 50vh;
    overflow-y: auto;
}

.sc-popup__response {
    font-size: 11px;
    color: #a5abb7;
    padding: 0 2px 12px;
}

.sc-popup__members {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ########
   Member Card
   ######## */

.sc-member {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: #ffffff;
    border-radius: 10px;
    border-bottom: 3px solid var(--sc-accent, #2db742);
    text-decoration: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    /* Animation on popup open */
    opacity: 0;
    transform: translateY(16px);
    animation: sc-member-appear 0.3s ease forwards;
    animation-delay: var(--sc-member-delay, 0s);
}

@keyframes sc-member-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sc-member--online:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.sc-member--offline {
    pointer-events: none;
    cursor: default;
    border-bottom-color: #d4d8dd;
}

.sc-member--offline.sc-member {
    animation-name: sc-member-appear-offline;
}

@keyframes sc-member-appear-offline {
    to {
        opacity: 0.55;
        transform: translateY(0);
    }
}

/* Avatar */
.sc-member__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sc-member__avatar--initials {
    background: linear-gradient(135deg, #43b654 0%, #25a244 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
}

/* Info */
.sc-member__info {
    flex: 1;
    min-width: 0;
}

.sc-member__status-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
    padding: 2px 8px 2px 6px;
    border-radius: 20px;
}

.sc-member--online .sc-member__status-tag {
    background: rgba(0, 231, 133, 0.1);
}

.sc-member--offline .sc-member__status-tag {
    background: rgba(245, 166, 35, 0.1);
}

.sc-member__status-dot {
    position: relative;
    width: 6px;
    height: 6px;
    flex-shrink: 0;
}

.sc-member__status-dot::before {
    content: "";
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.sc-member--online .sc-member__status-dot::before {
    background: #00e785;
}

.sc-member--offline .sc-member__status-dot::before {
    background: #f5a623;
}

/* Online pulse dot */
.sc-member--online .sc-member__status-dot::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1.5px solid #00e785;
    background: transparent;
    animation: sc-dot-pulse 1.2s ease-out infinite;
    animation-delay: 0.3s;
}

@keyframes sc-dot-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }

    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

.sc-member__status-text {
    font-size: 9px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.03em;
}

.sc-member--online .sc-member__status-text {
    color: #00c873;
}

.sc-member--offline .sc-member__status-text {
    color: #f5a623;
}

.sc-member__name {
    font-size: 14px;
    font-weight: 600;
    color: #363c47;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sc-member__role {
    font-size: 11px;
    font-weight: 400;
    color: #989b9f;
    padding-top: 3px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Arrow */
.sc-member__arrow {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sc-member--online .sc-member__arrow {
    background: var(--sc-accent, #2db742);
}

.sc-member--offline .sc-member__arrow {
    background: #d4d8dd;
}

/* ########
   Button Animations
   ######## */

/* Pulse */
.zapteam--anim-pulse:not(.sc--open) .sc-fab {
    animation: sc-pulse 0.9s ease-in-out infinite;
}

@keyframes sc-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

.zapteam--anim-pulse.sc--open .sc-fab,
.zapteam--anim-pulse .sc-fab-wrap:hover .sc-fab {
    animation: none;
}

/* Focus ring */
.sc-ring--focus {
    position: absolute;
    width: var(--sc-btn-size, 56px);
    height: var(--sc-btn-size, 56px);
    border-radius: 50%;
    border: 6px solid var(--sc-btn-color, #2db742);
    background: transparent;
    box-sizing: border-box;
    pointer-events: none;
    z-index: 0;
    /* Centraliza sobre o FAB sem afetar o layout do container */
    left: 50%;
    top: 50%;
    margin-left: calc(var(--sc-btn-size, 56px) / -2);
    margin-top: calc(var(--sc-btn-size, 56px) / -2);
    animation: sc-focus-pulse 1s ease-out infinite;
    animation-delay: 0.1s;
}

@keyframes sc-focus-pulse {
    0% {
        transform: scale(1);
        opacity: 0.4;
    }

    100% {
        transform: scale(1.6);
        opacity: 0;
    }
}

.zapteam-widget.sc--open .sc-ring--focus,
.sc-fab-wrap:hover .sc-ring--focus {
    animation: none;
    opacity: 0;
}

/* Satellite rings */
.sc-ring--satellite-1,
.sc-ring--satellite-2 {
    position: absolute;
    width: calc(var(--sc-btn-size, 56px) + 16px);
    height: calc(var(--sc-btn-size, 56px) + 16px);
    left: 50%;
    top: 50%;
    margin-left: calc((var(--sc-btn-size, 56px) + 16px) / -2);
    margin-top: calc((var(--sc-btn-size, 56px) + 16px) / -2);
    border-radius: 50%;
    border-width: 6px;
    border-style: solid;
    border-left-color: transparent;
    border-right-color: transparent;
    border-top-color: var(--sc-btn-color, #2db742);
    border-bottom-color: var(--sc-btn-color, #2db742);
    box-sizing: border-box;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

.sc-ring--satellite-1 {
    animation: sc-sat-spin 5s linear infinite;
}

.sc-ring--satellite-2 {
    animation: sc-sat-spin-reverse 2s linear infinite;
}

@keyframes sc-sat-spin {
    to { transform: rotate(360deg); }
}

@keyframes sc-sat-spin-reverse {
    to { transform: rotate(-360deg); }
}

.zapteam-widget.sc--open .sc-ring--satellite-1,
.zapteam-widget.sc--open .sc-ring--satellite-2,
.sc-fab-wrap:hover .sc-ring--satellite-1,
.sc-fab-wrap:hover .sc-ring--satellite-2 {
    opacity: 0;
    transition: opacity 0.4s ease;
}

/* Multicolor */
.zapteam--anim-multicolor:not(.sc--open) .sc-fab {
    animation: sc-multicolor 4s linear infinite alternate;
}

@keyframes sc-multicolor {
    0%   { background-color: #4dc247; }
    33%  { background-color: #19dcea; }
    66%  { background-color: #b22cff; }
    100% { background-color: #ea2222; }
}

.zapteam--anim-multicolor.sc--open .sc-fab,
.zapteam--anim-multicolor .sc-fab-wrap:hover .sc-fab {
    animation: none;
    background-color: var(--sc-btn-color, #2db742) !important;
}

/* Display delay */
.zapteam-widget.sc--delayed {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

.zapteam-widget.sc--appear {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
