/* ============================================
   ENTERPRISE BUTTONS - PREMIUM EDITION
   Inti Wasi Global - E-commerce International
   ============================================ */

/* ============================================
   BASE BUTTON STYLES - ENTERPRISE
   ============================================ */

.btn-enterprise {
    --btn-radius: var(--radius-xl); /* Custom property for consistent border-radius across pseudo-elements */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.875rem 1.75rem;
    font-size: var(--font-size-base);
    font-weight: 600;
    border-radius: var(--btn-radius);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden; /* FIXED: Hidden to contain shine effect - badges use separate positioning */
    white-space: nowrap;
    /* Specific transitions instead of 'all' for better performance */
    transition:
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        background 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        background-position 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* Creates isolated stacking context for internal z-index management.
       All children's z-index values are relative to this context.
       Note: May affect overlays/tooltips that need to appear above button. */
    isolation: isolate;
    /* FIX: Force GPU acceleration and prevent flickering */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* FIX: Prevent hover state flicker at edges by adding transparent outline that extends hitbox */
    outline: 2px solid transparent;
    outline-offset: -2px;
    /* CRITICAL FIX: Set base transform to match hover transform syntax.
       This ensures smooth transition and prevents "jump" effect when hovering.
       Base state: no movement. Hover state: -3px up. */
    transform: translate3d(0, 0, 0);
}

/* Triple shadow system for depth */
.btn-enterprise {
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading) {
    /* FIX: Use translate3d instead of translateY for better GPU acceleration */
    transform: translate3d(0, -3px, 0);
    box-shadow:
        0 12px 28px rgba(0, 0, 0, 0.12),
        0 6px 12px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-enterprise:active:not(:disabled):not(.is-disabled):not(.is-loading) {
    /* FIX: Use translate3d instead of translateY for better GPU acceleration */
    transform: translate3d(0, -1px, 0);
    transition:
        transform 0.1s,
        box-shadow 0.1s;
}

/* Shine effect overlay - contained within button to prevent overflow affecting adjacent buttons */
.btn-enterprise::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    transition: left 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* Reduced from 0.6s to prevent flicker on rapid hover state changes */
    z-index: 1;
    border-radius: var(--btn-radius);
    /* Clip shine effect to button boundaries to prevent affecting adjacent elements */
    clip-path: inset(0 0 0 0 round var(--btn-radius));
    /* CRITICAL FIX: Prevent shine effect from intercepting mouse events that cause adjacent button flicker.
       clip-path only affects visual rendering, NOT mouse event detection.
       The ::before extends beyond button bounds (left: -100% to left: 100%) during animation,
       so it can trigger false hover states on adjacent buttons despite being visually clipped. */
    pointer-events: none;
}

.btn-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading)::before {
    left: 100%;
}

/* Icon animation */
.btn-enterprise i,
.btn-enterprise svg {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

/* Base icon hover removed - only use specific icon animations (icon-slide-right, etc.) to prevent double scaling */

/* Text z-index */
.btn-enterprise > * {
    position: relative;
    z-index: 2;
}

/* ============================================
   PRIMARY BUTTON - ENTERPRISE
   ============================================ */

.btn-primary-enterprise {
    background: linear-gradient(
        135deg,
        #d97642 0%,
        #e8915f 50%,
        #d97642 100%
    );
    background-size: 200% 200%;
    color: var(--color-white);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading) {
    background-position: 100% 0;
    box-shadow:
        0 12px 32px rgba(217, 118, 66, 0.35),
        0 6px 16px rgba(217, 118, 66, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* Luminous border effect - contained to prevent affecting adjacent buttons */
/* Note: This uses ::after which conflicts with hover buffer on base .btn-enterprise */
/* Primary buttons get border effect instead of buffer (acceptable trade-off) */
.btn-primary-enterprise::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-xl);
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 0;
    /* Clip to prevent border effect from bleeding into adjacent buttons */
    clip-path: inset(-1px -1px -1px -1px round var(--radius-xl));
    pointer-events: none; /* Ensure this doesn't interfere with click events */
}

.btn-primary-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading)::after {
    opacity: 1;
}

/* ============================================
   SECONDARY BUTTON - GLASSMORPHISM
   ============================================ */

.btn-secondary-enterprise {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(255, 255, 255, 0.85) 100%
    );
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    color: var(--color-primary);
    border: 2px solid rgba(217, 118, 66, 0.2);
}

