/* ==========================================================================
 * Typography scale - shared with the admin screens
 * ========================================================================== */
:root {
    --cdz-fs-xs: 11px;
    --cdz-fs-sm: 12px;
    --cdz-fs-base: 13px;
    --cdz-fs-md: 14px;
    --cdz-fs-lg: 16px;
    --cdz-fs-xl: 20px;
    --cdz-fw-normal: 400;
    --cdz-fw-medium: 500;
    --cdz-fw-semibold: 600;
    --cdz-fw-bold: 700;
}

/* Hide Default Add-to-Cart (controlled via settings) */
.checkoutdz-hide-add-to-cart .single-product form.cart,
.checkoutdz-hide-add-to-cart .woocommerce-variation-add-to-cart,
.checkoutdz-hide-add-to-cart .woocommerce-product-rating,
.checkoutdz-hide-add-to-cart .product_meta,
.checkoutdz-hide-add-to-cart .woocommerce-tabs,
.checkoutdz-hide-add-to-cart .woocommerce-product-details__short-description,
.checkoutdz-hide-add-to-cart .summary-content-wrapper form.cart {
    display: none !important;
}

/* RTL Support */
.checkoutdz-wrap.checkoutdz-rtl {
    direction: rtl;
    text-align: right;
}

.checkoutdz-rtl .checkoutdz-field input,
.checkoutdz-rtl .checkoutdz-field select,
.checkoutdz-rtl .checkoutdz-field textarea {
    text-align: right;
}

.checkoutdz-rtl .checkoutdz-field select {
    background-position: left 12px center !important;
    padding-left: 40px;
    padding-right: 12px;
}

.checkoutdz-rtl .req {
    margin-left: 6px;
}

/* Compact Form Mode — Hide Labels Visually (Keep Accessible) */
/* Use > to target only the field's own label, not nested labels
   (e.g. the .checkoutdz-delivery-option cards inside the Delivery Type field).
   Per-variation labels (e.g. Color, Size) are always shown inline with their
   choices; only the common "Choose options" title and field labels are hidden. */
