/* ========================================
   CHECKOUT CORE CSS
   Estilos funcionais essenciais que todos os temas precisam
   ======================================== */


/* Form Validation States - CORE FUNCTIONALITY */

.form-control.show-invalid {
    border-color: var(--error, #EF4444) !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
    padding-right: calc(1.5em + 0.75rem);
}

.form-control.show-invalid+.invalid-feedback {
    display: block;
    color: var(--error, #EF4444);
    font-size: 0.875em;
    margin-top: 0.25rem;
}

.form-control.show-valid {
    border-color: var(--success, #10B981) !important;
}

.invalid-feedback {
    display: none;
    color: var(--error, #EF4444);
    font-size: 0.875em;
    margin-top: 0.25rem;
}


/* Payment Button States - CORE FUNCTIONALITY */

.btn-payment {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    transform: translateZ(0);
}

.btn-payment.loading {
    pointer-events: none !important;
    opacity: 0.9 !important;
    cursor: not-allowed !important;
    transform: scale(0.98) !important;
}

.btn-payment.loading:hover {
    transform: scale(0.98) !important;
}

.btn-payment .payment-text {
    transition: opacity 0.25s ease-in-out;
    font-weight: bold;
}

.btn-payment.loading .payment-text {
    opacity: 0 !important;
    font-weight: bold;
}

.btn-payment.blocked {
    animation: blockedShake 0.4s ease-in-out;
}

.btn-payment.btn-validation-error {
    background-color: var(--error, #EF4444) !important;
    transform: scale(0.98);
    animation: validationErrorPulse 1.5s ease-in-out;
}

@keyframes blockedShake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-3px);
    }
    75% {
        transform: translateX(3px);
    }
}

@keyframes validationErrorPulse {
    0% {
        transform: scale(0.98);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(0.98);
    }
}

.spinner-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
    font-weight: 500;
}

.btn-payment.loading .spinner-container {
    opacity: 1 !important;
    display: flex !important;
}

.spinner-container span {
    color: white !important;
    font-weight: 500 !important;
    margin-left: 0.25rem;
}

.payment-spinner {
    display: inline-block;
    width: 1.2rem;
    height: 1.2rem;
    margin-right: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    border-right-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


/* Order Bump Selection States - CORE FUNCTIONALITY */

.order-bump-item {
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.order-bump-item:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transform: translateY(-2px);
}

.order-bump-item.selected {
    background-color: rgba(var(--secondary-rgb, 16, 185, 129), 0.2);
    border-color: var(--secondary, #10B981);
}

.order-bump-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}


/* Payment Method Selection States - CORE FUNCTIONALITY */

.payment-method {
    cursor: pointer;
    transition: border-color 0.15s ease-in-out;
}

.payment-method:hover {
    border-color: var(--secondary, #10B981);
}

.payment-method.active {
    border-color: var(--secondary, #10B981);
    background-color: rgba(var(--secondary-rgb, 16, 185, 129), 0.05);
}


/* Credit Card Fields Validation - CORE FUNCTIONALITY */

#credit-card-fields .form-group input.show-invalid {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

#credit-card-fields .form-group input.show-valid {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
}


/* Error Overlay - CORE FUNCTIONALITY */

#checkout-blur-content {
    filter: blur(3px) grayscale(0.2);
    pointer-events: none;
    user-select: none;
}

.checkout-error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(255, 255, 255, 0.97);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkout-error-modal {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    padding: 48px 32px 36px 32px;
    max-width: 95vw;
    width: 100%;
    max-width: 420px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.checkout-error-modal .icon {
    font-size: 3.5rem;
    color: #F7D44C;
    margin-bottom: 8px;
}

.checkout-error-modal h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 0.5rem;
}

.checkout-error-modal p {
    color: #555;
    font-size: 1.08rem;
    margin-bottom: 1.2rem;
}

.checkout-error-modal .try-again {
    background: #f3f4f6;
    color: #374151;
    font-size: 0.95rem;
    font-weight: 600;
    border: 1px solid #d1d5db;
    padding: 0.55rem 1.25rem;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    margin-top: -0.8rem;
    margin-bottom: 0.5rem;
}

.checkout-error-modal .try-again:hover {
    background: #e5e7eb;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

@media (max-width: 600px) {
    .checkout-error-modal {
        padding: 32px 8vw 24px 8vw;
    }
}


/* Coupon Toggle States - CORE FUNCTIONALITY */

.coupon-toggle i.fa-chevron-down {
    transition: transform 0.2s ease;
}

.coupon-toggle.open i.fa-chevron-down {
    transform: rotate(180deg);
}


/* Core Color Variables */

:root {
    --error: #EF4444;
    --success: #10B981;
}

/* Button Animations - CORE FUNCTIONALITY */

.btn-animation-pulse {
    animation: buttonPulse 2s ease-out infinite;
}

@keyframes buttonPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--theme-secondary-rgb, 58, 182, 95), 0.7);
    }
    100% {
        box-shadow: 0 0 0 8px rgba(var(--theme-secondary-rgb, 58, 182, 95), 0);
    }
}

.btn-animation-bounce {
    animation: buttonScale 2s ease-in-out infinite;
}

@keyframes buttonScale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
}

.btn-animation-shake {
    animation: buttonShake 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes buttonShake {
    0% {
        transform: translateX(0);
    }
    /* 5 tremidas suaves com variação aleatória (~5%) e espaçamento maior */
    /* Tremida 1 */
    2.5% {
        transform: translateX(-4.2px);
    }
    4.5% {
        transform: translateX(0);
    }
    /* Tremida 2 */
    7% {
        transform: translateX(3.8px);
    }
    9% {
        transform: translateX(0);
    }
    /* Tremida 3 */
    11.5% {
        transform: translateX(-4.5px);
    }
    13.5% {
        transform: translateX(0);
    }
    /* Tremida 4 */
    16% {
        transform: translateX(4.1px);
    }
    18% {
        transform: translateX(0);
    }
    /* Tremida 5 */
    20.5% {
        transform: translateX(-3.9px);
    }
    23.5% {
        transform: translateX(0);
    }
    /* Pausa de 1 segundo (de 23.5% até 57% = ~1s) */
    57% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(0);
    }
}


/* Utility Classes for Core Functionality */

.animate-fade-in {
    animation: fadeIn 0.5s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.5s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}