.btn-secondary-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading) {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 1) 0%,
        rgba(248, 244, 240, 1) 100%
    );
    border-color: rgba(217, 118, 66, 0.4);
    box-shadow:
        0 12px 32px rgba(217, 118, 66, 0.2),
        0 6px 16px rgba(217, 118, 66, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Inner glow */
/* Note: This uses ::after which conflicts with hover buffer on base .btn-enterprise */
/* Secondary buttons get inner glow instead of buffer (acceptable trade-off) */
.btn-secondary-enterprise::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: calc(var(--btn-radius) - 2px); /* Use custom property */
    background: radial-gradient(
        circle at 50% 0%,
        rgba(217, 118, 66, 0.1) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
    pointer-events: none; /* Ensure this doesn't interfere with click events */
}

.btn-secondary-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading)::after {
    opacity: 1;
}

/* ============================================
   GHOST BUTTON - OUTLINE VARIANT
   ============================================ */

.btn-ghost-enterprise {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
    box-shadow: none;
}

.btn-ghost-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading) {
    background: var(--color-primary);
    color: var(--color-white);
    border-color: var(--color-primary);
    box-shadow:
        0 8px 24px rgba(217, 118, 66, 0.3),
        0 4px 8px rgba(217, 118, 66, 0.2);
}

.btn-ghost-enterprise::before {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
}

/* ============================================
   WHITE BUTTON - PREMIUM
   ============================================ */

.btn-white-enterprise {
    background: var(--color-white);
    color: var(--color-gray-800);
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.btn-white-enterprise:hover:not(:disabled):not(.is-disabled):not(.is-loading) {
    background: var(--color-snow);
    border-color: rgba(217, 118, 66, 0.3);
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.15),
        0 6px 16px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 1);
}

/* ============================================
   SIZE VARIANTS
   ============================================ */

.btn-enterprise-sm {
    padding: 0.625rem 1.25rem;
    font-size: var(--font-size-sm);
}

.btn-enterprise-lg {
    padding: 1.125rem 2.25rem;
    font-size: var(--font-size-lg);
}

.btn-enterprise-xl {
    padding: 1.375rem 2.75rem;
    font-size: var(--font-size-xl);
    font-weight: 700;
    min-width: 220px;
}

/* ============================================
   BUTTON STATES
   ============================================ */

/* Loading state */
.btn-enterprise.is-loading {
    pointer-events: none;
    position: relative;
}

.btn-enterprise.is-loading > *:not(.btn-spinner) {
    opacity: 0;
}

.btn-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    z-index: 3; /* Above all button content including icons (z:2) */
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Disabled state */
.btn-enterprise:disabled,
.btn-enterprise.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    transform: none; /* No !important needed with :not() selectors */
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.08),
        0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Focus state for accessibility - using box-shadow instead of outline to avoid clipping */
.btn-enterprise:focus-visible {
    outline: none;
    box-shadow:
        0 4px 14px rgba(0, 0, 0, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 0 0 3px rgba(217, 118, 66, 0.4); /* Focus ring using box-shadow */
}

/* ============================================
   RIPPLE EFFECT CONTAINER
   ============================================ */

.btn-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
    z-index: 1; /* Below text/icons (z:2) but above background, below badge (z:10) */
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   BADGE ON BUTTON
   ============================================ */

/* EXCEPTION: Buttons with badges need visible overflow to show badges positioned outside
   Uses :has() selector - fallback: badges may be clipped in older browsers */
.btn-enterprise:has(.btn-badge-enterprise) {
    overflow: visible;
}

.btn-enterprise .btn-badge-enterprise {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ff5733 0%, #ff8c42 100%);
    color: var(--color-white);
    font-size: 0.625rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    box-shadow:
        0 4px 12px rgba(255, 87, 51, 0.4),
        0 2px 4px rgba(255, 87, 51, 0.3);
    border: 2px solid var(--color-white);
    z-index: 10;
    animation: badgePulse 2s ease-in-out infinite;
    white-space: nowrap;
    will-change: transform; /* Optimize animation performance */
    /* FIX: Prevent badge from intercepting mouse events that cause adjacent button flicker.
       The badge extends outside button bounds (top: -8px, right: -8px) and can overlap
       into adjacent buttons' hover zones. This causes flicker as mouse events alternate
       between the badge and the adjacent button. pointer-events: none ensures badge
       is purely visual and doesn't interfere with button hover detection. */
    pointer-events: none;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1) translateZ(0); /* GPU acceleration */
    }
    50% {
        transform: scale(1.05) translateZ(0);
    }
}

