/**
 * Frontend styles for DITU WhatsApp Button (Multi-button version)
 */

/* Base button styles */
.dwbp-whatsapp-button {
    position: fixed;
    z-index: 999999;
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border-radius:50px;
}

/* Position classes */
.dwbp-bottom-right {
    bottom: 20px;
    right: 20px;
}

.dwbp-bottom-left {
    bottom: 20px;
    left: 20px;
}

.dwbp-top-right {
    top: 20px;
    right: 20px;
}

.dwbp-top-left {
    top: 20px;
    left: 20px;
}

/* Button link */
.dwbp-button-link {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--button-color, #25d366);
    color: var(--text-color, #ffffff) !important;
    text-decoration: none;
    padding: 15px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(37, 211, 102, 0.3);
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 16px;
    line-height: 1;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dwbp-button-link:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.4);
    color: var(--text-color, #ffffff);
    text-decoration: none;
}

.dwbp-button-link:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.dwbp-button-link:active {
    transform: scale(0.95);
}

/* Icon only mode */
.dwbp-icon-only .dwbp-button-link {
    width: 60px;
    height: 60px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
}

/* WhatsApp icon */
.dwbp-whatsapp-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.dwbp-icon-only .dwbp-whatsapp-icon {
    width: 28px;
    height: 28px;
}

/* Button text */
.dwbp-button-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pulse animation */
.dwbp-pulse .dwbp-button-link {
    animation: dwbp-pulse-animation 2s infinite;
}

@keyframes dwbp-pulse-animation {
    0% {
        box-shadow: 0 4px 20px var(--pulse-shadow, rgba(37, 211, 102, 0.3)), 0 0 0 0 var(--pulse-ring, rgba(37, 211, 102, 0.7));
    }
    70% {
        box-shadow: 0 4px 20px var(--pulse-shadow, rgba(37, 211, 102, 0.3)), 0 0 0 10px var(--pulse-ring-fade, rgba(37, 211, 102, 0));
    }
    100% {
        box-shadow: 0 4px 20px var(--pulse-shadow, rgba(37, 211, 102, 0.3)), 0 0 0 0 var(--pulse-ring-fade, rgba(37, 211, 102, 0));
    }
}

/* Tooltip */
.dwbp-tooltip {
    position: absolute;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000000;
}

.dwbp-tooltip::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

/* Tooltip positioning based on button position */
.dwbp-bottom-right .dwbp-tooltip,
.dwbp-bottom-left .dwbp-tooltip {
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
}

.dwbp-bottom-right .dwbp-tooltip::after,
.dwbp-bottom-left .dwbp-tooltip::after {
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px 5px 0 5px;
    border-color: #333 transparent transparent transparent;
}

.dwbp-top-right .dwbp-tooltip,
.dwbp-top-left .dwbp-tooltip {
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
}

.dwbp-top-right .dwbp-tooltip::after,
.dwbp-top-left .dwbp-tooltip::after {
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 0 5px 5px 5px;
    border-color: transparent transparent #333 transparent;
}

/* Show tooltip on hover */
.dwbp-whatsapp-button:hover .dwbp-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Offline state */
.dwbp-whatsapp-button.dwbp-offline {
    opacity: 0.6;
    pointer-events: none;
}

.dwbp-whatsapp-button.dwbp-offline .dwbp-button-link {
    background: #ccc;
    box-shadow: 0 4px 20px rgba(204, 204, 204, 0.3);
}

/* Multiple buttons stacking */
.dwbp-whatsapp-button + .dwbp-whatsapp-button {
    margin-top: 80px;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .dwbp-whatsapp-button {
        bottom: 20px !important;
        right: 20px !important;
        left: auto !important;
        top: auto !important;
    }
    
    .dwbp-button-link {
        font-size: 16px;
    }
    
    .dwbp-icon-only .dwbp-button-link {
        width: 50px;
        height: 50px;
    }
    
    .dwbp-icon-only .dwbp-whatsapp-icon {
        width: 24px;
        height: 24px;
    }
    
    /* Stack mobile buttons vertically */
    .dwbp-whatsapp-button {
        bottom: 32px !important;
        right:16px;
    }
    
    /* Hide tooltips on mobile */
    .dwbp-tooltip {
        display: none;
    }
}

/* Small mobile screens */
@media (max-width: 480px) {
    .dwbp-whatsapp-button {
        right: 15px !important;
        bottom: 15px !important;
    }
    
    .dwbp-button-link {
        font-size: 16px;
    }
    
    .dwbp-whatsapp-icon {
        width: 20px;
        height: 20px;
    }
    
    .dwbp-icon-only .dwbp-button-link {
        width: 45px;
        height: 45px;
    }
    
    .dwbp-icon-only .dwbp-whatsapp-icon {
        width: 22px;
        height: 22px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .dwbp-whatsapp-button,
    .dwbp-button-link,
    .dwbp-tooltip {
        transition: none;
    }
    
    .dwbp-pulse {
        animation: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .dwbp-button-link {
        border: 2px solid currentColor;
    }
    
    .dwbp-tooltip {
        border: 1px solid #fff;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .dwbp-tooltip {
        background: #1a1a1a;
        color: #f0f0f1;
        border: 1px solid #3c434a;
    }
    
    .dwbp-tooltip::after {
        border-color: #1a1a1a transparent transparent transparent;
    }
    
    .dwbp-top-right .dwbp-tooltip::after,
    .dwbp-top-left .dwbp-tooltip::after {
        border-color: transparent transparent #1a1a1a transparent;
    }
}

/* Print styles */
@media print {
    .dwbp-whatsapp-button {
        display: none !important;
    }
}

/* Loading state */
.dwbp-whatsapp-button.dwbp-loading {
    opacity: 0.7;
    pointer-events: none;
}

.dwbp-whatsapp-button.dwbp-loading .dwbp-button-link {
    position: relative;
    overflow: hidden;
}

.dwbp-whatsapp-button.dwbp-loading .dwbp-button-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: dwbp-loading-shimmer 1.5s infinite;
}

@keyframes dwbp-loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Focus visible for keyboard navigation */
.dwbp-button-link:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* Reduce motion for vestibular disorders */
@media (prefers-reduced-motion: reduce) {
    .dwbp-button-link:hover {
        transform: none;
    }
    
    .dwbp-button-link:active {
        transform: none;
    }
}