/**
 * Al Ehda — Checkout CSS
 * File: /assets/css/checkout.css
 *
 * Sections:
 *  1. Progress Steps
 *  2. Layout (2-col)
 *  3. Section Cards
 *  4. Form Fields (icon prefix)
 *  5. WooCommerce Payment Wrapper override
 *  6. Order Summary Card
 *  7. Coupon Toggle
 *  8. Totals
 *  9. Trust Badges
 * 10. Responsive
 *
 * Design tokens come from style.css — never raw hex here.
 */

/* ════════════════════════════════════════════════════════════
   1. PROGRESS STEPS
   ════════════════════════════════════════════════════════════ */
.ae-checkout-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 2rem 1rem 2.5rem;
    background: var(--ae-bg);
    border-bottom: 1px solid var(--ae-border);
    margin-bottom: 0;
}

.ae-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    position: relative;
    flex: 1;
    max-width: 120px;
}

/* Connector line between steps */
.ae-progress-step + .ae-progress-step::before {
    content: '';
    position: absolute;
    top: 16px;
    right: calc(50% + 20px);
    left: -50%;
    height: 2px;
    background: var(--ae-border);
    z-index: 0;
}

.ae-progress-step.is-done + .ae-progress-step::before,
.ae-progress-step.is-active + .ae-progress-step::before {
    background: var(--ae-primary);
}

.ae-progress-step__icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--ae-border);
    background: var(--ae-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--ae-text-muted);
    position: relative;
    z-index: 1;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.ae-progress-step.is-done .ae-progress-step__icon {
    background: var(--ae-primary);
    border-color: var(--ae-primary);
    color: #fff;
}

.ae-progress-step.is-active .ae-progress-step__icon {
    border-color: var(--ae-primary);
    color: var(--ae-primary);
    box-shadow: 0 0 0 4px rgba(var(--ae-primary-rgb, 79, 70, 229), 0.12);
}

.ae-progress-step__label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--ae-text-muted);
    white-space: nowrap;
}

.ae-progress-step.is-active .ae-progress-step__label {
    color: var(--ae-primary);
    font-weight: 700;
}

.ae-progress-step.is-done .ae-progress-step__label {
    color: var(--ae-primary);
}

/* ════════════════════════════════════════════════════════════
   2. LAYOUT — 2-col on desktop
   ════════════════════════════════════════════════════════════ */
.ae-checkout-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

.ae-checkout-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 2rem;
    align-items: start;
}

/* Left column */
.ae-checkout-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Right column — sticky */
.ae-checkout-sidebar {
    position: sticky;
    top: calc(var(--ae-header-h, 72px) + 1.5rem);
}

/* ════════════════════════════════════════════════════════════
   3. SECTION CARDS
   ════════════════════════════════════════════════════════════ */
.ae-checkout-section {
    background: var(--ae-surface);
    border: 1px solid var(--ae-border);
    border-radius: var(--ae-radius-lg, 12px);
    padding: 1.75rem;
}

.ae-checkout-section__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ae-text);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--ae-border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ae-checkout-section__title .ae-step-badge {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ae-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   4. FORM FIELDS WITH ICON PREFIX
   ════════════════════════════════════════════════════════════ */

/* Override WC's default field wrapper spacing */
.ae-checkout-section .form-row {
    margin-bottom: 1rem;
}

.ae-checkout-section .form-row label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ae-text);
    margin-bottom: 0.35rem;
}

