/**
 * Hyva Theme Styles for TBI FusionPay
 * Uses Tailwind CSS utility classes and custom styles
 */

/* Alpine.js x-cloak to prevent flash of unstyled content */
[x-cloak] {
    display: none !important;
}

/* TBI Button Animations */
.tbi-button {
    transition: all 0.2s ease-in-out;
}

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

.tbi-button:active {
    transform: translateY(0);
}

/* Modal Backdrop Animation */
.modal-backdrop {
    animation: fadeIn 0.2s ease-in-out;
}

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

/* Iframe Loading State */
#tbi_loading {
    animation: fadeIn 0.3s ease-in-out;
}

#tbi_loading img {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Success Message Styling */
.fusion-pay-custom-message {
    animation: slideInDown 0.4s ease-out;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus States for Accessibility */
.tbi-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Orange Text Color (matching brand) */
.text-orange-600 {
    color: #ea580c;
}

.text-orange {
    color: #ea580c;
}

/* Additional Button Variants */
.tbi-button-primary {
    background-color: #2563eb;
    color: #ffffff;
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.tbi-button-primary:hover {
    background-color: #1d4ed8;
}

.tbi-button-secondary {
    background-color: #e5e7eb;
    color: #1f2937;
    transition-property: color, background-color, border-color;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.tbi-button-secondary:hover {
    background-color: #d1d5db;
}

.fusionpay-hyva-product-button #tbi_button_container {
    display: block;
    box-sizing: border-box;
    width: 100%;
    max-width: 560px;
    min-width: 0;
}

.fusionpay-hyva-product-button .tbi_button1,
.fusionpay-hyva-product-button .tbi_button_ro {
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 560px;
}

.fusionpay-hyva-product-button #tbi_button_body1,
.fusionpay-hyva-product-button .tbi_button_body_ro {
    align-items: center;
    background: #fff !important;
    border: 1px solid #e7e7e7;
    border-radius: 24px !important;
    box-shadow: 0 12px 26px rgb(17 24 39 / 12%) !important;
    box-sizing: border-box;
    color: #1f2430 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 10px;
    justify-content: space-between !important;
    width: 310px;
    max-width: 560px;
    height: 64px;
    padding: 8px !important;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.fusionpay-hyva-product-button #tbi_button:hover .tbi_button_body_ro,
.fusionpay-hyva-product-button #tbi_button:focus-within .tbi_button_body_ro {
    background: #f3f3f3 !important;
    box-shadow: none !important;
    transform: translateY(-4px);
}

.fusionpay-hyva-product-button .tbi_button_ro_brand {
    align-items: center;
    display: flex;
    flex: 0 0 auto;
    justify-content: center;
}

.fusionpay-hyva-product-button #tbi_button_logo1,
.fusionpay-hyva-product-button .tbi_button_ro_logo {
    height: auto;
    margin: 0;
    max-height: 44px;
    width: 44px;
}

.fusionpay-hyva-product-button .tbi_button_ro_copy {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* ------------------------
 * RO offer state animation
 * ------------------------ */

.fusionpay-hyva-product-button .tbi_button_ro_state_viewport {
    display: flex;
    align-items: center;
    min-height: 48px;
    overflow: hidden;
    position: relative;
    width: 100%;
}

.fusionpay-hyva-product-button .tbi_button_body_ro--bnpl .tbi_button_ro_state_viewport,
.fusionpay-hyva-product-button .tbi_button_body_ro--standard .tbi_button_ro_state_viewport {
    justify-content: flex-start;
    min-height: 48px;
}

.fusionpay-hyva-product-button .tbi_button_ro_state_track {
    display: flex;
    flex-direction: column;
    position: relative;
    transform: translateY(0);
    transition: transform 0.24s ease;
    will-change: transform;
    width: 100%;
}

.fusionpay-hyva-product-button .tbi_button_ro_state_track.is-animating-up {
    transform: translateY(-100%);
}

.fusionpay-hyva-product-button .tbi_button_ro_state_track.is-animating-down {
    transform: translateY(100%);
}

.fusionpay-hyva-product-button .tbi_button_ro_state_track.is-resetting {
    transition: none;
}

.fusionpay-hyva-product-button .tbi_button_ro_state {
    align-items: flex-start;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    gap: 4px;
    min-height: 48px;
    width: 100%;
}

.fusionpay-hyva-product-button .tbi_button_ro_state--next {
    left: 0;
    pointer-events: none;
    position: absolute;
}

/* A -> B: B starts above and slides down into view. */
.fusionpay-hyva-product-button .tbi_button_ro_state_track.direction-down .tbi_button_ro_state--next {
    top: -100%;
}

/* B -> A: A starts below and slides up into view. */
.fusionpay-hyva-product-button .tbi_button_ro_state_track.direction-up .tbi_button_ro_state--next {
    top: 100%;
}

.fusionpay-hyva-product-button .tbi_button_body_ro--bnpl .tbi_button_ro_state,
.fusionpay-hyva-product-button .tbi_button_body_ro--standard .tbi_button_ro_state {
    align-items: flex-start;
}

.fusionpay-hyva-product-button .tbi_button_ro_title {
    color: #ff6600;
    display: block;
    font-family: 'Inter', open-sans;
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    text-align: left;
    white-space: nowrap;
}

.fusionpay-hyva-product-button .tbi_button_line--ro-amount {
    color: #202532;
    display: block;
    font-family: 'Inter', open-sans;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.25;
    margin: 0;
    padding: 0;
    text-align: left;
    white-space: nowrap;
}

.fusionpay-hyva-product-button .tbi_button_ro_details {
    background: #ffe8db;
    border-radius: 18px;
    color: #ff6600;
    flex: 0 0 auto;
    font-family: 'Inter', open-sans;
    font-size: 16px;
    font-weight: 600;
    line-height: 0.75;
    padding: 10px 14px;
    white-space: nowrap;
}

@media (max-width: 640px) {
    .fusionpay-hyva-product-button #tbi_button_container,
    .fusionpay-hyva-product-button .tbi_button1,
    .fusionpay-hyva-product-button .tbi_button_ro,
    .fusionpay-hyva-product-button #tbi_button_body1,
    .fusionpay-hyva-product-button .tbi_button_body_ro {
        max-width: 400px;
    }
}
