/**
 * WhatsApp Chat Frontend Stylesheet
 * @version 1.2.1
 */

/* Root Widget Wrapper */
.wac-widget {
    position: fixed;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Positions with independent X & Y offsets */
.wac-pos-bottom-right {
    bottom: var(--wac-offset-y, 75px);
    right: var(--wac-offset-x, 75px);
}

.wac-pos-bottom-left {
    bottom: var(--wac-offset-y, 75px);
    left: var(--wac-offset-x, 75px);
}

.wac-pos-top-right {
    top: var(--wac-offset-y, 75px);
    right: var(--wac-offset-x, 75px);
}

.wac-pos-top-left {
    top: var(--wac-offset-y, 75px);
    left: var(--wac-offset-x, 75px);
}

/* Launcher Button / Link */
.wac-launcher {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    text-decoration: none !important;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    line-height: normal;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.25s ease;
}

.wac-launcher:hover {
    transform: scale(1.1);
}

.wac-launcher:active {
    transform: scale(0.95);
}

/* Accessibility: Keyboard focus indicator */
.wac-launcher:focus-visible {
    outline: 3px solid #075e54;
    outline-offset: 3px;
    border-radius: 50%;
}

/* Badge Styles */
.wac-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    box-sizing: border-box;
    overflow: hidden;
}

.wac-badge svg {
    display: block;
}

.wac-badge-default {
    background: transparent;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.18));
}

.wac-badge-circle {
    background: #25D366;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.45);
}

.wac-badge-circle svg {
    width: 65% !important;
    height: 65% !important;
}

.wac-badge-dark {
    background: #075e54;
    box-shadow: 0 4px 14px rgba(7, 94, 84, 0.45);
}

.wac-badge-dark svg {
    width: 65% !important;
    height: 65% !important;
}

.wac-badge-gradient {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    box-shadow: 0 4px 15px rgba(18, 140, 126, 0.45);
}

.wac-badge-gradient svg {
    width: 65% !important;
    height: 65% !important;
}

.wac-badge-custom {
    background: transparent;
}

.wac-custom-icon {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Pulse animation effect */
.wac-pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid #25D366;
    opacity: 0.8;
    animation: wac-pulse 2.2s infinite;
    pointer-events: none;
    box-sizing: border-box;
}

.wac-pulse-disabled .wac-pulse-ring {
    display: none !important;
}

@keyframes wac-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.35);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Tooltip / Text Label */
.wac-tooltip {
    position: absolute;
    background: #111b21;
    color: #ffffff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.3;
}

/* Tooltip Positioning (Opposite to widget corner) */
.wac-pos-bottom-right .wac-tooltip,
.wac-pos-top-right .wac-tooltip {
    right: calc(100% + 12px);
}

.wac-pos-bottom-left .wac-tooltip,
.wac-pos-top-left .wac-tooltip {
    left: calc(100% + 12px);
}

