/* ═══════════════════════════════════════════════════════════════
   Threadwair Smart Checkout v9 — Premium Mobile-First Cart UI
   Inspired by Snitch, Nike, Zara — dark streetwear aesthetic
   ═══════════════════════════════════════════════════════════════ */

/* ── RESET CART PAGE CHROME ─────────────────────────────────── */
.twpcod-cart-page .woocommerce-cart-form table {
    border: none !important;
}

/* ── SOCIAL PROOF TICKER ────────────────────────────────────── */
.twpcod-ticker {
    background: #111827;
    color: #f9fafb;
    overflow: hidden;
    padding: 9px 0;
    margin-bottom: 16px;
    border-radius: 10px;
    position: relative;
}
.twpcod-ticker__track {
    display: flex;
    gap: 48px;
    width: max-content;
    animation: twpcod-scroll 55s linear infinite;
}
.twpcod-ticker__item {
    font-size: 12.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
}
.twpcod-ticker__dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 6px #22c55e;
    animation: twpcod-pulse 1.5s infinite;
}
@keyframes twpcod-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}
@keyframes twpcod-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── UPSELL BANNER ──────────────────────────────────────────── */
.twpcod-banner { margin-bottom: 16px; }
.twpcod-banner__inner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 13.5px;
    animation: twpcod-slidein 0.3s ease;
}
.twpcod-banner--upsell {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 1px solid #374151;
    color: #f3f4f6;
}
.twpcod-banner--success {
    background: linear-gradient(135deg, #052e16 0%, #064e3b 100%);
    border: 1px solid #065f46;
    color: #d1fae5;
}
.twpcod-banner__icon { font-size: 22px; flex-shrink: 0; }
.twpcod-banner__text {
    display: flex; flex-direction: column; flex: 1; gap: 2px;
}
.twpcod-banner__text strong { font-size: 14px; font-weight: 700; }
.twpcod-banner--upsell .twpcod-banner__text strong { color: #fff; }
.twpcod-banner--success .twpcod-banner__text strong { color: #a7f3d0; }
.twpcod-banner__text span { font-size: 12.5px; opacity: 0.85; }
.twpcod-banner__pill {
    background: #facc15;
    color: #111;
    font-size: 11px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

/* ── URGENCY TIMER ──────────────────────────────────────────── */
.twpcod-urgency {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff7ed;
    border: 1.5px solid #fed7aa;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 13px;
    color: #9a3412;
    pointer-events: none;
    position: relative;
    z-index: 0;
    isolation: isolate;
}
.twpcod-urgency__icon { font-size: 16px; flex-shrink: 0; }
.twpcod-urgency__text strong { color: #c2410c; }
#twpcod-timer {
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    font-size: 14px;
    color: #dc2626;
}

/* ── PAYMENT SELECTOR ───────────────────────────────────────── */
.twpcod-selector { margin-bottom: 16px; }
.twpcod-selector__header { margin-bottom: 10px; }
.twpcod-selector__title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #9ca3af;
}
.twpcod-selector__options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 10;
}

/* Ensure nothing sits on top of cards */
.twpcod-selector,
.twpcod-selector__options,
.twpcod-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    cursor: pointer;
    background: #fafafa;
    transition: border-color 0.15s ease, background 0.15s ease,
                box-shadow 0.15s ease, transform 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    outline: none;
}
.twpcod-card:active { transform: scale(0.985); }
.twpcod-card.is-active {
    border-color: #111827;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(17,24,39,0.08), 0 4px 16px rgba(0,0,0,0.07);
}
.twpcod-card__radio {
    width: 22px; height: 22px;
    border: 2px solid #d1d5db;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: border-color 0.15s;
    background: #fff;
}
.twpcod-card.is-active .twpcod-card__radio { border-color: #111827; }
.twpcod-card__dot {
    width: 11px; height: 11px;
    border-radius: 50%;
    background: #111827;
    transform: scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.twpcod-card.is-active .twpcod-card__dot { transform: scale(1); }
.twpcod-card__icon { font-size: 22px; flex-shrink: 0; }
.twpcod-card__body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.twpcod-card__top  { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.twpcod-card__name { font-size: 15px; font-weight: 700; color: #111827; }
.twpcod-card__desc { font-size: 12.5px; color: #6b7280; line-height: 1.4; }
.twpcod-card__desc strong { color: #111827; }
.twpcod-card__badge {
    font-size: 10px; font-weight: 700;
    padding: 2px 8px; border-radius: 20px;
    white-space: nowrap; letter-spacing: 0.3px;
}
.twpcod-card__badge--green { background: #dcfce7; color: #15803d; }
.twpcod-card__badge--gold  { background: #fef3c7; color: #92400e; }

/* Loading state */
.twpcod-card.is-loading { pointer-events: none; opacity: 0.55; }
.twpcod-card.is-loading::after {
    content: '';
    position: absolute; top: 50%; right: 14px;
    transform: translateY(-50%);
    width: 15px; height: 15px;
    border: 2px solid #e5e7eb;
    border-top-color: #111827;
    border-radius: 50%;
    animation: twpcod-spin 0.55s linear infinite;
}

/* Feedback */


/* ── CLICK FIX — child elements pass clicks to parent card div ── */
.twpcod-card * {
    pointer-events: none;
}
.twpcod-card {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.twpcod-feedback {
    min-height: 18px; font-size: 12px;
    margin-top: 8px; padding: 0 2px; color: #6b7280;
}
.twpcod-feedback.is-success { color: #15803d; }
.twpcod-feedback.is-error   { color: #dc2626; }

/* ── TRUST BAR ──────────────────────────────────────────────── */
.twpcod-trust-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0 14px;
    padding: 16px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 12px;
}
.twpcod-trust-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #374151;
    font-weight: 600;
}
.twpcod-trust-item small {
    display: block;
    font-weight: 400;
    color: #9ca3af;
    font-size: 11px;
}
.twpcod-trust-icon { font-size: 20px; flex-shrink: 0; }

/* ── WHATSAPP HELP BUTTON ───────────────────────────────────── */
.twpcod-whatsapp {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    color: #374151 !important;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
    margin-top: 10px;
    transition: background 0.15s, border-color 0.15s;
}
.twpcod-whatsapp:hover {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #15803d !important;
}
.twpcod-whatsapp svg { flex-shrink: 0; }

/* ── STICKY MOBILE CHECKOUT ─────────────────────────────────── */
.twpcod-sticky {
    display: none; /* shown via JS on mobile only */
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 9999;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: twpcod-slideup 0.25s ease;
}
.twpcod-sticky.is-visible { display: flex; }
.twpcod-sticky__info { flex: 1; min-width: 0; }
.twpcod-sticky__label {
    font-size: 12px;
    color: #6b7280;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.twpcod-sticky__btn {
    background: #111827;
    color: #fff !important;
    text-decoration: none !important;
    padding: 12px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
.twpcod-sticky__btn:active { transform: scale(0.96); }

/* Spacer so sticky bar doesn't cover content */
.twpcod-cart-page .woocommerce {
    padding-bottom: 80px;
}

/* ── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes twpcod-slidein {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes twpcod-slideup {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}
@keyframes twpcod-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ── MOBILE OPTIMIZATIONS ───────────────────────────────────── */
@media (max-width: 768px) {
    .twpcod-sticky { display: flex; } /* always show on mobile */

    .twpcod-card { padding: 14px 12px; gap: 10px; }
    .twpcod-card__name { font-size: 14px; }
    .twpcod-card__icon { font-size: 20px; }

    .twpcod-banner__inner { padding: 12px 14px; }
    .twpcod-banner__pill  { display: none; }

    .twpcod-trust-bar { grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px; }
    .twpcod-trust-item { font-size: 11.5px; gap: 8px; }
    .twpcod-trust-icon { font-size: 18px; }
}

@media (min-width: 769px) {
    /* On desktop, only show sticky if user scrolled past checkout button */
    .twpcod-sticky { display: none !important; }
    .twpcod-sticky.is-visible-desktop { display: flex !important; }
    .twpcod-cart-page .woocommerce { padding-bottom: 0; }
}

/* ── CART TOTALS FEE STYLING ────────────────────────────────── */

/* Hide the ₹0.00 amount on informational fee lines */
.cart-subtotal + tr,
.woocommerce-cart-form ~ .cart_totals .shop_table tr.fee td.product-total {
    color: #374151;
}

/* Target fee rows containing our emoji labels */
.cart_totals .shop_table tr.fee {
    border-top: 1px solid #f3f4f6;
}

/* Flash Sale row — highlight it */
.cart_totals .shop_table tr.fee th:contains("Flash Sale"),
.cart_totals .shop_table tr.fee td.product-total {
    font-weight: 600;
}

/* Hide ₹0.00 on informational rows (Balance & Pay Now) */
.cart_totals table.shop_table tr.fee th {
    font-size: 13.5px;
    color: #374151;
}

/* Make flash sale label stand out */
.twpcod-cart-page .cart_totals table tr.fee th {
    font-size: 13px;
    line-height: 1.4;
}

/* Order total — make it bold and prominent */
.twpcod-cart-page .cart_totals .order-total th,
.twpcod-cart-page .cart_totals .order-total td {
    font-size: 17px !important;
    font-weight: 800 !important;
    color: #111827 !important;
    padding-top: 14px !important;
    padding-bottom: 14px !important;
}

/* Style the ₹29 total amount specifically */
.twpcod-cart-page .cart_totals .order-total td strong {
    color: #111827;
    font-size: 20px;
}

/* Hide ₹0.00 text on zero-amount fee rows via JS class */
.twpcod-cart-page .cart_totals tr.fee.twpcod-info-row td {
    color: #6b7280;
    font-size: 12.5px;
    font-style: italic;
}
.twpcod-cart-page .cart_totals tr.fee.twpcod-info-row td .amount {
    display: none;
}

/* ── ZERO-AMOUNT INFO FEE ROWS ──────────────────────────────── */
/* Hide ₹0.00 column on info rows — JS adds class, CSS hides */
.cart_totals table.shop_table tr.fee.twpcod-info-row td {
    display: none !important;
}
.cart_totals table.shop_table tr.fee.twpcod-info-row th {
    width: 100% !important;
    padding-left: 10px !important;
    border-left: 3px solid #e5e7eb;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #6b7280 !important;
}

/* Flash Sale row */
.cart_totals table.shop_table tr.fee th {
    font-size: 13.5px;
}

/* ── COD CLARITY NOTICE ─────────────────────────────────────── */
.twpcod-cod-notice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #fffbeb;
    border: 1.5px solid #fcd34d;
    border-radius: 10px;
    padding: 11px 14px;
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
}
.twpcod-cod-notice--prepaid {
    background: #f0fdf4;
    border-color: #86efac;
    color: #14532d;
}
.twpcod-cod-notice__icon { flex-shrink: 0; font-size: 15px; margin-top: 1px; }
.twpcod-cod-notice__text strong { color: #111827; }

/* ── MOBILE CART TOTALS — prevent negative amount wrapping ──── */
@media (max-width: 768px) {
    .cart_totals table.shop_table tr.fee th,
    .cart_totals table.shop_table tr.fee td {
        display: table-cell !important;
        vertical-align: middle;
    }
    .cart_totals table.shop_table tr.fee th {
        width: 65% !important;
        font-size: 12.5px !important;
        padding-right: 8px !important;
    }
    .cart_totals table.shop_table tr.fee td {
        width: 35% !important;
        text-align: right !important;
        font-size: 13px !important;
        white-space: nowrap;
    }
    /* Flash Sale row amount — red on mobile too */
    .cart_totals table.shop_table tr.fee.twpcod-flash-sale-row td {
        color: #dc2626 !important;
        font-weight: 700 !important;
    }
    /* Info rows on mobile — full width label */
    .cart_totals table.shop_table tr.fee.twpcod-info-row th {
        width: 100% !important;
        display: block !important;
    }
}

/* ── RAZORPAY SPINNER BACKDROP FIX ─────────────────────────── */
/* rzp-spinner-backdrop is a full-page fixed overlay injected by
   Razorpay's rzp-spinner.php that blocks ALL clicks on the page.
   We ensure our payment selector cards sit ABOVE it always.     */
#rzp-spinner-backdrop {
    z-index: 0 !important;
    pointer-events: none !important;
}
#rzp-spinner {
    z-index: 1 !important;
}

/* Our cards must always be clickable regardless of Razorpay overlays */
.twpcod-selector {
    position: relative !important;
    z-index: 9999 !important;
    isolation: isolate;
}
.twpcod-card {
    position: relative !important;
    z-index: 9999 !important;
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* ── RADIO INPUT — hidden but native, label handles visual ──── */
.twpcod-radio-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none; /* label handles clicks */
}

/* Label acts as the card — ensure it's always clickable */
label.twpcod-card {
    cursor: pointer !important;
    display: flex !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: rgba(0,0,0,0.05);
    user-select: none;
}

/* All card children pass clicks to parent label */
.twpcod-card *:not(.twpcod-radio-input) {
    pointer-events: none;
}
label.twpcod-card {
    pointer-events: auto !important;
}
