/**
 * STJ Delivery Manager - Checkout Page Brand Styling
 * File: assets/css/frontend/stjdm-checkout.css
 * 
 * This styling works alongside the existing functional styles
 * and applies STJ brand colors, fonts, and design aesthetic
 */

/* Hide express payment options and separator on Checkout page */
body.woocommerce-checkout #wc-stripe-express-checkout-element,
body.woocommerce-checkout #wc-stripe-express-checkout-button-separator {
    display: none !important;
}

/* ========================================
   CHECKOUT LAYOUT RESTRUCTURING
   ======================================== */

/* Desktop: Two-column layout */
@media (min-width: 769px) {
    /* Make checkout form use flexbox */
    .woocommerce-checkout .woocommerce-checkout {
        display: flex;
        flex-wrap: wrap;
        gap: 30px;
    }
    
    /* Left column: Order Type + Delivery Info */
    .woocommerce-checkout .col-1 {
        flex: 0 0 calc(50% - 15px);
        order: 1;
    }
    
    /* Right column: Billing + Additional Info */
    .woocommerce-checkout .col-2 {
        flex: 0 0 calc(50% - 15px);
        order: 2;
    }
    
    /* Move billing to top of right column */
    .woocommerce-checkout .woocommerce-billing-fields {
        order: 1;
    }
    
    /* Additional info stays below billing in right column */
    .woocommerce-checkout .woocommerce-additional-fields {
        order: 2;
    }
    
    /* Order Type section at top of left column */
    #stjdm-order-type-section {
        order: 1;
    }
    
    /* Delivery Information below Order Type in left column */
    #stjdm-checkout-fields-wrapper {
        order: 2;
    }
    
    /* Your Order section spans full width below columns */
    #order_review_heading,
    #order_review {
        flex: 0 0 100%;
        order: 3;
        clear: both;
    }
    
    /* Payment section spans full width below Your Order */
    .woocommerce-checkout-payment {
        flex: 0 0 100%;
        order: 4;
        clear: both;
    }
}

/* Mobile/Tablet: Single column, specific order */
@media (max-width: 768px) {
    .woocommerce-checkout .woocommerce-checkout {
        display: flex;
        flex-direction: column;
    }
    
    /* Order Type at top */
    #stjdm-order-type-section {
        order: 1;
    }
    
    /* Delivery Information */
    #stjdm-checkout-fields-wrapper {
        order: 2;
    }
    
    /* Billing Details */
    .woocommerce-checkout .woocommerce-billing-fields {
        order: 3;
    }
    
    /* Additional Information */
    .woocommerce-checkout .woocommerce-additional-fields {
        order: 4;
    }
    
    /* Your Order */
    #order_review_heading,
    #order_review {
        order: 5;
    }
    
    /* Payment Info */
    .woocommerce-checkout-payment {
        order: 6;
    }
}

/* ========================================
   GLOBAL CHECKOUT STYLES
   ======================================== */

/* Elementor checkout page title */
.woocommerce-checkout .elementor-heading-title {
    font-family: 'the-seasons', serif !important;
    font-size: 48px !important;
    font-weight: 600 !important;
}

/* Elementor header - Sam & Jack's */
.elementor-element-4ae89ea .elementor-heading-title,
.elementor-element-5ed4684 .elementor-heading-title {
    font-family: 'the-seasons', serif !important;
    font-size: 32px !important;
    font-weight: 600 !important;
}

.elementor-element-4ae89ea .elementor-heading-title a,
.elementor-element-5ed4684 .elementor-heading-title a {
    font-family: 'the-seasons', serif !important;
    font-size: 32px !important;
    font-weight: 600 !important;
}

/* Elementor header - Catering */
.elementor-element-b69b4f7 .elementor-heading-title,
.elementor-element-721f05d .elementor-heading-title {
    font-family: 'Poppins', sans-serif !important;
    font-size: 17px !important;
    font-weight: 400 !important;
}

.elementor-element-b69b4f7 .elementor-heading-title a,
.elementor-element-721f05d .elementor-heading-title a {
    font-family: 'Poppins', sans-serif !important;
    font-size: 17px !important;
    font-weight: 400 !important;
}

/* Navigation Menu - all links should be weight 400 */
.elementor-element-bc65c62 .elementor-nav-menu a,
.elementor-element-bc65c62 .elementor-item,
.elementor-element-bc65c62 .elementor-sub-item {
    font-weight: 400 !important;
}

