/**
 * WP Smart Delivery Slots - Checkout Fields Styles
 * Matches WooCommerce theme styles
 */

/* Cutoff notice styling - ensure consistent appearance across all themes */
.wp-smart-delivery-cutoff-notice {
    max-width: 100% !important;
    box-sizing: border-box !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    overflow: visible !important;
    font-size: 0.9em !important;
    line-height: 1.6 !important;
    padding: 12px 15px 12px 15px !important;
    margin-top: 20px !important;
    margin-bottom: 20px !important;
    display: block !important;
    clear: both !important;
    position: relative !important;
    text-align: left !important;
}

/* Ensure text and icon display properly - no icon space needed */
.wp-smart-delivery-cutoff-notice strong {
    display: inline !important;
    margin-right: 5px !important;
    font-weight: 600 !important;
}

/* Completely remove any ::before pseudo-elements (icons) */
.wp-smart-delivery-cutoff-notice::before,
.woocommerce-info.wp-smart-delivery-cutoff-notice::before,
.woocommerce-checkout .wp-smart-delivery-cutoff-notice::before {
    display: none !important;
    content: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure text is not cut off */
.wp-smart-delivery-cutoff-notice * {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .wp-smart-delivery-cutoff-notice {
        font-size: 0.85em !important;
        padding: 10px 12px !important;
        margin-top: 15px !important;
        margin-bottom: 15px !important;
        line-height: 1.5 !important;
    }
}

.wp-smart-delivery-fulfillment-section {
    margin-bottom: 25px;
    margin-top: 20px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    clear: both;
    width: 100%;
    box-sizing: border-box;
}

.wp-smart-delivery-fulfillment-heading {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    line-height: 1.5;
    clear: both;
    display: block;
    width: 100%;
}

.wp-smart-delivery-fulfillment-type-field,
.wp-smart-delivery-date-field,
.wp-smart-delivery-time-slot-field {
    margin-bottom: 15px;
}

/* Radio field styling - horizontal layout in one row */
.wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    width: 100%;
    gap: 0;
}

/* Each radio input */
.wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > input[type="radio"] {
    margin-right: 0.75em;
    margin-top: 0.15em;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--wc-primary, #0073aa);
    vertical-align: top;
}

/* Each radio label */
.wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio {
    display: inline-flex;
    align-items: flex-start;
    cursor: pointer;
    font-weight: normal;
    margin: 0 2.5em 0 0;
    padding: 0;
    line-height: 1.5;
    flex: 0 1 auto;
    min-width: 0;
    color: #333;
    transition: color 0.2s ease;
    vertical-align: top;
}

.wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio:last-of-type {
    margin-right: 0;
}

.wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio:hover {
    color: var(--wc-primary, #0073aa);
}

/* Selected radio button styling */
.wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > input[type="radio"]:checked + label.radio {
    color: var(--wc-primary, #0073aa);
    font-weight: 500;
}

/* Match WooCommerce form field styles */
.wp-smart-delivery-date-field input[type="text"],
.wp-smart-delivery-time-slot-field select {
    font-family: inherit;
    font-weight: normal;
    letter-spacing: normal;
    padding: 0.5em;
    display: block;
    background-color: var(--wc-form-color-background, #fff);
    border: var(--wc-form-border-width, 1px) solid var(--wc-form-border-color, #ddd);
    border-radius: var(--wc-form-border-radius, 4px);
    color: var(--wc-form-color-text, #000);
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    line-height: normal;
    height: auto;
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wp-smart-delivery-date-field input[type="text"]:focus,
.wp-smart-delivery-time-slot-field select:focus {
    outline: none;
    border-color: currentColor;
    box-shadow: 0 0 0 1px currentColor;
}

/* Select field styling to match WooCommerce */
.wp-smart-delivery-time-slot-field select {
    cursor: pointer;
    appearance: none;
    padding-right: 3em;
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItY2hldnJvbi1kb3duIj48cG9seWxpbmUgcG9pbnRzPSI2IDkgMTIgMTUgMTggOSI+PC9wb2x5bGluZT48L3N2Zz4=);
    background-repeat: no-repeat;
    background-size: 16px;
    background-position: calc(100% - 0.5em) 50%;
}

/* Loading state styles */
.wp-smart-delivery-time-slot-field select:disabled {
    background-color: var(--wc-form-color-background, #f5f5f5);
    cursor: not-allowed;
    opacity: 0.6;
    background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjOTk5IiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCI+PHBvbHlsaW5lIHBvaW50cz0iNiA5IDEyIDE1IDE4IDkiPjwvcG9seWxpbmU+PC9zdmc+);
}

/* Past time slots styling */
.wp-smart-delivery-time-slot-field select option.past {
    color: #999;
    font-style: italic;
    opacity: 0.7;
}

.wp-smart-delivery-spinner {
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
}

.wp-smart-delivery-spinner .spinner {
    float: none;
    margin: 0;
    visibility: visible;
    width: 20px;
    height: 20px;
    border-width: 2px;
}

/* Loading state indicator */
.wp-smart-delivery-time-slot-field select[aria-busy="true"] {
    position: relative;
    padding-right: 3.5em;
}

.wp-smart-delivery-time-slot-field select[aria-busy="true"]::after {
    content: "";
    position: absolute;
    right: 0.75em;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* Error state styles - Match WooCommerce error styling */
.wp-smart-delivery-date-field.woocommerce-invalid label,
.wp-smart-delivery-time-slot-field.woocommerce-invalid label {
    color: var(--wc-red, #e74c3c);
}

.wp-smart-delivery-date-field input.woocommerce-invalid,
.wp-smart-delivery-time-slot-field select.woocommerce-invalid {
    border-color: var(--wc-red, #e74c3c);
    border-width: 2px;
    box-shadow: 0 0 0 1px var(--wc-red, #e74c3c);
}

.wp-smart-delivery-error {
    color: var(--wc-red, #e74c3c);
    font-size: 0.875em;
    display: block;
    margin-top: 5px;
    font-weight: normal;
    line-height: 1.5;
}

.wp-smart-delivery-error[role="alert"] {
    font-weight: 600;
    padding-left: 1.2em;
    position: relative;
}

.wp-smart-delivery-error[role="alert"]::before {
    content: "⚠";
    position: absolute;
    left: 0;
    font-size: 1em;
}

#place_order.disabled,
#place_order:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Accessibility: Screen reader only text */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
    word-wrap: normal !important;
}

/* Accessibility: Focus styles for keyboard navigation */
.wp-smart-delivery-date-field input[type="text"]:focus,
.wp-smart-delivery-time-slot-field select:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.wp-smart-delivery-date-field input[type="text"]:focus-visible,
.wp-smart-delivery-time-slot-field select:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Accessibility: Error messages with role="alert" */
.wp-smart-delivery-error[role="alert"] {
    font-weight: 600;
}

/* Datepicker styling - Mobile-friendly and matches WooCommerce */
/* High specificity selectors to override jQuery UI defaults */
html body #ui-datepicker-div,
html body .ui-datepicker {
    z-index: 99999 !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
    font-family: inherit !important;
    font-size: 14px !important;
    max-width: 100% !important;
    width: auto !important;
    padding: 0 !important;
}

/* Header styling */
html body #ui-datepicker-div .ui-datepicker-header,
html body .ui-datepicker .ui-datepicker-header {
    background: #0073aa !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px 4px 0 0 !important;
    padding: 10px 8px !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    position: relative !important;
}

/* Title container - inline month/year display */
html body #ui-datepicker-div .ui-datepicker-title,
html body .ui-datepicker .ui-datepicker-title {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    flex: 1 !important;
    margin: 0 40px !important;
    color: #fff !important;
    font-weight: 600 !important;
    font-size: 14px !important;
}

/* Month and Year text (span elements) */
html body #ui-datepicker-div .ui-datepicker-title .ui-datepicker-month,
html body #ui-datepicker-div .ui-datepicker-title .ui-datepicker-year,
html body .ui-datepicker .ui-datepicker-title .ui-datepicker-month,
html body .ui-datepicker .ui-datepicker-title .ui-datepicker-year {
    display: inline-block !important;
    color: #fff !important;
    font-weight: 600 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
}

/* Month and Year dropdowns (select elements) */
html body #ui-datepicker-div .ui-datepicker-title select,
html body .ui-datepicker .ui-datepicker-title select {
    display: inline-block !important;
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 3px !important;
    padding: 4px 8px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    margin: 0 2px !important;
    min-width: auto !important;
    width: auto !important;
}

html body #ui-datepicker-div .ui-datepicker-title select option,
html body .ui-datepicker .ui-datepicker-title select option {
    background: #fff !important;
    color: #333 !important;
}

/* Navigation buttons - prev/next */
html body #ui-datepicker-div .ui-datepicker-prev,
html body #ui-datepicker-div .ui-datepicker-next,
html body .ui-datepicker .ui-datepicker-prev,
html body .ui-datepicker .ui-datepicker-next {
    cursor: pointer !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 30px !important;
    height: 30px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 3px !important;
    transition: background-color 0.2s ease !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    text-indent: -9999px !important;
    overflow: hidden !important;
}

html body #ui-datepicker-div .ui-datepicker-prev,
html body .ui-datepicker .ui-datepicker-prev {
    left: 8px !important;
}

html body #ui-datepicker-div .ui-datepicker-next,
html body .ui-datepicker .ui-datepicker-next {
    right: 8px !important;
}

/* Hide jQuery UI icon elements */
html body #ui-datepicker-div .ui-datepicker-prev .ui-icon,
html body #ui-datepicker-div .ui-datepicker-next .ui-icon,
html body .ui-datepicker .ui-datepicker-prev .ui-icon,
html body .ui-datepicker .ui-datepicker-next .ui-icon {
    display: none !important;
}

/* CSS-based chevron arrows */
html body #ui-datepicker-div .ui-datepicker-prev::after,
html body #ui-datepicker-div .ui-datepicker-next::after,
html body .ui-datepicker .ui-datepicker-prev::after,
html body .ui-datepicker .ui-datepicker-next::after {
    content: '' !important;
    display: block !important;
    width: 10px !important;
    height: 10px !important;
    border-top: 2px solid #fff !important;
    border-right: 2px solid #fff !important;
    position: absolute !important;
    top: 50% !important;
    text-indent: 0 !important;
}

/* Previous arrow (left chevron) */
html body #ui-datepicker-div .ui-datepicker-prev::after,
html body .ui-datepicker .ui-datepicker-prev::after {
    transform: translateY(-50%) rotate(-135deg) !important;
    left: 12px !important;
}

/* Next arrow (right chevron) */
html body #ui-datepicker-div .ui-datepicker-next::after,
html body .ui-datepicker .ui-datepicker-next::after {
    transform: translateY(-50%) rotate(45deg) !important;
    right: 12px !important;
}

/* Hover states for navigation */
html body #ui-datepicker-div .ui-datepicker-prev:hover,
html body #ui-datepicker-div .ui-datepicker-next:hover,
html body .ui-datepicker .ui-datepicker-prev:hover,
html body .ui-datepicker .ui-datepicker-next:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}

/* Calendar table styling */
html body #ui-datepicker-div .ui-datepicker-calendar,
html body .ui-datepicker .ui-datepicker-calendar {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 0 !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar th,
html body .ui-datepicker .ui-datepicker-calendar th {
    background: #f5f5f5 !important;
    color: #333 !important;
    font-weight: 600 !important;
    padding: 8px 4px !important;
    text-align: center !important;
    font-size: 12px !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td,
html body .ui-datepicker .ui-datepicker-calendar td {
    padding: 2px !important;
    text-align: center !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td a,
html body #ui-datepicker-div .ui-datepicker-calendar td span,
html body .ui-datepicker .ui-datepicker-calendar td a,
html body .ui-datepicker .ui-datepicker-calendar td span {
    padding: 8px !important;
    text-align: center !important;
    color: #333 !important;
    transition: background-color 0.2s ease, color 0.2s ease !important;
    display: block !important;
    border-radius: 3px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    line-height: 16px !important;
    text-decoration: none !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td a:hover,
html body .ui-datepicker .ui-datepicker-calendar td a:hover {
    background: #e0e0e0 !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td.ui-datepicker-today a,
html body .ui-datepicker .ui-datepicker-calendar td.ui-datepicker-today a {
    background: #0073aa !important;
    color: #fff !important;
    font-weight: 600 !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td.ui-datepicker-current-day a,
html body .ui-datepicker .ui-datepicker-calendar td.ui-datepicker-current-day a {
    background: #005177 !important;
    color: #fff !important;
    font-weight: 700 !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td.ui-datepicker-other-month a,
html body #ui-datepicker-div .ui-datepicker-calendar td.ui-datepicker-other-month span,
html body .ui-datepicker .ui-datepicker-calendar td.ui-datepicker-other-month a,
html body .ui-datepicker .ui-datepicker-calendar td.ui-datepicker-other-month span {
    color: #ccc !important;
}

html body #ui-datepicker-div .ui-datepicker-calendar td.ui-state-disabled span,
html body .ui-datepicker .ui-datepicker-calendar td.ui-state-disabled span {
    color: #ccc !important;
    cursor: not-allowed !important;
    opacity: 0.5 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wp-smart-delivery-fulfillment-section {
        padding: 15px;
        margin-bottom: 15px;
    }

    .wp-smart-delivery-fulfillment-heading {
        font-size: 1em;
        margin-bottom: 12px;
    }

    .wp-smart-delivery-fulfillment-type-field,
    .wp-smart-delivery-date-field,
    .wp-smart-delivery-time-slot-field {
        margin-bottom: 1em;
    }

    /* Keep radio buttons in one row on mobile but adjust spacing */
    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper {
        gap: 0;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }

    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > input[type="radio"] {
        width: 20px;
        height: 20px;
        margin-right: 0.5em;
        margin-top: 0.1em;
    }

    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio {
        padding: 0;
        font-size: 0.95em;
        min-height: 44px; /* Touch-friendly */
        align-items: center;
        flex: 0 1 auto;
        margin-right: 1.5em; /* Reduced spacing on mobile */
    }

    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio:last-of-type {
        margin-right: 0;
    }

    .wp-smart-delivery-date-field input[type="text"],
    .wp-smart-delivery-time-slot-field select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75em;
        min-height: 44px; /* Touch-friendly minimum size */
    }

    /* Mobile-friendly datepicker */
    html body #ui-datepicker-div,
    html body .ui-datepicker {
        width: calc(100vw - 40px) !important;
        max-width: 320px !important;
        font-size: 13px !important;
    }

    html body #ui-datepicker-div .ui-datepicker-header,
    html body .ui-datepicker .ui-datepicker-header {
        padding: 12px 8px !important;
    }

    html body #ui-datepicker-div .ui-datepicker-calendar th,
    html body .ui-datepicker .ui-datepicker-calendar th {
        padding: 6px 2px !important;
        font-size: 11px !important;
    }

    html body #ui-datepicker-div .ui-datepicker-calendar td a,
    html body #ui-datepicker-div .ui-datepicker-calendar td span,
    html body .ui-datepicker .ui-datepicker-calendar td a,
    html body .ui-datepicker .ui-datepicker-calendar td span {
        padding: 10px 6px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        line-height: 16px !important;
    }

    .wp-smart-delivery-spinner {
        margin-left: 8px;
    }

    .wp-smart-delivery-spinner .spinner {
        width: 18px;
        height: 18px;
    }

    .wp-smart-delivery-error {
        font-size: 0.8em;
        margin-top: 4px;
    }
}

@media (max-width: 480px) {
    .wp-smart-delivery-fulfillment-section {
        padding: 12px;
    }

    .wp-smart-delivery-fulfillment-heading {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    /* Keep radio buttons in one row on small mobile */
    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper {
        gap: 0;
        flex-wrap: nowrap;
    }

    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > input[type="radio"] {
        width: 18px;
        height: 18px;
        margin-right: 0.4em;
    }

    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio {
        font-size: 0.9em;
        padding: 0;
        min-height: 40px;
        margin-right: 1em; /* Reduced spacing on small mobile */
    }

    .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper > label.radio:last-of-type {
        margin-right: 0;
    }

    html body #ui-datepicker-div,
    html body .ui-datepicker {
        width: calc(100vw - 20px) !important;
        font-size: 12px !important;
    }

    html body #ui-datepicker-div .ui-datepicker-calendar td a,
    html body #ui-datepicker-div .ui-datepicker-calendar td span,
    html body .ui-datepicker .ui-datepicker-calendar td a,
    html body .ui-datepicker .ui-datepicker-calendar td span {
        padding: 8px 4px !important;
        min-width: 32px !important;
        min-height: 32px !important;
        line-height: 16px !important;
    }

    .wp-smart-delivery-date-field input[type="text"],
    .wp-smart-delivery-time-slot-field select {
        padding: 0.875em;
    }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
    html body #ui-datepicker-div,
    html body .ui-datepicker {
        max-width: 350px !important;
    }
}

/* Estimated Delivery Styles */
.wp-sds-earliest-delivery {
    margin-bottom: 1em;
    padding: 0.75em;
    line-height: 1.6;
}

.wp-sds-earliest-delivery__label {
    font-weight: 600;
    margin-right: 0.5em;
}

.wp-sds-earliest-delivery__value {
    color: #2271b1;
    font-weight: 500;
}

/* Cart Estimated Delivery */
.wp-sds-cart-estimated-delivery {
    margin-bottom: 1em;
    padding: 0.75em;
    background: #f8f9fa;
    border-left: 3px solid #2271b1;
    border-radius: 2px;
    line-height: 1.6;
}

.wp-sds-cart-estimated-delivery__label {
    font-weight: 600;
    margin-right: 0.5em;
}

.wp-sds-cart-estimated-delivery__value {
    color: #2271b1;
    font-weight: 500;
}

/* Checkout Estimated Delivery - Blue box style in order summary */
.woocommerce-checkout .wp-sds-checkout-estimated-delivery {
    margin-top: 0;
    padding: 1em 1.25em;
    border: none;
    border-left: 2px solid #e0e0e0;
    border-right: 2px solid #e0e0e0;
    border-radius: 4px;
    color: #fff;
    display: block;
    width: 40%;
    float: right;
    box-sizing: border-box;
    position: relative;
}

/* Ensure estimated delivery respects order review padding */
.woocommerce-checkout form #order_review .wp-sds-checkout-estimated-delivery {
    margin-left: 0;
    margin-right: 0;
}

/* Hide estimated delivery from left column (customer details area) */
.woocommerce-checkout #customer_details .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .woocommerce-billing-fields .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .woocommerce-shipping-fields .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .woocommerce-additional-fields .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .col-1 .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .large-7 .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .col-md-7 .wp-sds-checkout-estimated-delivery {
    display: none !important;
}

/* Only show in order review area (right column) */
.woocommerce-checkout #order_review .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .woocommerce-checkout-review-order .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .col-2 .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .large-5 .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .col-md-5 .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .checkout-sidebar .wp-sds-checkout-estimated-delivery {
    display: block !important;
}

.wp-sds-checkout-estimated-delivery__wrapper {
    display: flex;
    align-items: center;
    gap: 0.75em;
    width: 100%;
    background: #2271b1;
}

.wp-sds-checkout-estimated-delivery__icon {
    color: #fff;
    font-size: 20px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.9;
    line-height: 1;
}

.wp-sds-checkout-estimated-delivery__content {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25em;
    line-height: 1.4;
}

.wp-sds-checkout-estimated-delivery__label {
    display: inline;
    margin: 0;
    color: #fff;
    font-weight: 600;
    font-size: 0.95em;
    opacity: 0.95;
    white-space: nowrap;
}

.wp-sds-checkout-estimated-delivery__value {
    display: inline;
    font-size: 1.1em;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

/* Match WooCommerce order review styling */
.woocommerce-checkout form #order_review:not(.elementor-widget-woocommerce-checkout-page #order_review) {
    padding: 0 2em;
    border-width: 0 2px 2px;
    border-style: solid;
    border-color: var(--ast-border-color, #e0e0e0);
}

@media (min-width: 922px) {
    .woocommerce.woocommerce-checkout form #order_review,
    .woocommerce.woocommerce-checkout form #order_review_heading,
    .woocommerce-page.woocommerce-checkout form #order_review,
    .woocommerce-page.woocommerce-checkout form #order_review_heading {
        width: 40%;
        float: right;
        margin-right: 0;
        clear: right;
    }
}

/* Ensure proper spacing in order summary */
.woocommerce-checkout #order_review,
.woocommerce-checkout .woocommerce-checkout-review-order,
.woocommerce-checkout .woocommerce-checkout-review-order-table {
    position: relative;
}

.woocommerce-checkout #order_review .wp-sds-checkout-estimated-delivery,
.woocommerce-checkout .woocommerce-checkout-review-order .wp-sds-checkout-estimated-delivery {
    margin-top: 0;
}

/* Prevent text merging in order summary header */
.woocommerce-checkout #order_review_heading,
.woocommerce-checkout .woocommerce-checkout-review-order h3,
.woocommerce-checkout .woocommerce-checkout-review-order-table h3 {
    margin-bottom: 1em;
    clear: both;
    display: block;
    width: 100%;
}

/* Ensure estimated delivery appears before order totals in the table */
.woocommerce-checkout .shop_table.woocommerce-checkout-review-order-table {
    margin-top: 0;
}

/* Position estimated delivery before order totals row */
.woocommerce-checkout .shop_table.woocommerce-checkout-review-order-table .order-total {
    position: relative;
}

.woocommerce-checkout .shop_table.woocommerce-checkout-review-order-table tr.order-total::before {
    content: '';
    display: block;
    margin-bottom: 1.5em;
}

/* Fix checkout layout - ensure fields don't break layout */
.woocommerce-checkout .wp-smart-delivery-fulfillment-section {
    clear: both;
    margin-top: 25px;
    margin-bottom: 25px;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
    float: none;
    border-top: 1px solid #e0e0e0;
    padding-top: 25px;
}

.woocommerce-checkout #shipping_address_2_field + .wp-smart-delivery-fulfillment-section,
.woocommerce-checkout .woocommerce-shipping-fields + .wp-smart-delivery-fulfillment-section {
    margin-top: 30px;
    border-top: 1px solid #e0e0e0;
    padding-top: 25px;
}

.woocommerce-checkout .wp-smart-delivery-date-field,
.woocommerce-checkout .wp-smart-delivery-time-slot-field {
    clear: both;
    margin-top: 15px;
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
    float: none;
}

/* Ensure form fields don't overflow */
.woocommerce-checkout .wp-smart-delivery-fulfillment-type-field {
    width: 100%;
    box-sizing: border-box;
    float: none;
    clear: both;
}

.woocommerce-checkout .wp-smart-delivery-fulfillment-type-field .woocommerce-input-wrapper {
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
}

/* Ensure form-row-wide class works correctly */
.woocommerce-checkout .wp-smart-delivery-fulfillment-type-field.form-row-wide,
.woocommerce-checkout .wp-smart-delivery-date-field.form-row-wide,
.woocommerce-checkout .wp-smart-delivery-time-slot-field.form-row-wide {
    width: 100%;
    float: none;
    clear: both;
}

/* Ensure form-row wrapper doesn't break layout */
.woocommerce-checkout .form-row.wp-smart-delivery-fulfillment-type-field,
.woocommerce-checkout .form-row.wp-smart-delivery-date-field,
.woocommerce-checkout .form-row.wp-smart-delivery-time-slot-field {
    width: 100%;
    float: none;
    clear: both;
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

/* Fix for two-column checkout layouts */
.woocommerce-checkout .col2-set .col-1 .wp-smart-delivery-fulfillment-section,
.woocommerce-checkout .col2-set .col-1 .wp-smart-delivery-date-field,
.woocommerce-checkout .col2-set .col-1 .wp-smart-delivery-time-slot-field,
.woocommerce-checkout .col2-set .col-2 .wp-smart-delivery-fulfillment-section,
.woocommerce-checkout .col2-set .col-2 .wp-smart-delivery-date-field,
.woocommerce-checkout .col2-set .col-2 .wp-smart-delivery-time-slot-field {
    width: 100%;
    float: none;
    clear: both;
}

/* Responsive adjustments for estimated delivery */
@media (max-width: 768px) {
    .wp-sds-checkout-estimated-delivery {
        padding: 0.875em 1em;
        width: 100%;
        float: none;
    }

    .wp-sds-checkout-estimated-delivery__icon {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }

    .wp-sds-checkout-estimated-delivery__value {
        font-size: 1em;
    }

    .wp-sds-checkout-estimated-delivery__label {
        font-size: 0.9em;
    }

    .wp-sds-cart-estimated-delivery {
        padding: 0.625em;
    }
}


@media (max-width: 427px) {
    .wp-sds-checkout-estimated-delivery {
        width: 100% !important;
        float: none !important;
    }
}

/* Minicart Estimated Delivery */
.wp-sds-minicart-estimated-delivery {
    margin: 0.75em 0;
    padding: 0.75em;
    font-size: 0.9em;
    background: #f0f6fc;
    border: 1px solid #2271b1;
    border-left: 3px solid #2271b1;
    border-radius: 3px;
    text-align: center;
}

.wp-sds-minicart-estimated-delivery__label {
    display: block;
    font-size: 0.85em;
    color: #1d2327;
    margin-bottom: 0.15em;
}

.wp-sds-minicart-estimated-delivery__value {
    display: block;
    font-size: 0.95em;
    font-weight: 600;
    color: #2271b1;
}

/* Block-based minicart estimated delivery */
.wp-sds-minicart-estimated-delivery-block {
    margin-top: 0.75em;
    margin-bottom: 0.75em;
    padding: 0.75em;
    font-size: 0.9em;
    background: #f0f6fc;
    border: 1px solid #2271b1;
    border-left: 3px solid #2271b1;
    border-radius: 3px;
}

.wp-sds-minicart-estimated-delivery-block .dashicons {
    color: #2271b1;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Responsive adjustments for minicart estimated delivery */
@media (max-width: 768px) {
    .wp-sds-minicart-estimated-delivery,
    .wp-sds-minicart-estimated-delivery-block {
        font-size: 0.85em;
        padding: 0.6em;
    }
    
    .wp-sds-minicart-estimated-delivery__label,
    .wp-sds-minicart-estimated-delivery-block span {
        font-size: 0.8em;
    }
    
    .wp-sds-minicart-estimated-delivery__value {
        font-size: 0.9em;
    }
}