/* ============================================
   ICON ANIMATIONS
   ============================================ */

/* Slide right on hover - FIX: Add :not() selectors to prevent animations on disabled/loading states */
.btn-enterprise.icon-slide-right:hover:not(:disabled):not(.is-disabled):not(.is-loading) i:last-child,
.btn-enterprise.icon-slide-right:hover:not(:disabled):not(.is-disabled):not(.is-loading) svg:last-child {
    /* FIX: Use translate3d for GPU acceleration */
    transform: translate3d(4px, 0, 0) scale(1.1);
}

/* Slide left on hover - FIX: Add :not() selectors to prevent animations on disabled/loading states */
.btn-enterprise.icon-slide-left:hover:not(:disabled):not(.is-disabled):not(.is-loading) i:first-child,
.btn-enterprise.icon-slide-left:hover:not(:disabled):not(.is-disabled):not(.is-loading) svg:first-child {
    /* FIX: Use translate3d for GPU acceleration */
    transform: translate3d(-4px, 0, 0) scale(1.1);
}

/* Bounce on hover - FIX: Add :not() selectors to prevent animations on disabled/loading states */
.btn-enterprise.icon-bounce:hover:not(:disabled):not(.is-disabled):not(.is-loading) i,
.btn-enterprise.icon-bounce:hover:not(:disabled):not(.is-disabled):not(.is-loading) svg {
    animation: iconBounce 0.6s ease;
}

@keyframes iconBounce {
    0%, 100% {
        /* FIX: Use translate3d for GPU acceleration */
        transform: translate3d(0, 0, 0) scale(1.1);
    }
    50% {
        /* FIX: Use translate3d for GPU acceleration */
        transform: translate3d(0, -4px, 0) scale(1.15);
    }
}

/* Rotate on hover - FIX: Add :not() selectors to prevent animations on disabled/loading states */
.btn-enterprise.icon-rotate:hover:not(:disabled):not(.is-disabled):not(.is-loading) i,
.btn-enterprise.icon-rotate:hover:not(:disabled):not(.is-disabled):not(.is-loading) svg {
    transform: rotate(15deg) scale(1.1);
}

/* ============================================
   BUTTON GROUP
   ============================================ */

.btn-group-enterprise {
    display: flex;
    flex-wrap: wrap;
    /* Fallback for browsers without gap support (Safari <14.1) */
    margin: calc(var(--spacing-md) * -0.5);
}

.btn-group-enterprise .btn-enterprise {
    flex: 0 1 auto;
    /* Fallback for browsers without gap support */
    margin: calc(var(--spacing-md) * 0.5);
}

/* Modern browsers with gap support */
@supports (gap: 1rem) {
    .btn-group-enterprise {
        gap: var(--spacing-md);
        margin: 0;
    }

    .btn-group-enterprise .btn-enterprise {
        margin: 0;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .btn-enterprise {
        padding: 0.75rem 1.5rem;
        font-size: var(--font-size-sm);
    }

    .btn-enterprise-xl {
        padding: 1rem 2rem;
        font-size: var(--font-size-lg);
        min-width: 180px;
    }

    .btn-group-enterprise {
        flex-direction: column;
        width: 100%;
    }

    .btn-group-enterprise .btn-enterprise {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .btn-enterprise {
        padding: 0.625rem 1.25rem;
        font-size: var(--font-size-sm);
    }

    .btn-enterprise-xl {
        padding: 0.875rem 1.75rem;
        font-size: var(--font-size-base);
        min-width: 160px;
    }

    /* Badge responsive styles removed - minimal difference doesn't justify the code */
}

/* ============================================
   FEEDBACK STATES
   ============================================ */

.btn-feedback-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    background-size: 100% 100% !important;
}

.btn-feedback-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    background-size: 100% 100% !important;
}

/* ============================================
   SHAKE ANIMATION
   ============================================ */

@keyframes shake {
    0%, 100% {
        transform: translateX(0) translateY(0);
    }
    25% {
        transform: translateX(-10px) translateY(0);
    }
    75% {
        transform: translateX(10px) translateY(0);
    }
}

.btn-shake {
    animation: shake 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
