/* =============================================
   Whapolis Frontend Styles
   by Sitiopolis - sitiopolis.com
   ============================================= */

/* Wrapper */
.whapolis-wrapper {
    position: fixed;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.whapolis-wrapper.whapolis-pos-bottom-left,
.whapolis-wrapper.whapolis-pos-top-left {
    align-items: flex-start;
}

/* Scroll hidden state */
.whapolis-scroll-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.whapolis-scroll-hidden.whapolis-visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* Device visibility */
@media (max-width: 768px) {
    .whapolis-hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .whapolis-hide-desktop {
        display: none !important;
    }
}

/* Main Button */
.whapolis-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    position: relative;
    outline: none;
}

.whapolis-btn:hover {
    transform: scale(1.05);
}

.whapolis-btn:active {
    transform: scale(0.98);
}

.whapolis-btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.whapolis-btn-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    line-height: 0;
}

.whapolis-btn-icon .whapolis-svg {
    display: block;
}

.whapolis-btn-text {
    white-space: nowrap;
}

/* Pulse Animation */
.whapolis-pulse .whapolis-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: inherit;
    opacity: 0;
    z-index: -1;
    animation: whapolis-pulse 2s ease-out infinite;
}

@keyframes whapolis-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Badge */
.whapolis-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 0 5px;
    animation: whapolis-badge-bounce 0.5s ease;
}

@keyframes whapolis-badge-bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Tooltip */
.whapolis-tooltip {
    background: #fff;
    color: #333;
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    font-size: 14px;
    line-height: 1.4;
    max-width: 250px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: whapolis-tooltip-in 0.4s ease;
    position: relative;
}

.whapolis-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 20px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #fff;
}

.whapolis-pos-bottom-left .whapolis-tooltip::after,
.whapolis-pos-top-left .whapolis-tooltip::after {
    right: auto;
    left: 20px;
}

.whapolis-pos-top-right .whapolis-tooltip::after,
.whapolis-pos-top-left .whapolis-tooltip::after {
    bottom: auto;
    top: -6px;
    border-top: 0;
    border-bottom: 6px solid #fff;
}

.whapolis-pos-top-right .whapolis-tooltip,
.whapolis-pos-top-left .whapolis-tooltip {
    order: 2;
}

.whapolis-tooltip-text {
    flex: 1;
}

.whapolis-tooltip-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.whapolis-tooltip-close:hover {
    color: #333;
}

.whapolis-tooltip.whapolis-hidden {
    display: none;
}

@keyframes whapolis-tooltip-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Team Panel */
.whapolis-team-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    animation: whapolis-panel-in 0.3s ease;
    z-index: 1;
}

.whapolis-pos-top-right .whapolis-team-panel,
.whapolis-pos-top-left .whapolis-team-panel {
    bottom: auto;
    top: 70px;
}

.whapolis-pos-bottom-left .whapolis-team-panel,
.whapolis-pos-top-left .whapolis-team-panel {
    right: auto;
    left: 0;
}

@keyframes whapolis-panel-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.whapolis-team-panel.whapolis-panel-closing {
    animation: whapolis-panel-out 0.25s ease forwards;
}

@keyframes whapolis-panel-out {
    to {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
}

.whapolis-team-header {
    padding: 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.whapolis-team-header-content {
    flex: 1;
}

.whapolis-team-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 4px;
}

.whapolis-team-subtitle {
    font-size: 13px;
    opacity: 0.85;
}

.whapolis-team-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.7;
    padding: 0;
    line-height: 1;
}

.whapolis-team-close:hover {
    opacity: 1;
}

.whapolis-team-agents {
    padding: 8px 0;
    max-height: 320px;
    overflow-y: auto;
}

.whapolis-agent {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
    cursor: pointer;
}

.whapolis-agent:hover {
    background: #f5f5f5;
}

.whapolis-agent-avatar {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.whapolis-agent-avatar img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.whapolis-agent-initial {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #075E54;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.whapolis-agent-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.whapolis-status-available {
    background: #25D366;
}

.whapolis-status-away {
    background: #ffc107;
}

.whapolis-agent-info {
    flex: 1;
    min-width: 0;
}

.whapolis-agent-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.whapolis-agent-role {
    font-size: 12px;
    color: #888;
}

.whapolis-agent-arrow {
    flex-shrink: 0;
    opacity: 0.6;
    display: flex;
}

.whapolis-agent:hover .whapolis-agent-arrow {
    opacity: 1;
}

.whapolis-team-footer {
    padding: 10px 20px;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 11px;
    color: #aaa;
}

.whapolis-team-footer a {
    color: #888;
    text-decoration: none;
}

.whapolis-team-footer a:hover {
    color: #075E54;
}

/* Post-action Popup */
.whapolis-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: whapolis-fade-in 0.3s ease;
}

.whapolis-popup-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.whapolis-popup-content {
    position: relative;
    max-width: 400px;
    width: 90%;
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: whapolis-popup-in 0.4s ease;
}

.whapolis-popup-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
    line-height: 1;
}

.whapolis-popup-close:hover {
    opacity: 1;
}

.whapolis-popup-icon {
    margin-bottom: 16px;
}

.whapolis-popup-icon svg {
    display: inline-block;
}

.whapolis-popup-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 8px;
}

.whapolis-popup-text {
    font-size: 15px;
    margin: 0 0 20px;
    opacity: 0.8;
}

.whapolis-popup-btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 10px 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.whapolis-popup-btn:hover {
    opacity: 0.9;
}

@keyframes whapolis-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes whapolis-popup-in {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Offline message */
.whapolis-offline-msg {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 280px;
    animation: whapolis-tooltip-in 0.3s ease;
}

.whapolis-pos-bottom-left .whapolis-offline-msg,
.whapolis-pos-top-left .whapolis-offline-msg {
    right: auto;
    left: 0;
}

.whapolis-pos-top-right .whapolis-offline-msg,
.whapolis-pos-top-left .whapolis-offline-msg {
    bottom: auto;
    top: 70px;
}

.whapolis-offline-content {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    position: relative;
}

.whapolis-offline-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    padding-right: 20px;
}

.whapolis-offline-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* Shortcode button */
.whapolis-shortcode-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    text-decoration: none !important;
    transition: opacity 0.2s;
    line-height: 1.2;
}

.whapolis-shortcode-btn:hover {
    opacity: 0.9;
}

.whapolis-shortcode-btn svg {
    flex-shrink: 0;
}
