/**
 * WC Crypto Pay – Inline Checkout Box
 * Styles for Buy Now button, product-detail inline box, and product-list modal.
 */

/* ============================================================
   Hide default WooCommerce Add-to-Cart on single product
   (replaced by Buy Now)
   ============================================================ */
body.single-product .single_add_to_cart_button,
body.single-product .woocommerce-variation-add-to-cart .single_add_to_cart_button {
    display: none !important;
}

/* Hide cart icon / redirect notices that show after add-to-cart */
body.single-product .woocommerce-message,
body.single-product .added_to_cart {
    display: none !important;
}

/* ============================================================
   BUY NOW BUTTON (product detail + product list)
   ============================================================ */
.crypto-buy-now-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: var(--wp--preset--color--primary, #446084);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    line-height: 1.3;
    letter-spacing: 0.01em;
    box-sizing: border-box;
    margin-top: 10px;
}

.crypto-buy-now-btn:hover {
    opacity: 0.88;
}

.crypto-buy-now-btn:active {
    transform: scale(0.99);
}

.crypto-buy-now-btn svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

/* Single product page inline button */
body.single-product .crypto-buy-now-btn.crypto-buy-now-btn--single {
    width: auto;
    flex: 1;
    margin-top: 0;
    margin-left: 10px;
}

/* Smaller variant for product loop cards */
.crypto-buy-now-btn.crypto-buy-now-btn--loop {
    font-size: 12px;
    padding: 6px 12px;
    margin-top: 6px;
    border-radius: 4px;
    line-height: 1.2;
}

/* ============================================================
   COIN EQUIVALENT UNDER PRODUCT PRICE (product detail)
   ============================================================ */
.crypto-price-coin-equiv {
    display: none; /* shown by JS after coin selected */
    font-size: 13px;
    color: #888;
    margin-top: 4px;
    line-height: 1.4;
}

.crypto-price-coin-equiv.visible {
    display: block;
}

/* ============================================================
   INLINE CHECKOUT BOX (product detail page)
   ============================================================ */
.crypto-inline-box {
    display: none; /* shown by JS slideDown */
    margin-top: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
    overflow: hidden;
}

.crypto-inline-box-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 12px !important;
    border-bottom: 1px solid #f0f0f0 !important;
    min-height: unset !important;
    height: auto !important;
}

.crypto-inline-box-title {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #999 !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.crypto-label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 2px 0 !important;
}

.crypto-inline-box-cancel {
    background: #fef2f2 !important;
    border: 1px solid #fecaca !important;
    padding: 0 !important;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    box-sizing: border-box !important;
    cursor: pointer;
    color: #ef4444 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    transition: all 0.15s !important;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
    align-self: center !important;
    aspect-ratio: 1/1 !important; /* Force exact square shape for border-radius */
}

.crypto-inline-box-cancel:hover {
    background: #fee2e2 !important;
    color: #b91c1c !important;
    border-color: #fca5a5 !important;
}

.crypto-inline-box-cancel svg {
    width: 12px !important;
    height: 12px !important;
    display: block !important;
}

.crypto-inline-box-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Product summary row inside box */
.crypto-inline-product-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.crypto-inline-product-thumb {
    width: 52px;
    height: 52px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fafafa;
}

.crypto-inline-product-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.crypto-inline-product-price {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    flex-shrink: 0;
    text-align: right;
}

.crypto-rate-info {
    font-size: 13px;
    color: #94a3b8;
    margin-top: -4px;
}

.crypto-inline-product-coin-price {
    font-size: 11px;
    color: #888;
    margin-top: 2px;
    display: none; /* shown by JS */
}

/* Email field */
.crypto-inline-field-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.crypto-inline-label {
    font-size: 13px;
    font-weight: 500;
    color: #444;
}

.crypto-inline-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    color: #1a1a1a;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
    outline: none;
}

