/* Lightbox Styles */
.soh-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.soh-lightbox-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: sohFadeIn 0.3s ease-out;
    transition: max-width 0.3s ease;
}

/* Step-based layout */
.soh-lightbox-step {
    display: none;
    min-height: 100%;
}

.soh-lightbox-step.active {
    display: block;
}

/* Make sure the initial step choice is visible (inline style will be overridden by classes) */
.soh-step-choice {
    display: none;
}

.soh-step-choice.active {
    display: block;
}

.soh-step-delivery {
    display: none;
}

.soh-step-delivery.active {
    display: block;
}

/* When in delivery step, expand to full width */
.soh-lightbox-overlay[data-step="delivery"] .soh-lightbox-content {
    max-width: 600px;
}

@keyframes sohFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.soh-lightbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #f0f0f0;
    gap: 16px;
}

.soh-lightbox-header h2 {
    margin: 0;
    font-size: 22px;
    color: #1a1a1a;
    flex: 1;
    font-weight: 600;
}

.soh-lightbox-back {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 500;
    margin-right: 8px;
}

.soh-lightbox-back:hover {
    background: #f5f5f5;
    color: #333;
}

.soh-lightbox-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.soh-lightbox-close:hover {
    background: #f5f5f5;
    color: #333;
}

.soh-lightbox-body {
    padding: 24px;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

/* Step 1: Choice view - grid layout */
.soh-step-choice .soh-lightbox-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Step 2: Delivery entry - full width */
.soh-delivery-entry {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.soh-option-card {
    flex: 1;
    min-width: 200px;
    padding: 24px;
    border: 2px solid #e8e8e8;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.soh-option-card:hover:not(.disabled) {
    border-color: #007cba;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 124, 186, 0.15);
}

.soh-option-card.selected {
    border-color: #007cba;
    background: #f0f8ff;
}

.soh-option-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f9f9f9;
}

.soh-option-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.soh-option-card h3 {
    margin: 12px 0 8px 0;
    color: #1a1a1a;
    font-size: 18px;
    font-weight: 600;
}

.soh-option-card p {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* Delivery address input wrapper with icons */
.soh-address-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
}

.soh-address-icon {
    position: absolute;
    left: 14px;
    color: #999;
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
}

/* Delivery address input styles */
#soh-delivery-address {
    width: 100%;
    padding: 14px 44px 14px 40px;
    border: 2px solid #e8e8e8;
    border-radius: 50px;
    font-size: 16px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    font-family: inherit;
    height: 50px;
}

#soh-delivery-address:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

#soh-delivery-address::placeholder {
    color: #999;
}

/* Clear button styles */
.soh-clear-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
}

.soh-clear-btn:hover {
    color: #333;
}

#soh-delivery-address:not(:placeholder-shown) ~ .soh-clear-btn {
    display: flex;
}

.soh-address-input-wrapper:has(#soh-delivery-address:focus) .soh-address-icon {
    color: #007cba;
}

/* Address error state */
#soh-delivery-address.error {
    border-color: #dc3545;
    background-color: white;
}

#soh-delivery-address.error:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.soh-address-error {
    display: none;
    margin-top: -3px;
    color: #dc3545;
    font-size: 13px;
    line-height: 1.3;
}

.soh-address-error.show {
    display: flex !important;
    align-items: flex-start;
    gap: 6px;
}

.soh-error-icon {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    display: none;
}

.soh-address-error.show .soh-error-icon {
    display: block;
}

.soh-error-text {
    display: block;
    flex: 1;
    word-break: break-word;
}

.soh-address-error strong {
    font-weight: 600;
}

.soh-address-validating {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    color: #666;
    font-size: 13px;
}

.soh-address-validating.show {
    display: flex !important;
}

.soh-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0066cc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#soh-address-suggestions {
    display: none;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    background: white;
    margin-top: 8px;
}

#soh-address-suggestions.active {
    display: block;
}

.soh-button-group {
    margin-top: 15px;
    display: flex;
    gap: 12px;
    width: 100%;
}