/* Set all checkout fonts to Poppins */
.woocommerce-checkout,
.woocommerce-checkout * {
    font-family: 'Poppins', sans-serif !important;
}

/* Set default text color to brown */
.woocommerce-checkout,
.woocommerce-checkout label,
.woocommerce-checkout .woocommerce-form__label,
.woocommerce-checkout h3,
.woocommerce-checkout p {
    color: #613C21 !important;
}

/* Remove border radius from all fields and buttons */
.woocommerce-checkout input[type="text"],
.woocommerce-checkout input[type="email"],
.woocommerce-checkout input[type="tel"],
.woocommerce-checkout input[type="date"],
.woocommerce-checkout input[type="number"],
.woocommerce-checkout input[type="password"],
.woocommerce-checkout select,
.woocommerce-checkout textarea,
.woocommerce-checkout button,
.woocommerce-checkout .button,
.woocommerce-checkout .input-text,
.woocommerce-checkout .select2-container .select2-selection,
.woocommerce-checkout .select2-container--default .select2-selection--single {
    border-radius: 0 !important;
}

/* ========================================
   ORDER TYPE SELECTION - PROMINENT CARDS
   ======================================== */

#stjdm-order-type-section {
    background: #FFF9F0;
    padding: 25px;
    margin-bottom: 30px;
    border-left: 5px solid #7F9731;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.stjdm-order-type-heading {
    color: #613C21 !important;
    font-weight: 700 !important;
    font-size: 24px !important;
    margin: 0 0 20px 0 !important;
    padding: 0 !important;
    border: none !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stjdm-delivery-type-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.stjdm-delivery-card {
    display: block;
    position: relative;
    cursor: pointer;
    background: white;
    border: 3px solid #E0E0E0;
    padding: 20px;
    transition: all 0.3s ease;
    margin: 0 !important;
}

.stjdm-delivery-card:hover {
    border-color: #7F9731;
    box-shadow: 0 4px 12px rgba(127, 151, 49, 0.15);
}

.stjdm-delivery-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.stjdm-delivery-card input[type="radio"]:checked + .stjdm-card-content {
    border-left: 5px solid #7F9731;
    padding-left: 15px;
}

.stjdm-delivery-card input[type="radio"]:checked ~ .stjdm-card-content::before {
    content: "✓";
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: #7F9731;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
}

.stjdm-card-content {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    transition: all 0.3s ease;
}

.stjdm-card-icon {
    font-size: 48px;
    line-height: 1;
    flex-shrink: 0;
}

.stjdm-card-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}

.stjdm-card-title {
    font-size: 20px;
    font-weight: 700;
    color: #613C21;
    display: block;
}

.stjdm-card-description {
    font-size: 14px;
    color: #613C21;
    opacity: 0.8;
    display: block;
    line-height: 1.4;
}

/* Selected state for the card itself */
.stjdm-delivery-card:has(input[type="radio"]:checked) {
    border-color: #7F9731;
    background: #F9FFF0;
}

/* ========================================
   SECTION STYLING - Remove Boxes
   ======================================== */

/* Remove backgrounds from all sections */
.woocommerce-checkout .woocommerce-billing-fields,
.woocommerce-checkout .woocommerce-additional-fields,
.woocommerce-checkout #stjdm-checkout-fields-wrapper,
.woocommerce-checkout .woocommerce-checkout-review-order,
.woocommerce-checkout .woocommerce-checkout-payment {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Add thin dividing lines between major sections */
.woocommerce-checkout .woocommerce-billing-fields,
.woocommerce-checkout .woocommerce-additional-fields {
    border-bottom: 1px solid #613C21 !important;
    padding-bottom: 2rem !important;
    margin-bottom: 2rem !important;
}

/* Remove ALL borders from col-1 wrapper */
.woocommerce-checkout .col-1,
.woocommerce form.checkout .col-1,
form.checkout .col-1 {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    border-left: none !important;
    border-right: none !important;
}

.woocommerce-checkout .col-1 > *,
.woocommerce-checkout .col-1::after,
.woocommerce-checkout .col-1::before {
    border-bottom: none !important;
}

/* Delivery Information section - PROMINENT */
#stjdm-checkout-fields-wrapper {
    background: #FFF9F0 !important;
    padding: 25px !important;
    margin: 20px 0 !important;
    margin-top: 2rem !important;
    padding-bottom: 25px !important;
    border: none !important;
    border-left: 4px solid #7F9731 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08) !important;
}