.checkoutdz-wrap.checkoutdz-hide-labels .checkoutdz-field > label,
.checkoutdz-wrap.checkoutdz-hide-labels .checkoutdz-variation-title {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
.checkoutdz-wrap.checkoutdz-hide-labels .checkoutdz-field {
    position: relative;
}

/* Wrapper & Card styling */
.checkoutdz-wrap {
    max-width: 540px;
    margin: 2rem auto;
    font-family: 'Tajawal', 'Noto Sans Arabic', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 40px -10px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    border: 1px solid #f3f4f6;
    overflow: hidden;
    color: #1f2937;
}

/* Every control inside the form uses the same typeface. */
.checkoutdz-wrap input,
.checkoutdz-wrap select,
.checkoutdz-wrap textarea,
.checkoutdz-wrap button,
.checkoutdz-wrap label,
.checkoutdz-wrap h1,
.checkoutdz-wrap h2,
.checkoutdz-wrap h3,
.checkoutdz-wrap h4,
.checkoutdz-wrap p,
.checkoutdz-wrap span,
.checkoutdz-wrap div,
.checkoutdz-wrap a,
.checkoutdz-wrap small,
.checkoutdz-wrap strong,
.checkoutdz-wrap ul,
.checkoutdz-wrap li {
    font-family: inherit;
}

/* Keep the WordPress icon font for any dashicon used in the form. */
.checkoutdz-wrap .dashicons,
.checkoutdz-wrap .dashicons::before,
.checkoutdz-wrap .dashicons::after {
    font-family: dashicons !important;
    speak: never;
}

/* One type scale for the checkout form. */
.checkoutdz-wrap {
    font-size: var(--cdz-fs-base);
    line-height: 1.6;
}
.checkoutdz-wrap h1,
.checkoutdz-wrap h2,
.checkoutdz-wrap h3 {
    font-size: var(--cdz-fs-lg);
    line-height: 1.3;
}
.checkoutdz-wrap label,
.checkoutdz-wrap .cdz-label {
    font-size: var(--cdz-fs-sm);
}
.checkoutdz-wrap small,
.checkoutdz-wrap .cdz-hint {
    font-size: var(--cdz-fs-xs);
}

/* Header */
.checkoutdz-header {
    background: #f8fafc;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    text-align: center;
}

.checkoutdz-title {
    margin: 0 0 4px 0 !important;
    font-size: var(--cdz-fs-xl) !important;
    font-weight: 700 !important;
    color: #111827;
}

.checkoutdz-subtitle {
    margin: 0 !important;
    font-size: var(--cdz-fs-base);
    color: #6b7280;
}

/* Form Body */
.checkoutdz-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Rows for 2-column layout on desktop */
.checkoutdz-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 480px) {
    .checkoutdz-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* Full-width field inside a two-column row (e.g. address) */
.checkoutdz-field--full {
    grid-column: 1 / -1;
}

/* Labels */
.checkoutdz-field label {
    display: block;
    margin-bottom: 8px;
    font-size: var(--cdz-fs-base);
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checkoutdz-field label .req {
    color: #ef4444;
}

/* Delivery type cards — identical look to variation cards */
.checkoutdz-delivery-options {
    display: flex;
    flex-direction: column;
    /* gap: 6px; */
}
.checkoutdz-delivery-option {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--cdz-fs-base);
    font-weight: 500;
    color: #1f2937;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    position: relative;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
}
.checkoutdz-delivery-option:hover {
    border-color: #cbd5e1;
}
.checkoutdz-delivery-option input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.checkoutdz-delivery-option:has(input[type="radio"]:checked) {
    background: var(--checkoutdz-primary, #1e3a8a);
    color: #fff;
    border-color: var(--checkoutdz-primary, #1e3a8a);
    font-weight: 600;
}
.checkoutdz-delivery-option:has(input[type="radio"]:checked)::after {
    content: "✓";
    font-size: var(--cdz-fs-sm);
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.9;
}
.checkoutdz-delivery-option:has(input[type="radio"]:checked) .checkoutdz-delivery-option-name,
.checkoutdz-delivery-option:has(input[type="radio"]:checked) .checkoutdz-delivery-option-delivery {
    color: #fff;
}
.checkoutdz-delivery-option-label {
    display: flex;
    flex: 1;
    min-width: 0;
}
.checkoutdz-delivery-option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.checkoutdz-delivery-option-name {
    font-weight: inherit;
    color: inherit;
    text-transform: none;
    letter-spacing: 0;
    font-size: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.checkoutdz-delivery-option-company {
    flex-shrink: 0;
    font-size: var(--cdz-fs-xs);
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
    margin-left: 4px;
    display: none;
}
.checkoutdz-delivery-option:has(input[type="radio"]:checked) .checkoutdz-delivery-option-company {
    color: rgba(255,255,255,0.65);
}
.checkoutdz-delivery-option-delivery {
    flex-shrink: 0;
    font-size: var(--cdz-fs-sm);
    color: #6b7280;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.checkoutdz-delivery-option:has(input[type="radio"]:checked) .checkoutdz-delivery-option-delivery {
    color: rgba(255,255,255,0.8);
}
.checkoutdz-delivery-option-delivery.is-unavailable {
    color: #9ca3af;
    font-weight: 400;
    font-style: italic;
}
.checkoutdz-delivery-option:has(input[type="radio"]:disabled) {
    opacity: 0.45;
    cursor: not-allowed;
}
.checkoutdz-delivery-option:has(input[type="radio"]:disabled):hover {
    border-color: #e5e7eb;
}

.checkoutdz-delivery-select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: var(--cdz-fs-base);
    font-weight: 500;
    background: #fff;
    cursor: pointer;
    line-height: 1.4;
    color: #1f2937;
}
.checkoutdz-delivery-select:hover {
    border-color: #cbd5e1;
}
.checkoutdz-delivery-select:focus {
    outline: none;
    border-color: var(--checkoutdz-primary, #1e3a8a);
    box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.15);
}

.checkoutdz-order-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 12px 6px;
    background: transparent;
    border-radius: 0;
    border-top: 1px solid #e5e7eb;
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.checkoutdz-order-summary-label {
    flex-shrink: 0;
    font-weight: 600;
    font-size: var(--cdz-fs-base);
    color: #111827;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.checkoutdz-order-summary-formula {
    flex: 1;
    min-width: 0;
    font-size: var(--cdz-fs-base);
    color: #6b7280;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.checkoutdz-order-summary-divider {
    flex-shrink: 0;
    font-size: var(--cdz-fs-base);
    color: #9ca3af;
    white-space: nowrap;
}

.checkoutdz-order-summary-value {
    flex-shrink: 0;
    font-weight: 800;
    font-size: var(--cdz-fs-xl);
    color: var(--checkoutdz-primary, #1e3a8a);
    white-space: nowrap;
}

/* Free Shipping Badge (legacy large style — still supported) */
.checkoutdz-free-shipping-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: var(--cdz-fs-md);
    font-weight: 600;
    color: #fff;
    background-color: var(--checkoutdz-primary, #1e3a8a);
}

/* Product Badges (Free Shipping + Discount) — shown in form and on WC product page */
.checkoutdz-product-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.checkoutdz-product-badges--form {
    margin-bottom: 8px;
}
.checkoutdz-product-badges--wc {
    margin: 6px 0 10px;
}
.checkoutdz-discount-badge,
.checkoutdz-free-shipping-badge--inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: var(--cdz-fs-sm);
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    background-color: var(--checkoutdz-primary, #1e3a8a);
    letter-spacing: 0;
    text-transform: none;
}
.checkoutdz-discount-badge {
    background-color: #b91c1c;
}
.checkoutdz-discount-badge svg,
.checkoutdz-free-shipping-badge--inline svg {
    flex-shrink: 0;
}

/* Inputs, Selects, Textareas - CONSISTENT DESIGN */
.checkoutdz-field input[type="text"],
.checkoutdz-field input[type="tel"],
.checkoutdz-field input[type="number"],
.checkoutdz-field select,
.checkoutdz-field textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--cdz-fs-md);
    color: #111827;
    background-color: #f9fafb !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 10px;
    transition: all 0.2s ease;
    box-sizing: border-box;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.01) !important;
    outline: none !important;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.checkoutdz-field select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 12px center !important;
    background-repeat: no-repeat !important;
    background-size: 20px 20px !important;
    padding-right: 40px;
    cursor: pointer;
}

/* Focus states */
.checkoutdz-field input:focus,
.checkoutdz-field select:focus,
.checkoutdz-field textarea:focus {
    border-color: #3b82f6 !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
}

/* NEW: Custom Quantity Control */
.checkoutdz-qty-control {
    display: flex;
    align-items: center;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    height: 42px;
    padding: 0 !important;
}

.checkoutdz-qty-control:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.checkoutdz-qty-btn {
    background: var(--checkoutdz-primary, #1e3a8a);
    border: 1px solid var(--checkoutdz-primary, #1e3a8a);
    color: #ffffff;
    font-size: var(--cdz-fs-lg);
    font-weight: 500;
    width: 44px;
    height: 100%;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.checkoutdz-qty-btn:hover {
    background: #1e40af;
    color: #ffffff;
}

.checkoutdz-qty-input {
    flex: 1;
    height: 100% !important;
    min-height: 100% !important;
    border: none !important;
    background: #ffffff !important;
    text-align: center !important;
    font-size: var(--cdz-fs-lg) !important;
    font-weight: 600;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: #111827 !important;
}

/* Hide default up/down arrows on number inputs */
.checkoutdz-qty-input::-webkit-inner-spin-button,
.checkoutdz-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.checkoutdz-qty-input[type="number"] {
    -moz-appearance: textfield;
}

/* Submit row: quantity (small) + submit button (large) on one line */
.checkoutdz-row--submit {
    display: grid;
    grid-template-columns: minmax(130px, 35%) 1fr;
    gap: 10px;
    align-items: end;
}

.checkoutdz-row--submit .checkoutdz-qty-wrapper {
    margin: 0;
    min-width: 0;
}

.checkoutdz-row--submit .checkoutdz-submit-btn {
    height: 42px;
    width: 100%;
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* WhatsApp on its own dedicated row, full width, solid WhatsApp green */
.checkoutdz-wa-row {
    margin-top: 4px;
}

/* WhatsApp button placed beside the submit button (3-column submit row) */
.checkoutdz-row--submit.has-wa-beside {
    grid-template-columns: minmax(110px, auto) 1fr auto;
}

.checkoutdz-row--submit .checkoutdz-wa-beside {
    margin: 0;
    width: auto;
}

.checkoutdz-row--submit .checkoutdz-wa-beside .checkoutdz-wa-btn {
    width: auto;
    height: 42px;
    padding: 0 16px;
    white-space: nowrap;
}

.checkoutdz-wa-row .checkoutdz-wa-btn {
    width: 100%;
    padding: 10px 20px;
    font-size: var(--cdz-fs-base);
    font-weight: 600;
    color: #ffffff;
    background-color: #15803d;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s ease;
    box-sizing: border-box;
}

.checkoutdz-wa-row .checkoutdz-wa-btn:hover {
    background-color: #166534;
    color: #ffffff;
}

.checkoutdz-wa-row .checkoutdz-wa-btn:active {
    background-color: #14532d;
}

/* Main Call to Action Button */
.checkoutdz-actions {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkoutdz-submit-btn {
    width: 100%;
    padding: 12px 20px;
    font-size: var(--cdz-fs-md);
    font-weight: 600;
    color: #ffffff;
    background: var(--checkoutdz-primary, #1e3a8a);
    border: 1px solid var(--checkoutdz-primary, #1e3a8a);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    box-shadow: none;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.checkoutdz-submit-btn:hover {
    transform: none;
    background: #1e40af;
    box-shadow: none;
}

.checkoutdz-submit-btn:active {
    transform: translateY(0);
}

/* WhatsApp Alternative Button */
.checkoutdz-wa-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: var(--cdz-fs-lg);
    font-weight: 600;
    color: #166534;
    background-color: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    box-sizing: border-box;
}

.checkoutdz-wa-btn:hover {
    background-color: #bbf7d0;
    color: #14532d;
}

/* When WhatsApp button is positioned "beside" */
.checkoutdz-actions:has(.checkoutdz-wa-beside) {
    flex-direction: row;
    gap: 12px;
}

.checkoutdz-actions:has(.checkoutdz-wa-beside) .checkoutdz-submit-btn,
.checkoutdz-actions:has(.checkoutdz-wa-beside) .checkoutdz-wa-beside {
    flex: 1;
    width: auto;
}

/* Sticky Mobile Button */
.checkoutdz-sticky-mobile {
    display: none;
}

@media (max-width: 768px) {
    .checkoutdz-sticky-mobile {
        display: block;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #ffffff;
        padding: 12px 16px;
        z-index: 9999;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        border-top: 1px solid #e5e7eb;
    }

    body {
        padding-bottom: 80px;
    }

    .checkoutdz-sticky-btn {
        width: 100%;
    }

    /* Safe area for notched phones */
    .checkoutdz-sticky-mobile {
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-bottom: constant(safe-area-inset-bottom, 0px);
    }
}

/* Touch targets — 44px minimum on mobile */
@media (max-width: 768px) {
    .checkoutdz-variation-card,
    .checkoutdz-delivery-option {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 10px 14px;
    }
    .checkoutdz-qty-btn {
        min-width: 44px;
        min-height: 44px;
    }
    .checkoutdz-row--submit .checkoutdz-submit-btn {
        min-height: 44px;
        height: auto;
        padding: 12px 16px;
    }
}

/* Narrow screens: stack submit row + WhatsApp beside */
@media (max-width: 380px) {
    .checkoutdz-row--submit,
    .checkoutdz-row--submit.has-wa-beside {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .checkoutdz-row--submit .checkoutdz-wa-beside .checkoutdz-wa-btn {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .checkoutdz-actions:has(.checkoutdz-wa-beside) {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .checkoutdz-form {
        gap: 12px;
        padding: 16px 12px;
    }
    .checkoutdz-row {
        gap: 14px;
    }
}

/* Response / Notifications */
.checkoutdz-response {
    padding: 0 24px 24px;
}

.checkoutdz-response .notice {
    margin: 0;
    padding: 16px;
    border-radius: 12px;
    font-size: var(--cdz-fs-md);
    font-weight: 500;
}

.checkoutdz-response .notice-success {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #16a34a;
}

.checkoutdz-response .notice-error {
    background-color: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
}

/* Variation cards UI */
.checkoutdz-variation-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}
.checkoutdz-variation-card {
    background: #fff;
    border: 1.5px solid #e5e7eb;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--cdz-fs-base);
    font-weight: 500;
    color: #1f2937;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.checkoutdz-variation-card:hover { border-color: #cbd5e1; }
.checkoutdz-variation-card.active {
    background: var(--checkoutdz-primary, #1e3a8a);
    color: #fff;
    border-color: var(--checkoutdz-primary, #1e3a8a);
    font-weight: 600;
}
.checkoutdz-variation-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Hide native selects visually while keeping them in DOM for logic */
.checkoutdz-variation-select { display: none !important; }
