/**
 * Call Conversion Tracker - Frontend Styles
 * Floating Call Button
 */

/* ========================================
   Floating Button Base
   ======================================== */
.cct-floating-button {
    --cct-bg-color: #25D366;
    --cct-text-color: #ffffff;
    --cct-hover-color: #128C7E;
    
    position: fixed !important;
    z-index: 2147483647 !important; /* Maximum z-index */
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none !important;
    cursor: pointer;
    -webkit-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 2px 6px rgba(0, 0, 0, 0.1);
    background-color: var(--cct-bg-color) !important;
    color: var(--cct-text-color) !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    border: none !important;
    outline: none;
    /* Mobile Safari fixes */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: transform;
    /* Prevent iOS tap highlight */
    -webkit-tap-highlight-color: transparent;
}

.cct-floating-button:hover {
    background-color: var(--cct-hover-color) !important;
    color: var(--cct-text-color) !important;
    -webkit-transform: translateZ(0) scale(1.05);
    transform: translateZ(0) scale(1.05);
    -webkit-box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 3px 10px rgba(0, 0, 0, 0.15);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), 0 3px 10px rgba(0, 0, 0, 0.15);
    text-decoration: none !important;
}

.cct-floating-button:focus {
    outline: 2px solid var(--cct-bg-color);
    outline-offset: 2px;
}

.cct-floating-button:active {
    -webkit-transform: translateZ(0) scale(0.98);
    transform: translateZ(0) scale(0.98);
}

/* ========================================
   Icon
   ======================================== */
.cct-floating-icon {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cct-floating-icon svg {
    fill: currentColor;
    display: block !important;
}

/* ========================================
   Text
   ======================================== */
.cct-floating-text {
    display: none;
    white-space: nowrap;
}

.cct-show-text-desktop .cct-floating-text {
    display: inline;
}

@media (max-width: 768px) {
    .cct-show-text-desktop .cct-floating-text {
        display: none;
    }
    
    .cct-show-text-mobile .cct-floating-text {
        display: inline !important;
    }
}

/* ========================================
   Positions
   ======================================== */
.cct-position-bottom-right {
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
    top: auto !important;
}

.cct-position-bottom-left {
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
    top: auto !important;
}

@media (max-width: 768px) {
    .cct-position-bottom-right,
    .cct-position-bottom-left {
        bottom: 15px !important;
    }
    
    .cct-position-bottom-right {
        right: 15px !important;
    }
    
    .cct-position-bottom-left {
        left: 15px !important;
    }
}

/* Safe area insets for iPhone X and newer */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .cct-position-bottom-right,
    .cct-position-bottom-left {
        bottom: calc(20px + env(safe-area-inset-bottom)) !important;
    }
    
    .cct-position-bottom-right {
        right: calc(20px + env(safe-area-inset-right)) !important;
    }
    
    .cct-position-bottom-left {
        left: calc(20px + env(safe-area-inset-left)) !important;
    }
    
    @media (max-width: 768px) {
        .cct-position-bottom-right,
        .cct-position-bottom-left {
            bottom: calc(15px + env(safe-area-inset-bottom)) !important;
        }
        
        .cct-position-bottom-right {
            right: calc(15px + env(safe-area-inset-right)) !important;
        }
        
        .cct-position-bottom-left {
            left: calc(15px + env(safe-area-inset-left)) !important;
        }
    }
}

/* ========================================
   Sizes
   ======================================== */
/* Small */
.cct-size-small {
    padding: 10px !important;
    min-width: 44px !important;
    min-height: 44px !important;
}

.cct-size-small .cct-floating-icon svg {
    width: 20px !important;
    height: 20px !important;
}

.cct-size-small.cct-show-text-desktop,
.cct-size-small.cct-show-text-mobile {
    padding: 10px 16px !important;
}

.cct-size-small .cct-floating-text {
    font-size: 12px;
}

/* Medium */
.cct-size-medium {
    padding: 14px !important;
    min-width: 56px !important;
    min-height: 56px !important;
}

.cct-size-medium .cct-floating-icon svg {
    width: 24px !important;
    height: 24px !important;
}

.cct-size-medium.cct-show-text-desktop,
.cct-size-medium.cct-show-text-mobile {
    padding: 14px 20px !important;
}

.cct-size-medium .cct-floating-text {
    font-size: 14px;
}