#stjdm-checkout-fields-wrapper::after,
.woocommerce-billing-fields::after {
    display: none !important;
}

#stjdm-checkout-fields-wrapper .form-row {
    border-bottom: none !important;
}

#stjdm-checkout-fields-wrapper h3 {
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    color: #613C21 !important;
    border-bottom: 2px solid #7F9731 !important;
    padding-bottom: 12px !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stjdm-section-icon {
    font-size: 24px;
    display: inline-block;
}

/* Section headings */
.woocommerce-checkout h3 {
    color: #613C21 !important;
    font-weight: 600 !important;
    font-size: 20px !important;
    margin-bottom: 1.5rem !important;
    padding-bottom: 0.5rem !important;
    border-bottom: 1px solid #613C21 !important;
}

/* ========================================
   FORM FIELDS
   ======================================== */

/* All input fields and textareas */
.woocommerce-checkout input[type="text"],
.woocommerce-checkout input[type="email"],
.woocommerce-checkout input[type="tel"],
.woocommerce-checkout input[type="date"],
.woocommerce-checkout input[type="number"],
.woocommerce-checkout input[type="password"],
.woocommerce-checkout select,
.woocommerce-checkout textarea,
.woocommerce form .form-row input.input-text,
.woocommerce form .form-row select,
.woocommerce form .form-row textarea,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--single .select2-selection__rendered {
    border: 1px solid #613C21 !important;
    color: #613C21 !important;
    background: white !important;
    font-size: 14px !important;
}

/* Field focus state */
.woocommerce-checkout input[type="text"]:focus,
.woocommerce-checkout input[type="email"]:focus,
.woocommerce-checkout input[type="tel"]:focus,
.woocommerce-checkout input[type="date"]:focus,
.woocommerce-checkout select:focus,
.woocommerce-checkout textarea:focus {
    border-color: #613C21 !important;
    outline: none !important;
}

/* Field labels */
.woocommerce-checkout label {
    color: #613C21 !important;
    font-weight: 500 !important;
}

/* Required asterisk */
.woocommerce-checkout .required {
    color: #613C21 !important;
}



/* ========================================
   DELIVERY TYPE RADIO BUTTONS (OLD - HIDDEN)
   ======================================== */

/* Hide the old radio button field since we're using cards now */
.stjdm-delivery-type {
    display: none !important;
}

/* ========================================
   YOUR ORDER SECTION WITH INTEGRATED FEES
   ======================================== */

/* Order review container - complete box */
.woocommerce-checkout-review-order {
    border: 1px solid #613C21 !important;
    padding: 1.5rem !important;
    margin-bottom: 2rem !important;
}

/* Order review table */
.woocommerce-checkout-review-order-table {
    border: none !important;
}

/* Product names in order review - green */
.woocommerce-checkout-review-order-table .product-name a,
.woocommerce-checkout-review-order-table td.product-name {
    color: #7F9731 !important;
    font-weight: 500 !important;
}

/* Keep variation labels and values brown */
.woocommerce-checkout-review-order-table .variation dt,
.woocommerce-checkout-review-order-table .variation dd {
    color: #613C21 !important;
}

/* Order totals */
.woocommerce-checkout-review-order-table th,
.woocommerce-checkout-review-order-table td {
    color: #613C21 !important;
    border-top: 1px solid #613C21 !important;
    border-bottom: none !important;
}

/* Fee rows styling - uses same structure as product rows */
.stjdm-catering-fee-row.cart_item td.product-name,
.stjdm-delivery-fee-row.cart_item td.product-name,
.stjdm-order-total-row.cart_item td.product-name {
    color: #613C21 !important;
    text-align: left !important;
}

.stjdm-catering-fee-row.cart_item td.product-total,
.stjdm-delivery-fee-row.cart_item td.product-total,
.stjdm-order-total-row.cart_item td.product-total {
    text-align: left !important;
}

/* Make only the fee name text bold, not the description */
.stjdm-catering-fee-row.cart_item td.product-name .stjdm-fee-name,
.stjdm-delivery-fee-row.cart_item td.product-name .stjdm-fee-name {
    font-weight: 700 !important;
    color: #613C21 !important;
}