#soh-confirm-delivery,
#soh-collect-instead {
    background: #333;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.soh-btn-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

#soh-confirm-delivery:hover:not(:disabled),
#soh-collect-instead:hover:not(:disabled) {
    background: #333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3);
}

#soh-confirm-delivery:active:not(:disabled),
#soh-collect-instead:active:not(:disabled) {
    transform: translateY(0);
}

#soh-collect-instead {
    background: #333;
}

#soh-address-suggestions {
    display: none;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    background: white;
    margin-top: 8px;
}

#soh-address-suggestions.active {
    display: block;
}

.soh-address-suggestion {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s ease;
    font-size: 14px;
}

.soh-address-suggestion:hover {
    background: #f8f9fa;
}

.soh-address-suggestion:last-child {
    border-bottom: none;
}

/* Shortcode Styles */
.soh-delivery-preference {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.soh-delivery-preference h3 {
    margin-top: 0;
    color: #333;
}

.soh-current-preference {
    background: white;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.soh-delivery-preference .button {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: 10px;
    transition: background 0.3s ease;
}

.soh-delivery-preference .button:hover {
    background: #005a87;
}

/* Responsive Design */
@media (max-width: 600px) {
    .soh-lightbox-body {
        flex-direction: column;
    }

    .soh-option-card {
        min-width: auto;
    }

    .soh-lightbox-header h2 {
        font-size: 20px;
    }
}

.soh-option-card.disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.soh-option-card.disabled .soh-option-icon {
    opacity: 0.6;
}

.soh-modal-header {
    padding: 30px 24px 20px;
    text-align: center;
}

.soh-modal-header h2 {
    margin: 0;
    font-size: 22px;
    color: #1a1a1a;
    font-weight: 600;
}

.soh-modal-body {
    padding: 24px;
}

.soh-modal-body p {
    margin: 0 0 12px 0;
    font-size: 15px;
    line-height: 1.6;
    color: #666;
}

.soh-modal-body p:last-child {
    margin-bottom: 0;
}

/* Checkout Address Field Error State */
.soh-address-error-message {
    display: block;
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
}

#soh_delivery_address_checkout.soh-error-field {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
}

.form-row.has-error #soh_delivery_address_checkout,
.form-group.has-error #soh_delivery_address_checkout {
    border-color: #dc3545 !important;
    background-color: #fff5f5 !important;
}

/* Mobile Bottom Sheet Styles */
@media (max-width: 768px) {
    .soh-lightbox-overlay {
        align-items: flex-end;
        justify-content: center;
    }
    
    .soh-lightbox-content {
        border-radius: 20px 20px 0 0;
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        animation: sohSlideUp 0.3s ease-out;
    }
    
    @keyframes sohSlideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    .soh-lightbox-header {
        padding: 16px 24px;
        border-bottom: 1px solid #e0e0e0;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1000;
    }
    
    .soh-lightbox-header h2 {
        font-size: 18px;
    }
    
    .soh-lightbox-body {
        padding: 20px 24px 24px;
    }
    
    /* Add safe area for notches */
    @supports (padding: max(0px)) {
        .soh-lightbox-content {
            padding-left: max(12px, env(safe-area-inset-left));
            padding-right: max(12px, env(safe-area-inset-right));
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
    }
    
    /* Ensure buttons are easily tappable on mobile */
    .soh-lightbox-close,
    .soh-lightbox-back {
        padding: 12px 16px;
        min-width: 44px;
        min-height: 44px;
        font-size: 24px;
    }
    
    /* Delivery method buttons take full width on mobile */
    .soh-delivery-option {
        width: 100%;
        margin-bottom: 12px;
    }
    
    /* Address field improvements for mobile */
    #soh_delivery_address_checkout {
        font-size: 16px;
        padding: 12px;
    }
    
    /* Adjust time slot styling for mobile */
    #soh_time_select {
        font-size: 16px;
        padding: 12px;
        width: 100%;
    }
}