/* Akad Smart Pay — Frontend */
@font-face {
    font-family: 'IranSans';
    src: url('../fonts/IRANSansWeb.woff2') format('woff2'),
         url('../fonts/IRANSansWeb.woff')  format('woff');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'IranSans';
    src: url('../fonts/IRANSansWeb_Medium.woff2') format('woff2'),
         url('../fonts/IRANSansWeb_Medium.woff')  format('woff');
    font-weight: 500 700;
    font-display: swap;
}

:root {
    --akad-font: 'IranSans', 'Vazirmatn', Tahoma, sans-serif;
    /* Primary palette — overridden by PHP inline style from admin settings */
    --akad-blue: #378ADD;
    --akad-blue-dark: #185FA5;
    --akad-blue-bg: #f0f7ff;
    /* Dual-price pill palette — also overridden by PHP from admin settings */
    --akad-cash-color: #2d7a4f;
    --akad-cash-border: #a8d5ba;
    --akad-inst-color: #856404;
    --akad-inst-border: #f0c95a;
}

/* ── Dual Price — داخل .price که WooCommerce رندر میکنه ─────
   NOTE: The rule that hides the original WC price amount is
   injected by PHP via wp_add_inline_style only when
   show_both_prices is enabled, so it is not here.
────────────────────────────────────────────────────────── */

.akad-dual-price {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    direction: rtl;
    font-family: var(--akad-font);
    margin: 0;
    width: 100%;
}

.akad-price-pill {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    border-radius: 14px;
    padding: 12px 16px;
    flex: 1;
    min-width: 130px;
    transition: transform 0.15s;
}
.akad-price-pill:hover { transform: translateY(-1px); }

.akad-cash-pill {
    background: linear-gradient(135deg, #f0faf5 0%, #e6f5ed 100%);
    border: 1.5px solid var(--akad-cash-border);
}
.akad-inst-pill {
    background: linear-gradient(135deg, #fffbf0 0%, #fef6dc 100%);
    border: 1.5px solid var(--akad-inst-border);
}

.akad-pill-label {
    font-size: 11px;
    font-weight: 500;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.akad-cash-pill .akad-pill-label { color: var(--akad-cash-color); }
.akad-inst-pill .akad-pill-label { color: var(--akad-inst-color); }

.akad-pill-label em {
    font-style: normal;
    background: #fde68a;
    color: var(--akad-inst-color);
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 20px;
    font-weight: 600;
}

.akad-pill-amount {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1.2;
    font-family: var(--akad-font);
}
.akad-pill-amount small {
    font-size: 12px;
    font-weight: 400;
    color: #777;
    margin-right: 3px;
}

/* ── Checkout Payment UI ─────────────────────── */
.akad-pay-wrap {
    font-family: var(--akad-font);
    direction: rtl;
    margin-bottom: 24px;
}
.akad-pay-title {
    font-size: 11px;
    font-weight: 500;
    color: #b0b0b0;
    margin: 0 0 10px;
    text-align: right;
    letter-spacing: 0.04em;
}
.akad-pay-grid {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.akad-pay-card {
    background: #fff;
    border: 1.5px solid #eaeaea;
    border-radius: 14px;
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-direction: row-reverse;
}
.akad-pay-card:hover {
    border-color: #b8d4f0;
    background: #fafcff;
    box-shadow: 0 2px 10px rgba(55,138,221,0.08);
}
.akad-pay-card.akad-selected {
    border-color: var(--akad-blue);
    background: var(--akad-blue-bg);
    box-shadow: 0 3px 16px rgba(55,138,221,0.14);
}
.akad-pay-card.akad-selected .akad-pay-name {
    color: var(--akad-blue-dark);
    font-weight: 600;
}

.akad-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #d0d0d0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}
.akad-pay-card.akad-selected .akad-radio { border-color: var(--akad-blue); }
.akad-radio-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--akad-blue);
    transform: scale(0);
    transition: transform 0.18s cubic-bezier(.4, 1.6, .6, 1);
}
.akad-pay-card.akad-selected .akad-radio-dot { transform: scale(1); }

.akad-pay-logo {
    width: 50px;
    height: 34px;
    object-fit: contain;
    flex-shrink: 0;
}
.akad-pay-info { flex: 1; text-align: right; }
.akad-pay-name {
    font-size: 14px;
    font-weight: 500;
    color: #2a2a2a;
    margin: 0;
    line-height: 1.5;
    font-family: var(--akad-font);
}
.akad-pay-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: #fef3c7;
    color: #92400e;
    flex-shrink: 0;
    border: 1px solid #fde68a;
    font-family: var(--akad-font);
}
.akad-pay-extra {
    background: #f7f9fc;
    border-radius: 10px;
    font-size: 13px;
    color: #555;
    text-align: right;
    direction: rtl;
    line-height: 1.8;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 16px;
    margin-top: 0;
    border: 1px solid transparent;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s, margin-top 0.3s, border-color 0.3s;
    font-family: var(--akad-font);
}
.akad-pay-extra.akad-visible {
    max-height: 150px;
    opacity: 1;
    padding: 12px 16px;
    margin-top: 4px;
    border-color: #e2eaf5;
}

/* NOTE: #payment .wc_payment_methods is hidden via PHP inline style
   only when checkout_ui_enabled is on. Not hardcoded here. */

/* ══════════════════════════════════════════════════════════
   ORDER REVIEW  —  «سفارش شما»
   Scoped under .akad-order-table-styled (added by PHP to
   <body> only when customize_order_table is enabled).
   Zero side-effects when the feature is off.

   KEY ARCHITECTURE NOTE:
   The <table> element is set to display:block. This removes the
   table formatting context entirely — column-width constraints
   are gone. tbody/tfoot rows are flex containers. The shipping
   row is a plain block with genuine 100% width.
══════════════════════════════════════════════════════════ */

/* ── Heading ─────────────────────────────────────────────── */
.akad-order-table-styled #order_review_heading {
    font-family: var(--akad-font) !important;
    font-size: 15px !important;
    font-weight: 700 !important;
    color: #1a1a2e !important;
    direction: rtl;
    text-align: right;
    margin: 0 0 18px !important;
    padding: 0 0 12px !important;
    border-bottom: 2px solid #eaf0f8 !important;
    display: flex !important;
    align-items: center;
    gap: 8px;
}
.akad-order-table-styled #order_review_heading::before {
    content: '';
    flex-shrink: 0;
    width: 4px;
    height: 18px;
    background: var(--akad-blue);
    border-radius: 3px;
}

