/* Email Suggestions Styling - Muji-inspired Redesign */
#email-suggestions {
    position: absolute;
    width: 100%;
    z-index: 999999 !important;
    background: #F7F7F7; /* Soft off-white background */
    box-shadow: 0 2px 8px rgba(0,0,0,0.1); /* Softer shadow */
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 4px; /* Subtle border radius */
    margin-top: 8px; /* Increased margin-top */
    display: none;
    border: 1px solid #E0E0E0; /* Lighter border */
}

.email-suggestion {
    padding: 14px 20px !important; /* Generous padding */
    cursor: pointer !important;
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    transition: background-color 0.2s ease, color 0.2s ease;
    background: transparent !important;
    border: none;
    font-size: 14px;
    color: #333333; /* Dark gray text */
    border-bottom: 1px solid #E0E0E0; /* Lighter separator */
    touch-action: manipulation;
    text-transform: none !important;
}

.email-suggestion:last-child {
    border-bottom: none; /* Remove border from last item */
}

.email-suggestion.hover,
.email-suggestion:hover {
    background-color: #EFEFEF !important; /* Muted hover state */
    color: #000000 !important;
}

@media (max-width: 768px) {
    #email-suggestions {
        max-height: 220px; /* Adjusted for mobile */
    }
    
    .email-suggestion {
        padding: 16px 20px !important;
        font-size: 16px; /* Larger font for mobile */
    }
}

/* General Checkout Form Styling */
.woocommerce-checkout .form-row {
    margin-bottom: 20px !important;
}

.woocommerce form .form-row {
    position: relative;
}

.woocommerce form .form-row label {
    font-weight: 500;
    margin-bottom: 8px;
    display: block;
    color: #333;
}

/* Enhanced Input Field Styling */
.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce form .form-row select {
    padding: 12px 15px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 400;
    background-color: #fff;
    width: 100%;
    color: #2c3338;
    margin: 0;
    box-sizing: border-box;
    height: 46px;
    line-height: normal;
    
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    
    box-shadow: 0 1px 2px rgba(0,0,0,0.05), 
               inset 0 1px 2px rgba(255,255,255,0.05);
}

/* Specific fix for select fields */
.woocommerce form .form-row select {
    padding-right: 30px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #fff;
    position: relative;
}

.woocommerce form .form-row select::after {
    content: "▼";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

/* Remove default select arrow in IE/Edge */
.woocommerce form .form-row select::-ms-expand {
    display: none;
}

/* Ensure consistent spacing between form rows */
.woocommerce form .form-row {
    padding: 3px;
    margin: 0 0 16px;
}

/* Improved focus state */
.woocommerce form .form-row input.input-text:focus,
.woocommerce form .form-row textarea:focus,
.woocommerce form .form-row select:focus {
    border-color: #2271b1;
    border-width: 1.5px;
    outline: none;
    box-shadow: 0 0 0 1px rgba(34,113,177,0.1),
               0 2px 4px rgba(34,113,177,0.08);
    background-color: #fff;
}

/* Sharper placeholder text */
.woocommerce form .form-row input.input-text::placeholder {
    color: #6c757d;
    opacity: 0.8;
    font-weight: 400;
    letter-spacing: 0.2px;
}

/* Mobile optimization */
@media (max-width: 768px) {
    .woocommerce form .form-row input.input-text,
    .woocommerce form .form-row textarea,
    .woocommerce form .form-row select {
        font-size: 16px;
        line-height: 1.4;
        padding: 12px 15px;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
}

/* Fix for Safari text rendering */
@media not all and (min-resolution:.001dpcm) { 
    @supports (-webkit-appearance:none) {
        .woocommerce form .form-row input.input-text,
        .woocommerce form .form-row textarea,
        .woocommerce form .form-row select {
            letter-spacing: -0.2px;
        }
    }
}

/* Required Field Indicator */
.woocommerce form .form-row .required {
    color: #dc3545;
    font-weight: 700;
    border: 0 !important;
    text-decoration: none;
}

/* Error States */
.woocommerce form .form-row.woocommerce-invalid label {
    color: #dc3545;
}

.woocommerce form .form-row.woocommerce-invalid input.input-text,
.woocommerce form .form-row.woocommerce-invalid select {
    border-color: #dc3545;
    background-color: #fff8f8;
}

/* Valid States */
.woocommerce form .form-row.woocommerce-validated input.input-text,
.woocommerce form .form-row.woocommerce-validated select {
    border-color: #28a745;
}

/* Order Review Section */
.woocommerce-checkout-review-order {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

#order_review_heading {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #eee;
    color: #333;
}

/* Payment Section */
#payment {
    background: #fff !important;
    border-radius: 8px !important;
    padding: 15px !important;
}

#payment div.payment_box {
    background-color: #f8f9fa;
    border: 1px solid #eee;
}