.crypto-inline-input:focus {
    border-color: var(--wp--preset--color--primary, #446084);
    box-shadow: 0 0 0 2px rgba(68,96,132,0.12);
}

.crypto-inline-input::placeholder {
    color: #bbb;
}

/* Coin selector (reuses existing .crypto-dropdown styles from checkout.css) */
.crypto-inline-coin-label {
    font-size: 13px;
    font-weight: 500;
    color: #444;
    margin-bottom: 5px;
    display: block;
}

/* Quantity stepper (pill style under product name) */
.crypto-inline-qty-wrap {
    display: flex;
    align-items: center; /* keep them vertically centered */
    gap: 0;
    border: 1px solid #cbd5e1; /* softer outline */
    border-radius: 999px;
    overflow: hidden;
    width: fit-content;
    background: #f8fafc;
    height: 34px;
}

.crypto-qty-btn {
    width: 36px;
    height: 100%;
    border: none;
    background: transparent;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    padding: 0;
    margin: 0;
}

.crypto-qty-btn:hover {
    color: #0f172a;
    background: #f1f5f9;
}

.crypto-inline-qty-input {
    width: 48px !important;
    height: 100% !important;
    text-align: center !important;
    border: none !important;
    border-left: 1px solid #cbd5e1 !important;
    border-right: 1px solid #cbd5e1 !important;
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    color: #0f172a !important;
    box-shadow: none !important;
    -moz-appearance: textfield !important;
    appearance: textfield !important;
    display: flex !important;
    align-items: center !important;
    line-height: 1 !important; /* ensures exact vertical centering of the number */
}

.crypto-inline-qty-input::-webkit-inner-spin-button,
.crypto-inline-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Coupon row */
.crypto-inline-coupon-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

.crypto-inline-coupon-wrap .crypto-inline-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 13px;
}

.crypto-coupon-apply-btn {
    padding: 0;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 400;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s;
}

.crypto-coupon-apply-btn:hover {
    color: var(--wp--preset--color--primary, #446084);
}

.crypto-coupon-feedback {
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.4;
}

.crypto-coupon-feedback.success {
    color: #16a34a;
}

.crypto-coupon-feedback.error {
    color: #dc2626;
}

/* Payment details card inside inline box – populated by JS, inherits .crypto-payment-card styles */

/* Order summary (subtotal / discount / total) */
.crypto-order-summary {
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 8px 12px;
    background: #fafafa;
}

.crypto-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #555;
    padding: 3px 0;
}

.crypto-summary-discount {
    color: #16a34a;
}

.crypto-summary-total {
    font-weight: 700;
    color: #111;
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
    padding-top: 5px;
}

/* Coupon toggle link */
.crypto-coupon-toggle {
    font-size: 12px;
    color: #888;
    text-decoration: none;
    display: inline-block;
}

.crypto-coupon-toggle:hover {
    color: var(--wp--preset--color--primary, #446084);
    text-decoration: underline;
}

/* Confirm section */
.crypto-inline-confirm-section {
    padding: 0;
}

.crypto-inline-confirm-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: #444;
    cursor: pointer;
    line-height: 1.4;
}

.crypto-inline-confirm-label input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--wp--preset--color--primary, #446084);
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    cursor: pointer;
}

/* Place order button inside box */
.crypto-inline-place-order {
    width: 100%;
    padding: 9px 16px;
    background: var(--wp--preset--color--primary, #446084);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: opacity 0.2s;
    display: none; /* shown by JS when confirmed */
    box-sizing: border-box;
}

.crypto-inline-place-order:hover {
    opacity: 0.88;
}

.crypto-inline-place-order:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Inline icon copy button (inside payment card amount / address rows) */
.crypto-copy-inline-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 2px 3px;
    margin-left: 4px;
    cursor: pointer;
    color: #9ca3af;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
    vertical-align: middle;
    line-height: 1;
}

.crypto-copy-inline-btn:hover {
    color: var(--wp--preset--color--primary, #446084);
    background: rgba(68,96,132,0.08);
}

.crypto-copy-inline-btn.copied {
    color: #16a34a;
}

/* Address row: code + copy icon side by side */
.crypto-address-row {
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 3px 4px 3px 8px;
    gap: 4px;
}

.crypto-address-row .address-text {
    flex: 1;
    font-family: 'SF Mono', 'Fira Mono', monospace;
    font-size: 12px;
    color: #1e293b;
    word-break: break-all;
    background: transparent;
    border: none;
    padding: 5px 0;
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

/* Payment verification status */
.crypto-verify-status {
    font-size: 12px;
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    line-height: 1.4;
}

.crypto-verify-status.checking {
    background: #fffbeb;
    color: #92400e;
}

.crypto-verify-status.ok {
    background: #f0fdf4;
    color: #166534;
}

.crypto-verify-status.warn {
    background: #eff6ff;
    color: #1e40af;
}

/* Cancel link at footer of box */
.crypto-inline-cancel-link {
    display: block;
    text-align: center;
    font-size: 12px;
    color: #999;
    text-decoration: none;
    margin-top: 4px;
    cursor: pointer;
    transition: color 0.15s;
    background: none;
    border: none;
    width: 100%;
    padding: 0;
}

.crypto-inline-cancel-link:hover {
    color: #e53e3e;
    text-decoration: none;
}

/* Error / notice inside box */
.crypto-inline-notice {
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    display: none;
}

.crypto-inline-notice.error {
    background: #fef2f2;
    color: #991b1b;
}

.crypto-inline-notice.success {
    background: #f0fdf4;
    color: #166534;
}

/* ============================================================
   MODAL OVERLAY (product list / shop page)
   ============================================================ */
.crypto-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99990;
    /* Bottom sheet alignment for all screens */
    overflow-y: auto;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    box-sizing: border-box;
    backdrop-filter: blur(3px);
}

.crypto-modal-overlay.active {
    display: flex;
}

.crypto-modal-card {
    background: #fff;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 480px;
    position: relative;
    animation: cryptoModalInBottom 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin: auto auto 0 auto;
}

@keyframes cryptoModalInBottom {
    from { opacity: 0; transform: translateY(100%); }
    to   { opacity: 1; transform: translateY(0); }
}



/* Modal uses same inner structure as inline box */
.crypto-modal-card .crypto-inline-box-header {
    border-radius: 14px 14px 0 0;
    background: #fafafa;
}

/* ============================================================
   QUANTITY DISPLAY in product detail (read-only)
   ============================================================ */
.crypto-inline-qty-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
}