/* ══════════════════════════════════════════════════════════
   TABLE → BLOCK LAYOUT
   Root-cause fix: as long as the <table> element is
   display:table, browsers apply column-width constraints to
   ALL descendants — even ones with display:block.
   Making the table itself display:block removes the table
   formatting context entirely, so every child is a plain
   block/flex box with genuine 100% width.
══════════════════════════════════════════════════════════ */
.akad-order-table-styled .woocommerce-checkout-review-order-table {
    display: block !important;
    width: 100% !important;
    font-family: var(--akad-font);
    direction: rtl;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
}

/* Hide stock WC column headers */
.akad-order-table-styled .woocommerce-checkout-review-order-table thead {
    display: none !important;
}

/* tbody must also be block so its rows stretch to full width */
.akad-order-table-styled .woocommerce-checkout-review-order-table tbody {
    display: block !important;
    width: 100% !important;
}

/* ── Product item rows — flex layout ────────────────────── */
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart_item {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    direction: rtl;
    gap: 12px;
    width: 100% !important;
    box-sizing: border-box;
    border: none !important;
    border-bottom: 1px dashed #efefef !important;
    padding: 10px 0 !important;
    background: transparent !important;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart_item:last-of-type {
    border-bottom: 1px solid #e2eaf4 !important;
}
/* Shared td reset — borders go on the row, not individual cells */
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart_item td {
    display: block !important;
    border: none !important;
    padding: 0 !important;
    font-size: 13px;
    color: #333;
    line-height: 1.55;
    background: transparent !important;
    vertical-align: unset;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart_item td.product-name {
    flex: 1 1 0 !important;
    text-align: right;
    min-width: 0;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart_item td.product-total {
    flex: 0 0 auto !important;
    text-align: left;
    white-space: nowrap;
    font-weight: 700;
    font-size: 13px;
    color: #1a1a2e;
    align-self: center;
}

/* Quantity badge (× 1) */
.akad-order-table-styled .woocommerce-checkout-review-order-table .product-quantity {
    display: inline-block !important;
    background: var(--akad-blue-bg);
    color: var(--akad-blue);
    font-size: 11px !important;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 20px;
    margin-right: 5px;
    direction: ltr;
    white-space: nowrap;
}

/* ── tfoot — block container with flex rows ──────────────── */
.akad-order-table-styled .woocommerce-checkout-review-order-table tfoot {
    display: block !important;
    width: 100% !important;
}
/* Default tfoot row: flex (label right, value left) */
.akad-order-table-styled .woocommerce-checkout-review-order-table tfoot tr {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    width: 100% !important;
    direction: rtl;
    gap: 8px;
    border: none !important;
    border-bottom: 1px solid #f3f3f3 !important;
    padding: 10px 0 !important;
    box-sizing: border-box;
    background: transparent !important;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table tfoot tr th {
    display: block !important;
    flex: 1 1 auto !important;
    text-align: right !important;
    font-weight: 600 !important;
    color: #444 !important;
    font-size: 13px !important;
    font-family: var(--akad-font) !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    white-space: nowrap;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table tfoot tr td {
    display: block !important;
    flex: 0 0 auto !important;
    text-align: left !important;
    font-size: 13px !important;
    font-family: var(--akad-font) !important;
    color: #333;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
}

/* Subtotal — slightly muted */
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart-subtotal th,
.akad-order-table-styled .woocommerce-checkout-review-order-table .cart-subtotal td {
    font-size: 12px !important;
    color: #aaa !important;
}

/* ── Shipping row — stacked block ────────────────────────── */
/* Now that the table is display:block, this tr IS a real block
   element with genuine full width — no column constraints. */
.akad-order-table-styled .woocommerce-checkout-review-order-table .woocommerce-shipping-totals {
    display: block !important;
    width: 100% !important;
    border-bottom: 1px solid #f3f3f3 !important;
    padding: 12px 0 !important;
    box-sizing: border-box;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .woocommerce-shipping-totals th {
    display: block !important;
    width: 100% !important;
    flex: none !important;
    font-size: 12px !important;
    color: #aaa !important;
    font-weight: 600 !important;
    text-align: right !important;
    padding: 0 0 8px !important;
    border: none !important;
    white-space: normal !important;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .woocommerce-shipping-totals td {
    display: block !important;
    width: 100% !important;
    flex: none !important;
    padding: 0 !important;
    border: none !important;
    text-align: right !important;
    box-sizing: border-box;
}

/* Shipping methods list — full reset then restyle */
.akad-order-table-styled #shipping_method {
    all: unset !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    width: 100% !important;
    direction: rtl !important;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}
.akad-order-table-styled #shipping_method li {
    display: block !important;
    position: relative !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    background: none !important;
    width: 100% !important;
    float: none !important;
}
.akad-order-table-styled #shipping_method li::before {
    display: none !important;
}

/* Hide the raw radio input visually but keep it functional for WC */
.akad-order-table-styled #shipping_method .shipping_method {
    position: absolute !important;
    opacity: 0 !important;
    width: 1px !important;
    height: 1px !important;
    pointer-events: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Each shipping option becomes a card */
.akad-order-table-styled #shipping_method label {
    all: unset !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 9px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 14px !important;
    border: 1.5px solid #e4eaf0 !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    font-family: var(--akad-font) !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    color: #555 !important;
    line-height: 1.4 !important;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s !important;
    background: #fff !important;
    direction: rtl !important;
}
/* The label text grows to fill, the price <span> stays right-sized */
.akad-order-table-styled #shipping_method label > *:not(span.woocommerce-Price-amount):not(bdi) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}
/* Custom radio dot via ::before on the label */
.akad-order-table-styled #shipping_method label::before {
    content: '' !important;
    display: block !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    width: 14px !important;
    height: 14px !important;
    border: 2px solid #d0d0d0 !important;
    border-radius: 50% !important;
    background: #fff !important;
    transition: border-color 0.15s, box-shadow 0.15s !important;
    margin: 0 !important;
}
.akad-order-table-styled #shipping_method label:hover {
    border-color: #b0cef0 !important;
    background: #fafcff !important;
}

/* Selected state */
.akad-order-table-styled #shipping_method .shipping_method:checked + label {
    border-color: var(--akad-blue) !important;
    background: var(--akad-blue-bg) !important;
    color: var(--akad-blue-dark) !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(55,138,221,0.12) !important;
}
.akad-order-table-styled #shipping_method .shipping_method:checked + label::before {
    border-color: var(--akad-blue) !important;
    box-shadow: inset 0 0 0 3px var(--akad-blue) !important;
    background: #fff !important;
}