/* Tooltip Modes */
.wac-tooltip-hover {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.wac-widget:hover .wac-tooltip-hover {
    opacity: 1;
    transform: scale(1);
}

.wac-tooltip-always {
    opacity: 1;
    transform: scale(1);
}

/* Multi-Agent Dialog Panel */
.wac-panel {
    position: absolute;
    width: 320px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 1000000;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.wac-panel[hidden] {
    display: none !important;
}

.wac-panel.wac-panel-open {
    opacity: 1;
    pointer-events: auto;
}

/* Panel Anchoring */
.wac-pos-bottom-right .wac-panel {
    bottom: calc(100% + 16px);
    right: 0;
    transform: scale(0.92) translateY(10px);
    transform-origin: bottom right;
}

.wac-pos-bottom-right .wac-panel.wac-panel-open {
    transform: scale(1) translateY(0);
}

.wac-pos-bottom-left .wac-panel {
    bottom: calc(100% + 16px);
    left: 0;
    transform: scale(0.92) translateY(10px);
    transform-origin: bottom left;
}

.wac-pos-bottom-left .wac-panel.wac-panel-open {
    transform: scale(1) translateY(0);
}

.wac-pos-top-right .wac-panel {
    top: calc(100% + 16px);
    right: 0;
    transform: scale(0.92) translateY(-10px);
    transform-origin: top right;
}

.wac-pos-top-right .wac-panel.wac-panel-open {
    transform: scale(1) translateY(0);
}

.wac-pos-top-left .wac-panel {
    top: calc(100% + 16px);
    left: 0;
    transform: scale(0.92) translateY(-10px);
    transform-origin: top left;
}

.wac-pos-top-left .wac-panel.wac-panel-open {
    transform: scale(1) translateY(0);
}

/* Panel Header */
.wac-panel-header {
    background: linear-gradient(135deg, #075e54 0%, #128c7e 100%);
    color: #ffffff;
    padding: 16px 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wac-panel-header-content {
    flex: 1;
    min-width: 0;
}

.wac-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
}

.wac-panel-subtitle {
    margin: 4px 0 0 0;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.3;
}

.wac-panel-close {
    background: rgba(0, 0, 0, 0.15);
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-left: 10px;
    padding: 0;
}

.wac-panel-close:hover {
    background: rgba(0, 0, 0, 0.3);
}

.wac-panel-close:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Panel Body & Agent Items */
.wac-panel-body {
    padding: 12px;
    max-height: 380px;
    overflow-y: auto;
}

.wac-panel-offline-notice {
    background: #fff8e5;
    border-left: 3px solid #dba617;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #50575e;
    line-height: 1.4;
}

/* Pesan offline hanya tampil saat widget berstatus tutup (kelas dari PHP, dikoreksi JS) */
.wac-widget:not(.wac-is-closed) .wac-panel-offline-notice {
    display: none;
}

.wac-panel-offline-notice p {
    margin: 0;
}

.wac-agent-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wac-agent {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none !important;
    color: #111b21 !important;
    background-color: transparent;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.wac-agent:hover {
    background-color: #f0f2f5;
    transform: translateX(3px);
}

.wac-agent:focus-visible {
    outline: 2px solid #075e54;
    outline-offset: 1px;
    background-color: #f0f2f5;
}

.wac-agent-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(37, 211, 102, 0.35);
}

.wac-agent-info {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.wac-agent-name {
    font-weight: 600;
    font-size: 14px;
    color: #111b21;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wac-agent-role {
    font-size: 12px;
    color: #667781;
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wac-agent-action {
    color: #25D366;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* Display Delay Classes (M-2: Accessibility Hidden) */
.wac-delayed {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transform: translateY(10px) !important;
    transition: opacity 0.4s ease, transform 0.4s ease, visibility 0.4s ease;
}

.wac-widget.wac-revealed {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) !important;
}

/* Offline Hidden Mode */
.wac-offline-hidden {
    display: none !important;
}

/* Device Visibility Rules on Root Widget */
@media screen and (max-width: 767px) {
    .wac-hide-phone {
        display: none !important;
    }
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
    .wac-hide-tablet {
        display: none !important;
    }
}

@media screen and (min-width: 1025px) {
    .wac-hide-desktop {
        display: none !important;
    }
}

/* WCAG 2.3.3: Respect user's motion preference */
@media (prefers-reduced-motion: reduce) {
    .wac-pulse-ring {
        animation: none !important;
        opacity: 0 !important;
        display: none !important;
    }
    .wac-launcher,
    .wac-inline-btn,
    .wac-panel,
    .wac-delayed,
    .wac-tooltip {
        transition: none !important;
    }
}

/* Inline shortcode button */
.wac-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background-color: #25D366;
    color: #ffffff !important;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    margin: 8px 0;
    line-height: 1.4;
}

.wac-inline-btn:hover {
    background-color: #1eb956;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.45);
}

.wac-inline-btn:focus-visible {
    outline: 3px solid #075e54;
    outline-offset: 2px;
}

.wac-inline-btn svg {
    width: 22px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}