/* Large */
.cct-size-large {
    padding: 18px !important;
    min-width: 68px !important;
    min-height: 68px !important;
}

.cct-size-large .cct-floating-icon svg {
    width: 30px !important;
    height: 30px !important;
}

.cct-size-large.cct-show-text-desktop,
.cct-size-large.cct-show-text-mobile {
    padding: 18px 26px !important;
}

.cct-size-large .cct-floating-text {
    font-size: 16px;
}

/* Mobile size adjustments */
@media (max-width: 768px) {
    .cct-size-large {
        padding: 14px !important;
        min-width: 56px !important;
        min-height: 56px !important;
    }
    
    .cct-size-large .cct-floating-icon svg {
        width: 26px !important;
        height: 26px !important;
    }
    
    .cct-size-large.cct-show-text-mobile {
        padding: 14px 20px !important;
    }
}

/* ========================================
   Styles (Shapes)
   ======================================== */
.cct-style-circle {
    border-radius: 50% !important;
}

.cct-style-circle.cct-show-text-desktop,
.cct-style-circle.cct-show-text-mobile {
    border-radius: 999px !important;
}

.cct-style-rounded {
    border-radius: 16px !important;
}

.cct-style-square {
    border-radius: 8px !important;
}

/* ========================================
   Animations
   ======================================== */

/* Pulse */
@-webkit-keyframes cct-pulse {
    0% {
        -webkit-box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 var(--cct-bg-color);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 var(--cct-bg-color);
    }
    70% {
        -webkit-box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 15px transparent;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 15px transparent;
    }
    100% {
        -webkit-box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 transparent;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 transparent;
    }
}

@keyframes cct-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 var(--cct-bg-color);
    }
    70% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 15px transparent;
    }
    100% {
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 0 0 transparent;
    }
}

.cct-animation-pulse {
    -webkit-animation: cct-pulse 2s infinite;
    animation: cct-pulse 2s infinite;
}

.cct-animation-pulse:hover {
    -webkit-animation: none;
    animation: none;
}

/* Bounce */
@-webkit-keyframes cct-bounce {
    0%, 20%, 50%, 80%, 100% {
        -webkit-transform: translateZ(0) translateY(0);
        transform: translateZ(0) translateY(0);
    }
    40% {
        -webkit-transform: translateZ(0) translateY(-10px);
        transform: translateZ(0) translateY(-10px);
    }
    60% {
        -webkit-transform: translateZ(0) translateY(-5px);
        transform: translateZ(0) translateY(-5px);
    }
}

@keyframes cct-bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateZ(0) translateY(0);
    }
    40% {
        transform: translateZ(0) translateY(-10px);
    }
    60% {
        transform: translateZ(0) translateY(-5px);
    }
}

.cct-animation-bounce {
    -webkit-animation: cct-bounce 2s ease infinite;
    animation: cct-bounce 2s ease infinite;
}

.cct-animation-bounce:hover {
    -webkit-animation: none;
    animation: none;
}

/* Shake */
@-webkit-keyframes cct-shake {
    0%, 100% {
        -webkit-transform: translateZ(0) rotate(0deg);
        transform: translateZ(0) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        -webkit-transform: translateZ(0) rotate(-5deg);
        transform: translateZ(0) rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        -webkit-transform: translateZ(0) rotate(5deg);
        transform: translateZ(0) rotate(5deg);
    }
}

@keyframes cct-shake {
    0%, 100% {
        transform: translateZ(0) rotate(0deg);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateZ(0) rotate(-5deg);
    }
    20%, 40%, 60%, 80% {
        transform: translateZ(0) rotate(5deg);
    }
}

.cct-animation-shake {
    -webkit-animation: cct-shake 0.5s ease-in-out;
    animation: cct-shake 0.5s ease-in-out;
    -webkit-animation-iteration-count: 1;
    animation-iteration-count: 1;
    -webkit-animation-delay: 2s;
    animation-delay: 2s;
}

.cct-animation-shake:hover {
    -webkit-animation: none;
    animation: none;
}