/* Input wrapper for icon prefix */
.ae-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.ae-field-wrap .ae-field-icon {
    position: absolute;
    left: 0.9rem;
    font-style: normal;
    color: var(--ae-text-muted);
    font-size: 1rem;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

.ae-field-wrap .ae-field-prefix {
    position: absolute;
    left: 2.4rem;
    font-size: 0.85rem;
    color: var(--ae-text-muted);
    font-weight: 600;
    pointer-events: none;
    z-index: 1;
}

/* Base input style */
.ae-checkout-section input[type="text"],
.ae-checkout-section input[type="email"],
.ae-checkout-section input[type="tel"],
.ae-checkout-section input[type="password"],
.ae-checkout-section select,
.ae-checkout-section textarea,
.woocommerce-checkout .ae-checkout-section .input-text {
    width: 100%;
    height: 48px;
    padding: 0 1rem 0 2.8rem;
    border: 1.5px solid var(--ae-border);
    border-radius: var(--ae-radius, 8px);
    background: var(--ae-bg);
    color: var(--ae-text);
    font-family: var(--ae-font, inherit);
    font-size: 0.92rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* When field has a prefix (+880) */
.ae-checkout-section input[type="tel"] {
    padding-left: 5.2rem; /* icon (2.4rem) + prefix width */
}

.ae-checkout-section input:focus,
.woocommerce-checkout .ae-checkout-section .input-text:focus {
    border-color: var(--ae-primary);
    box-shadow: 0 0 0 3px rgba(var(--ae-primary-rgb, 79, 70, 229), 0.12);
}

/* Valid state */
.ae-checkout-section input.ae-valid {
    border-color: var(--ae-success, #16a34a);
}

/* Error state */
.ae-checkout-section input.ae-error,
.woocommerce-checkout .ae-checkout-section .input-text.ae-error {
    border-color: var(--ae-error, #dc2626);
}

/* WC inline error message */
.ae-checkout-section .woocommerce-invalid-required-field .input-text {
    border-color: var(--ae-error, #dc2626);
}

/* Field validation feedback */
.ae-field-feedback {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    min-height: 1.1rem;
}

.ae-field-feedback.ae-feedback-ok  { color: var(--ae-success, #16a34a); }
.ae-field-feedback.ae-feedback-err { color: var(--ae-error, #dc2626); }

/* Checkbox row */
.ae-checkout-section .ae-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.ae-checkout-section .ae-checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin-top: 3px;
    border: 1.5px solid var(--ae-border);
    border-radius: 4px;
    cursor: pointer;
    accent-color: var(--ae-primary);
}

.ae-checkout-section .ae-checkbox-row label {
    font-size: 0.82rem;
    color: var(--ae-text-muted);
    cursor: pointer;
    margin: 0;
}

/* Password toggle sub-field */
.ae-password-sub {
    display: none;
    margin-top: 1rem;
}

.ae-password-sub.is-visible {
    display: block;
}

/* ════════════════════════════════════════════════════════════
   5. WOOCOMMERCE PAYMENT WRAPPER OVERRIDE
      We style the container only — NEVER the gateway internals.
      bKash plugin renders its own UI inside #payment.
   ════════════════════════════════════════════════════════════ */
#payment {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

/* Payment method list */
#payment ul.wc_payment_methods {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#payment ul.wc_payment_methods li.wc_payment_method {
    border: 1.5px solid var(--ae-border);
    border-radius: var(--ae-radius, 8px);
    overflow: hidden;
    transition: border-color 0.2s;
}

#payment ul.wc_payment_methods li.wc_payment_method:has(input:checked) {
    border-color: var(--ae-primary);
    background: rgba(var(--ae-primary-rgb, 79, 70, 229), 0.04);
}

#payment ul.wc_payment_methods li.wc_payment_method label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ae-text);
}

#payment ul.wc_payment_methods li.wc_payment_method input[type="radio"] {
    accent-color: var(--ae-primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Gateway box (bKash form lives here) */
.payment_box {
    padding: 1rem;
    background: var(--ae-bg);
    border-top: 1px solid var(--ae-border);
    font-size: 0.88rem;
    color: var(--ae-text-muted);
}

/* Place order button — WC default */
#place_order,
.woocommerce-checkout .ae-place-order button[type="submit"] {
    width: 100%;
    padding: 0.9rem 1.5rem;
    background: var(--ae-primary);
    color: #fff;
    border: none;
    border-radius: var(--ae-radius, 8px);
    font-family: var(--ae-font, inherit);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    margin-top: 1rem;
}

#place_order:hover {
    background: var(--ae-primary-dark, var(--ae-primary));
    transform: translateY(-1px);
}

#place_order:disabled,
#place_order.loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* WC notices inside checkout */
.woocommerce-error,
.woocommerce-message,
.woocommerce-info {
    border-radius: var(--ae-radius, 8px);
    font-size: 0.88rem;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
    list-style: none;
}

.woocommerce-error {
    background: #fef2f2;
    border-left: 4px solid var(--ae-error, #dc2626);
    color: #991b1b;
}

.woocommerce-message {
    background: #f0fdf4;
    border-left: 4px solid var(--ae-success, #16a34a);
    color: #166534;
}

/* ════════════════════════════════════════════════════════════
   6. ORDER SUMMARY CARD
   ════════════════════════════════════════════════════════════ */
.ae-order-summary {
    background: var(--ae-surface);
    border: 1px solid var(--ae-border);
    border-radius: var(--ae-radius-lg, 12px);
    overflow: hidden;
}

.ae-order-summary__head {
    padding: 1.2rem 1.5rem;
    background: var(--ae-bg-alt, var(--ae-surface));
    border-bottom: 1px solid var(--ae-border);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ae-text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ae-order-summary__count {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ae-text-muted);
}

/* Product list */
.ae-summary-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ae-summary-item {
    display: grid;
    grid-template-columns: 52px 1fr auto;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    align-items: center;
    border-bottom: 1px solid var(--ae-border);
}

.ae-summary-item:last-child {
    border-bottom: none;
}

/* Product thumbnail with qty badge */
.ae-summary-item__thumb {
    position: relative;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--ae-bg);
    border: 1px solid var(--ae-border);
}

.ae-summary-item__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ae-summary-item__qty {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--ae-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--ae-surface);
}

.ae-summary-item__name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ae-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ae-summary-item__price {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ae-text);
    white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════
   7. COUPON TOGGLE
   ════════════════════════════════════════════════════════════ */
.ae-coupon-toggle-wrap {
    padding: 0.9rem 1.5rem;
    border-bottom: 1px solid var(--ae-border);
}

.ae-coupon-toggle-btn {
    background: none;
    border: none;
    color: var(--ae-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-family: var(--ae-font, inherit);
}

.ae-coupon-toggle-btn:hover {
    text-decoration: underline;
}

.ae-coupon-toggle-btn .ae-coupon-icon {
    font-size: 1rem;
}

.ae-coupon-form {
    display: none;
    margin-top: 0.75rem;
    flex-direction: row;
    gap: 0.5rem;
}

.ae-coupon-form.is-open {
    display: flex;
}

.ae-coupon-form input[type="text"] {
    flex: 1;
    height: 40px;
    padding: 0 0.9rem;
    border: 1.5px solid var(--ae-border);
    border-radius: var(--ae-radius, 8px);
    background: var(--ae-bg);
    color: var(--ae-text);
    font-size: 0.88rem;
    font-family: var(--ae-font, inherit);
    outline: none;
    transition: border-color 0.2s;
}

.ae-coupon-form input[type="text"]:focus {
    border-color: var(--ae-primary);
}

.ae-coupon-form button {
    height: 40px;
    padding: 0 1rem;
    background: var(--ae-primary);
    color: #fff;
    border: none;
    border-radius: var(--ae-radius, 8px);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--ae-font, inherit);
    white-space: nowrap;
    transition: background 0.2s;
}

.ae-coupon-form button:hover {
    background: var(--ae-primary-dark, var(--ae-primary));
}

/* ════════════════════════════════════════════════════════════
   8. TOTALS
   ════════════════════════════════════════════════════════════ */
.ae-order-totals {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--ae-border);
}

.ae-totals-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--ae-text-muted);
    padding: 0.3rem 0;
}

.ae-totals-row.ae-totals-discount {
    color: var(--ae-success, #16a34a);
}

.ae-totals-row.ae-totals-grand {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ae-text);
    border-top: 2px solid var(--ae-border);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
}

.ae-totals-row__label {
    color: inherit;
}

.ae-totals-row__value {
    font-weight: 600;
    color: inherit;
}

.ae-totals-row.ae-totals-grand .ae-totals-row__value {
    color: var(--ae-primary);
    font-size: 1.2rem;
}

/* ════════════════════════════════════════════════════════════
   9. TRUST BADGES (sidebar bottom)
   ════════════════════════════════════════════════════════════ */
.ae-checkout-trust {
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ae-checkout-trust__badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--ae-text-muted);
}

.ae-checkout-trust__badge .ae-badge-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

/* ════════════════════════════════════════════════════════════
   10. RESPONSIVE
   ════════════════════════════════════════════════════════════ */

/* Tablet: single column */
@media (max-width: 768px) {
    .ae-checkout-grid {
        grid-template-columns: 1fr;
    }

    .ae-checkout-sidebar {
        position: static;
        order: -1; /* Show summary first on mobile */
    }

    .ae-checkout-section {
        padding: 1.25rem;
    }

    .ae-checkout-progress {
        padding: 1.25rem 0.75rem 1.5rem;
    }

    .ae-progress-step__label {
        font-size: 0.65rem;
    }

    .ae-checkout-wrap {
        padding: 1.25rem 1rem 3rem;
    }
}

/* Mobile: compact */
@media (max-width: 480px) {
    .ae-checkout-section {
        padding: 1rem;
    }

    .ae-summary-item {
        padding: 0.75rem 1rem;
    }

    .ae-order-totals,
    .ae-coupon-toggle-wrap,
    .ae-checkout-trust {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .ae-progress-step + .ae-progress-step::before {
        left: -40%;
    }
}