.crypto-inline-qty-label {
    font-weight: 500;
}

/* ============================================================
   SHARED: Loading spinner inside inline box
   ============================================================ */
.crypto-inline-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #888;
    padding: 12px 0;
}

.crypto-inline-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--wp--preset--color--primary, #446084);
    border-radius: 50%;
    animation: cryptoSpin 0.7s linear infinite;
    flex-shrink: 0;
}

@keyframes cryptoSpin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
    .crypto-modal-card {
        max-width: 100%;
    }

    .crypto-inline-box-body {
        padding: 16px;
    }
}

/* ============================================================
   PAYMENT INFO LAYOUT OVERRIDES
   ============================================================ */
.crypto-pay-info-col {
    gap: 2px !important;
}

.crypto-info-block {
    gap: 1px !important;
}

.crypto-label {
    margin-bottom: 1px !important;
}

.crypto-amount-value {
    margin-bottom: 0 !important;
    line-height: 1.1 !important;
}

.crypto-rate-info {
    margin-top: 0 !important;
    margin-bottom: 6px !important;
    font-size: 12px !important;
    line-height: 1 !important;
}

/* Wallet address: compact borderless style */
.crypto-address-row {
    padding: 3px 4px 3px 8px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 5px !important;
}

.crypto-address-row .address-text {
    font-size: 11px !important;
    padding: 3px 0 !important;
    line-height: 1.4 !important;
}

/* ============================================================
   QR Code Light Effect (Conic Gradient Animation)
   ============================================================ */
.crypto-qr-anim-wrapper {
    position: relative;
    padding: 3px;
    border-radius: 8px;
    overflow: hidden;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: #e2e8f0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.crypto-qr-anim-wrapper::before {
    content: '';
    position: absolute;
    width: 250%;
    height: 250%;
    /* Bright green racing effect */
    background: conic-gradient(transparent, transparent, transparent, #22c55e, #10b981);
    animation: qrLightSpin 2.5s linear infinite;
}

.crypto-qr-code {
    position: relative;
    z-index: 2;
    background: #fff;
    border-radius: 5px;
    /* Extra padding inside so the QR code isn't flush against the glowing border */
    padding: 4px;
}

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

/* ============================================================
   SCROLL INDICATOR (shown when modal has hidden content below)
   Dùng sticky để tránh vấn đề stacking context của backdrop-filter
   ============================================================ */
.crypto-scroll-hint {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding-bottom: 12px;
    pointer-events: none;
    z-index: 10;
    /* Gradient mờ dần từ trong suốt → trắng để hint "nổi" lên tự nhiên */
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.95) 45%);
    transition: opacity 0.3s ease, visibility 0.3s ease;
    visibility: visible;
    opacity: 1;
    /* Chiều cao đủ để gradient thấy rõ */
    min-height: 52px;
}

.crypto-scroll-hint.hidden {
    opacity: 0;
    visibility: hidden;
}

.crypto-scroll-hint-cursor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    /* Animation chỉ dùng translate để tránh conflict */
    animation: cryptoScrollBounce 1.1s ease-in-out infinite;
}

.crypto-scroll-hint-cursor svg {
    width: 20px;
    height: 20px;
    color: var(--wp--preset--color--primary, #446084);
    opacity: 0.75;
    filter: drop-shadow(0 1px 3px rgba(68,96,132,0.25));
}

.crypto-scroll-hint-cursor span {
    font-size: 9px;
    font-weight: 700;
    color: var(--wp--preset--color--primary, #446084);
    opacity: 0.65;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    line-height: 1;
}

@keyframes cryptoScrollBounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(4px); }
}