/* Add touch feedback styles */
.email-suggestion {
    touch-action: pan-y;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.email-suggestion.hover {
    background-color: #f0f7ff !important;
    color: #0066cc !important;
}

/* Prevent text selection during drag */
.email-suggestions-dragging {
    user-select: none;
    -webkit-user-select: none;
}

/* Grid Layout System */
.woocommerce-checkout .form-row {
    display: block;
    width: 100%;
    margin-bottom: 20px !important;
}

/* Consistent Field Layout */
.woocommerce form .form-row-wide,
.woocommerce-page form .form-row-wide {
    width: 100%;
    clear: both;
}

/* Region/State Field Specific Fix */
#billing_state_field {
    width: 100% !important;
    padding: 3px !important;
    margin-bottom: 16px !important;
}

/* Select Field Container */
.woocommerce form .form-row .select2-container {
    width: 100% !important;
    height: 46px !important;
    line-height: 46px !important;
}

/* Select Field Appearance */
.select2-container--default .select2-selection--single {
    height: 46px !important;
    border: 1.5px solid #ddd !important;
    border-radius: 8px !important;
    padding: 8px 15px !important;
    background-color: #fff !important;
    display: flex !important;
    align-items: center !important;
}

/* Select Field Text */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 28px !important;
    color: #2c3338 !important;
    padding-left: 0 !important;
}

/* Select Field Arrow */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
    right: 8px !important;
}

/* Ensure all inputs have consistent height */
.woocommerce form .form-row input.input-text,
.woocommerce form .form-row select,
.select2-container .select2-selection--single {
    height: 46px !important;
    min-height: 46px !important;
    box-sizing: border-box !important;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .woocommerce form .form-row-first,
    .woocommerce form .form-row-last,
    .woocommerce form .form-row-wide {
        width: 100% !important;
        float: none !important;
    }

    #billing_state_field {
        margin-bottom: 20px !important;
    }
}

/* Order Notes Field Specific Styling */
#order_comments {
    min-height: 80px !important; /* Increase height for notes field */
    height: auto !important; /* Allow auto height expansion */
    padding: 12px 15px !important;
    line-height: 1.5 !important;
}

/* Placeholder Text Styling */
#order_comments::placeholder {
    white-space: pre-line !important; /* Allow line breaks in placeholder */
    line-height: 1.5 !important;
    color: #6c757d !important;
    opacity: 0.8 !important;
}

/* Container Styling */
.woocommerce form .form-row textarea {
    height: auto !important;
    min-height: 80px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    resize: vertical !important; /* Allow vertical resizing */
}

/* Mobile Optimization */
@media (max-width: 768px) {
    #order_comments {
        min-height: 100px !important;
        font-size: 16px !important; /* Better readability on mobile */
    }
}

/* Phone field specific styling */
#billing_phone {
    letter-spacing: 0.5px;
    font-family: monospace;
}

#billing_phone::placeholder {
    font-family: inherit;
    letter-spacing: normal;
}

/* Placeholder Styling */
.woocommerce form .form-row input::placeholder {
    color: #6c757d !important;
    opacity: 0.8 !important;
}

/* Ensure proper text display */
.woocommerce form .form-row input.input-text {
    font-size: 15px !important;
    line-height: 1.5 !important;
}

/* Muji-like Styling for Buttons */
#office-pickup-btn,
#my-location-btn {
    background-color: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    color: #333;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    height: 36px;
    box-sizing: border-box;
    text-transform: none;
    box-shadow: none;
}

#office-pickup-btn:hover,
#my-location-btn:hover {
    background-color: #f9f9f9;
    border-color: #bbb;
}

/* Specific styling for address field */
#billing_address_1_field {
    margin-bottom: 16px !important;
}

#billing_address_1 {
	width: 100% !important;
	padding: 12px 15px !important;
}

/* Address Field Buttons Container */
.button-container {
    display: flex;
    gap: 10px;
    visibility: hidden; /* Initially hide the container */
}

.button-container.visible {
    visibility: visible; /* Make it visible when the class is added */
}

/* Tooltip Styling */
#get-current-location-wrapper .tooltip-text {
    visibility: hidden;
    width: 160px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px 12px;
    position: absolute;
    z-index: 1;
    bottom: 125%; /* Position above the button */
    left: 50%;
    margin-left: -80px; /* Center the tooltip */
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    font-size: 13px;
    font-weight: 500;
}

#get-current-location-wrapper:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}