/* Ensure variation descriptions stay normal weight */
.stjdm-catering-fee-row.cart_item .variation,
.stjdm-delivery-fee-row.cart_item .variation {
    font-weight: normal !important;
}

/* Style Total row like Subtotal in tfoot */
.stjdm-order-total-row.cart_item {
    /* This row should look like cart-subtotal */
}

.stjdm-order-total-row.cart_item td.product-name,
.stjdm-order-total-row.cart_item td.product-total {
    font-weight: normal !important;
    color: #613C21 !important;
}

.stjdm-order-total-row.cart_item td.product-name strong,
.stjdm-order-total-row.cart_item td.product-total strong {
    font-weight: 700 !important;
}

/* Add top border to total row to separate from fees */
.stjdm-order-total-row.cart_item td {
    border-top: 2px solid #613C21 !important;
}

/* Close the box - add bottom border to last row */
.woocommerce-checkout-review-order-table tfoot tr:last-child td {
    border-bottom: 1px solid #613C21 !important;
}

/* Hide WooCommerce's default order total row */
.woocommerce-checkout-review-order-table .order-total {
    display: none !important;
}

/* ========================================
   HOUSE SELECTION FIELDS
   ======================================== */

/* Override plugin's default box styling */
#stjdm-house-selection-fields,
#stjdm-pickup-time-fields {
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
}

/* Autocomplete styling */
.stjdm-autocomplete-results {
    border: 1px solid #613C21 !important;
    border-radius: 0 !important;
    background: white;
    max-height: 200px;
    overflow-y: auto;
    position: absolute;
    z-index: 1000;
    width: 100%;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stjdm-autocomplete-result {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0 !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.stjdm-autocomplete-result:last-child {
    border-bottom: none !important;
}

.stjdm-autocomplete-result:hover {
    background-color: #FFF9F0 !important;
}

.stjdm-autocomplete-result strong {
    color: #613C21 !important;
    font-weight: 600;
}

.stjdm-autocomplete-result small {
    color: #613C21 !important;
    opacity: 0.7;
}

.stjdm-autocomplete-no-results,
.stjdm-autocomplete-loading,
.stjdm-autocomplete-error {
    padding: 12px;
    color: #613C21;
    font-style: italic;
}

/* ========================================
   ORDER NOTES WARNING
   ======================================== */

.woocommerce-additional-fields {
    position: relative;
}

.woocommerce-additional-fields::before {
    content: "⚠️ For delivery instructions, use the Delivery Information section above. This field is for general order notes only.";
    display: block;
    background: #FFF9E6;
    border-left: 4px solid #F0AD4E;
    padding: 15px;
    margin-bottom: 15px;
    color: #856404;
    font-weight: 500;
    font-size: 14px;
    line-height: 1.5;
}

/* Style the order notes textarea */
.woocommerce-checkout .woocommerce-additional-fields textarea {
    border: 1px solid #613C21 !important;
    color: #613C21 !important;
    border-radius: 0 !important;
}

/* ========================================
   PAYMENT SECTION
   ======================================== */

/* Payment methods */
.woocommerce-checkout-payment {
    background: transparent !important;
    border: none !important;
}

.woocommerce-checkout-payment ul.payment_methods {
    border: none !important;
}

.woocommerce-checkout-payment ul.payment_methods li {
    border-bottom: 1px solid #613C21 !important;
}

.woocommerce-checkout-payment label {
    color: #613C21 !important;
}

/* Payment box */
.woocommerce-checkout-payment .payment_box {
    background: #f9f9f9 !important;
    color: #613C21 !important;
    border-radius: 0 !important;
}

/* ========================================
   PLACE ORDER BUTTON
   ======================================== */

/* Place order button styling */
.woocommerce-checkout #place_order,
.woocommerce-checkout .woocommerce-form__input-checkbox + button {
    background-color: #BC326B !important;
    color: #FFFFFF !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 12px 24px !important;
    font-family: 'Poppins', sans-serif !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
}

/* Disable hover effects on place order button */
.woocommerce-checkout #place_order:hover,
.woocommerce-checkout #place_order:focus,
.woocommerce-checkout #place_order:active {
    background-color: #BC326B !important;
    color: #FFFFFF !important;
    opacity: 1 !important;
}

/* ========================================
   PRIVACY POLICY & TERMS
   ======================================== */

/* Hide privacy policy text */
.woocommerce-checkout .woocommerce-privacy-policy-text {
    display: none !important;
}

.woocommerce-checkout .woocommerce-terms-and-conditions-wrapper {
    color: #613C21 !important;
}

.woocommerce-checkout .woocommerce-terms-and-conditions-wrapper a {
    color: #7F9731 !important;
}

/* ========================================
   RESPONSIVE DESIGN - MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    /* Adjust section spacing for mobile */
    .woocommerce-checkout .woocommerce-billing-fields,
    .woocommerce-checkout .woocommerce-additional-fields,
    .woocommerce-checkout #stjdm-checkout-fields-wrapper {
        padding-bottom: 1.5rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    /* Adjust heading size for mobile */
    .woocommerce-checkout h3 {
        font-size: 18px !important;
    }
    
    /* Stack card content on very small screens */
    .stjdm-card-content {
        flex-direction: column;
        text-align: center;
    }
    
    .stjdm-card-icon {
        font-size: 40px;
    }
    
    .stjdm-card-title {
        font-size: 18px;
    }
    
    .stjdm-card-description {
        font-size: 13px;
    }
    
    /* Adjust order type section padding */
    #stjdm-order-type-section {
        padding: 20px;
    }
    
    .stjdm-order-type-heading {
        font-size: 20px !important;
    }
    
    /* Adjust delivery info section padding */
    #stjdm-checkout-fields-wrapper {
        padding: 20px !important;
    }
    
    /* Remove any column gaps on mobile */
    .woocommerce-checkout .col-1,
    .woocommerce-checkout .col-2 {
        width: 100%;
        margin: 0;
    }
}