/* Ring */
@-webkit-keyframes cct-ring {
    0% {
        -webkit-transform: translateZ(0) rotate(0) scale(1);
        transform: translateZ(0) rotate(0) scale(1);
    }
    10% {
        -webkit-transform: translateZ(0) rotate(-15deg) scale(1.1);
        transform: translateZ(0) rotate(-15deg) scale(1.1);
    }
    20% {
        -webkit-transform: translateZ(0) rotate(15deg) scale(1.1);
        transform: translateZ(0) rotate(15deg) scale(1.1);
    }
    30% {
        -webkit-transform: translateZ(0) rotate(-10deg) scale(1.05);
        transform: translateZ(0) rotate(-10deg) scale(1.05);
    }
    40% {
        -webkit-transform: translateZ(0) rotate(10deg) scale(1.05);
        transform: translateZ(0) rotate(10deg) scale(1.05);
    }
    50%, 100% {
        -webkit-transform: translateZ(0) rotate(0) scale(1);
        transform: translateZ(0) rotate(0) scale(1);
    }
}

@keyframes cct-ring {
    0% {
        transform: translateZ(0) rotate(0) scale(1);
    }
    10% {
        transform: translateZ(0) rotate(-15deg) scale(1.1);
    }
    20% {
        transform: translateZ(0) rotate(15deg) scale(1.1);
    }
    30% {
        transform: translateZ(0) rotate(-10deg) scale(1.05);
    }
    40% {
        transform: translateZ(0) rotate(10deg) scale(1.05);
    }
    50%, 100% {
        transform: translateZ(0) rotate(0) scale(1);
    }
}

.cct-animation-ring {
    -webkit-animation: cct-ring 1s ease;
    animation: cct-ring 1s ease;
    -webkit-animation-iteration-count: 1;
    animation-iteration-count: 1;
    -webkit-animation-delay: 1s;
    animation-delay: 1s;
}

.cct-animation-ring:hover {
    -webkit-animation: none;
    animation: none;
}

/* Re-trigger animations periodically */
.cct-animation-shake,
.cct-animation-ring {
    -webkit-animation-fill-mode: both;
    animation-fill-mode: both;
}

/* ========================================
   Device Visibility
   ======================================== */
@media (min-width: 769px) {
    .cct-hide-desktop {
        display: none !important;
        visibility: hidden !important;
    }
}

@media (max-width: 768px) {
    .cct-hide-mobile {
        display: none !important;
        visibility: hidden !important;
    }
    
    /* Ensure visible buttons are actually visible on mobile */
    .cct-floating-button:not(.cct-hide-mobile) {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .cct-floating-button {
        display: none !important;
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .cct-floating-button {
        -webkit-animation: none !important;
        animation: none !important;
        -webkit-transition: none !important;
        transition: none !important;
    }
}

/* ========================================
   WhatsApp Button Offset
   When both buttons are on the same side
   ======================================== */
.cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-right,
.cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-left {
    bottom: 90px !important;
}

.cct-whatsapp-button.cct-whatsapp-offset.cct-size-small.cct-position-bottom-right,
.cct-whatsapp-button.cct-whatsapp-offset.cct-size-small.cct-position-bottom-left {
    bottom: 75px !important;
}

.cct-whatsapp-button.cct-whatsapp-offset.cct-size-large.cct-position-bottom-right,
.cct-whatsapp-button.cct-whatsapp-offset.cct-size-large.cct-position-bottom-left {
    bottom: 105px !important;
}

/* Mobile offset */
@media (max-width: 768px) {
    .cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-right,
    .cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-left {
        bottom: 80px !important;
    }
    
    .cct-whatsapp-button.cct-whatsapp-offset.cct-size-small.cct-position-bottom-right,
    .cct-whatsapp-button.cct-whatsapp-offset.cct-size-small.cct-position-bottom-left {
        bottom: 65px !important;
    }
    
    .cct-whatsapp-button.cct-whatsapp-offset.cct-size-large.cct-position-bottom-right,
    .cct-whatsapp-button.cct-whatsapp-offset.cct-size-large.cct-position-bottom-left {
        bottom: 95px !important;
    }
}

/* Safe area insets for WhatsApp offset */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-right,
    .cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-left {
        bottom: calc(90px + env(safe-area-inset-bottom)) !important;
    }
    
    @media (max-width: 768px) {
        .cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-right,
        .cct-whatsapp-button.cct-whatsapp-offset.cct-position-bottom-left {
            bottom: calc(80px + env(safe-area-inset-bottom)) !important;
        }
    }
}