/* Price amount inside shipping label (ارسال با پست: 99,000 تومان) */
.akad-order-table-styled #shipping_method label .woocommerce-Price-amount {
    font-weight: 700;
    color: inherit;
}

/* ── Order total ─────────────────────────────────────────── */
.akad-order-table-styled .woocommerce-checkout-review-order-table .order-total {
    border-bottom: none !important;
    border-top: 2px solid #ddeaf8 !important;
    padding: 14px 0 8px !important;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .order-total th {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #1a1a2e !important;
    white-space: nowrap;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .order-total td {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #1a1a2e !important;
}
.akad-order-table-styled .woocommerce-checkout-review-order-table .order-total td bdi,
.akad-order-table-styled .woocommerce-checkout-review-order-table .order-total td .woocommerce-Price-amount {
    color: var(--akad-blue-dark) !important;
    font-size: 17px !important;
    font-family: var(--akad-font) !important;
}

/* ── Coupon nudge ────────────────────────────────────────── */
.akad-order-table-styled .e-woocommerce-coupon-nudge {
    font-family: var(--akad-font);
    font-size: 12.5px;
    color: #aaa;
    direction: rtl;
    text-align: right;
    margin: 12px 0 0 !important;
}
.akad-order-table-styled .e-woocommerce-coupon-nudge a {
    color: var(--akad-blue);
    text-decoration: none;
    font-weight: 500;
}
.akad-order-table-styled .e-woocommerce-coupon-nudge a:hover { text-decoration: underline; }