/* ========================================
   ERROR & VALIDATION MESSAGES
   ======================================== */

/* Error messages */
.woocommerce-checkout .woocommerce-error,
.woocommerce-checkout .woocommerce-NoticeGroup-checkout .woocommerce-error {
    background: #f8d7da !important;
    color: #721c24 !important;
    border: 1px solid #f5c6cb !important;
    border-radius: 0 !important;
}

/* Success messages */
.woocommerce-checkout .woocommerce-message {
    background: #d4edda !important;
    color: #155724 !important;
    border: 1px solid #c3e6cb !important;
    border-radius: 0 !important;
}

/* Field validation errors */
.woocommerce-checkout input.error,
.woocommerce-checkout select.error,
.woocommerce-checkout textarea.error {
    border-color: #721c24 !important;
}

/* ========================================
   CART-LIKE STYLING FOR CONSISTENCY
   ======================================== */

/* Make product images hidden in order review if they appear */
.woocommerce-checkout-review-order-table .product-thumbnail {
    display: none !important;
}

/* Ensure consistent spacing */
.woocommerce-checkout-review-order-table td,
.woocommerce-checkout-review-order-table th {
    padding: 12px 0 !important;
}

/* ========================================
   ALLERGY CONSIDERATIONS (from other plugin)
   ======================================== */

/* Ensure allergy section follows same styling */
.woocommerce-checkout [class*="allergy"] {
    color: #613C21 !important;
    font-family: 'Poppins', sans-serif !important;
}

.woocommerce-checkout [class*="allergy"] h3 {
    color: #613C21 !important;
    border-bottom: 1px solid #613C21 !important;
}

.woocommerce-checkout [class*="allergy"] input,
.woocommerce-checkout [class*="allergy"] textarea {
    border: 1px solid #613C21 !important;
    border-radius: 0 !important;
    color: #613C21 !important;
}

/* CC Fee row styling */
.stjdm-cc-fee-row.cart_item td.product-name,
.stjdm-cc-fee-row.cart_item td.product-total {
    color: #613C21 !important;
    text-align: left !important;
}

.stjdm-cc-fee-row.cart_item td.product-name .stjdm-fee-name {
    font-weight: 700 !important;
    color: #613C21 !important;
}

/* Fee footnote styling */
.stjdm-fee-footnote td {
    color: #613C21 !important;
    font-size: 12px !important;
    font-style: italic !important;
    padding-top: 10px !important;
    border-top: none !important;
}

/* Bottom border for pickup order total row */
.stjdm-order-total-row {
    border-bottom: 2px solid #e8e8e8;
}

/* Expected Total and Pre-Authorization Total labels - brown */
.stjdm-expected-total-row.cart_item td.product-name strong,
.stjdm-preauth-total-row.cart_item td.product-name strong {
    color: #613C21 !important;
}