/**
 * Product Fields Styles
 */

.lep-product-fields,
.lep-ship-to-field,
.lep-patient-field,
.lep-shipping-address-field {
    margin-bottom: 20px;
    margin-top: 15px;
}

.lep-product-fields .lep-field-group,
.lep-ship-to-field .lep-field-group,
.lep-patient-field .lep-field-group,
.lep-shipping-address-field .lep-field-group {
    margin-bottom: 15px;
}

.lep-product-fields label,
.lep-ship-to-field label,
.lep-patient-field label,
.lep-shipping-address-field label {
    display: block;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 700;
    line-height: 37.4px;
    text-align: left;
    margin-bottom: 8px;
}

.lep-product-fields .lep-field,
.lep-ship-to-field .lep-field,
.lep-patient-field .lep-field,
.lep-shipping-address-field .lep-field {
    width: 100%;
    padding: 0.2em 35px 0.2em 0.5em;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 400;
    line-height: 27.2px;
    text-transform: none;
    background-color: #fff;
    background-image: none;
    border: 1px solid var(--global-gray-400);
    border-radius: 0;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0px 0px 0px -7px rgba(0,0,0,0);
    outline: 0;
    transition: border-color 0.15s ease-in-out;
}

.lep-product-fields .lep-field:focus,
.lep-ship-to-field .lep-field:focus,
.lep-patient-field .lep-field:focus,
.lep-shipping-address-field .lep-field:focus {
    border-color: #2271b1;
    outline: 2px solid transparent;
    outline-offset: 0;
    box-shadow: 0 0 0 1px #2271b1;
}

.lep-product-fields .lep-field::placeholder,
.lep-ship-to-field .lep-field::placeholder,
.lep-patient-field .lep-field::placeholder,
.lep-shipping-address-field .lep-field::placeholder {
    color: #757575;
    opacity: 1;
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-weight: 400;
}

.lep-product-fields .lep-textarea {
    resize: vertical;
    min-height: 80px;
    padding: 0.5em; /* Different padding for textarea */
}

/* Style select dropdown */
.lep-ship-to-field .lep-select,
.lep-patient-field .lep-select:not(.select2-hidden-accessible),
.lep-shipping-address-field .lep-select:not(.select2-hidden-accessible) {
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2714%27%20height%3D%278%27%20viewBox%3D%270%200%2014%208%27%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%3E%3Cpath%20d%3D%27M1%201L7%207L13%201%27%20stroke%3D%27%238C8F94%27%20stroke-width%3D%272%27%20fill%3D%27none%27%20fill-rule%3D%27evenodd%27/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 100%;
}

/* Style native select option placeholders */
.lep-ship-to-field .lep-select option[value=""],
.variations_form .variations select option[value=""],
.variations_form .variations select option:first-child {
    color: #757575;
    opacity: 1;
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-weight: 400;
}

/* Style native select when placeholder is selected */
.lep-ship-to-field .lep-select:has(option[value=""]:checked),
.variations_form .variations select:has(option[value=""]:checked),
.variations_form .variations select:invalid,
.lep-ship-to-field .lep-select:invalid {
    color: #757575;
}

/* Select2 Styling - Match native select exactly */
.lep-patient-field .select2-container,
.lep-shipping-address-field .select2-container {
    width: 100% !important;
}

.lep-patient-field .select2-container--default .select2-selection--single,
.lep-shipping-address-field .select2-container--default .select2-selection--single {
    height: auto;
    padding: 0.2em 35px 0.2em 0.5em;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 400;
    line-height: 27.2px;
    text-transform: none;
    background-color: #fff;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2714%27%20height%3D%278%27%20viewBox%3D%270%200%2014%208%27%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%3E%3Cpath%20d%3D%27M1%201L7%207L13%201%27%20stroke%3D%27%238C8F94%27%20stroke-width%3D%272%27%20fill%3D%27none%27%20fill-rule%3D%27evenodd%27/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 100%;
    border: 1px solid var(--global-gray-400);
    border-radius: 0;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0px 0px 0px -7px rgba(0,0,0,0);
    outline: 0;
    transition: border-color 0.15s ease-in-out;
}

.lep-patient-field .select2-container--default.select2-container--focus .select2-selection--single,
.lep-patient-field .select2-container--default.select2-container--open .select2-selection--single,
.lep-shipping-address-field .select2-container--default.select2-container--focus .select2-selection--single,
.lep-shipping-address-field .select2-container--default.select2-container--open .select2-selection--single {
    border-color: #2271b1;
    outline: 2px solid transparent;
    outline-offset: 0;
    box-shadow: 0 0 0 1px #2271b1;
}

.lep-patient-field .select2-container--default .select2-selection--single .select2-selection__rendered,
.lep-shipping-address-field .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: rgb(45, 55, 72);
    padding: 0;
    line-height: 27.2px;
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-weight: 400;
}

.lep-patient-field .select2-container--default .select2-selection--single .select2-selection__placeholder,
.lep-shipping-address-field .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #757575;
    opacity: 1;
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-weight: 400;
}

/* Hide default Select2 arrow */
.lep-patient-field .select2-container--default .select2-selection--single .select2-selection__arrow,
.lep-shipping-address-field .select2-container--default .select2-selection--single .select2-selection__arrow {
    display: none;
}

/* Style Select2 clear button */
.lep-patient-field .select2-container--default .select2-selection--single .select2-selection__clear,
.lep-shipping-address-field .select2-container--default .select2-selection--single .select2-selection__clear {
    color: #8C8F94;
    cursor: pointer;
    float: right;
    font-weight: 400;
    font-size: 20px;
    line-height: 1;
    margin-right: 30px;
    margin-top: 4px;
    padding: 0;
}

.lep-patient-field .select2-container--default .select2-selection--single .select2-selection__clear:hover,
.lep-shipping-address-field .select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: #2c3338;
}

.lep-patient-field .select2-dropdown,
.lep-shipping-address-field .select2-dropdown {
    border: 1px solid var(--global-gray-400);
    border-radius: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    margin-top: 4px;
}

/* Force dropdown below */
.lep-patient-field .select2-container--default.select2-container--open .select2-dropdown,
.lep-shipping-address-field .select2-container--default.select2-container--open .select2-dropdown {
    top: 100%;
}

.lep-patient-field .select2-search--dropdown,
.lep-shipping-address-field .select2-search--dropdown {
    padding: 4px;
}

.lep-patient-field .select2-search--dropdown .select2-search__field,
.lep-shipping-address-field .select2-search--dropdown .select2-search__field {
    padding: 6px 10px;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 400;
    line-height: 27.2px;
    text-transform: none;
    border: 1px solid var(--global-gray-400);
    border-radius: 0;
}

.lep-patient-field .select2-search--dropdown .select2-search__field:focus,
.lep-shipping-address-field .select2-search--dropdown .select2-search__field:focus {
    border-color: #2271b1;
    outline: 2px solid transparent;
    box-shadow: 0 0 0 1px #2271b1;
}

.lep-patient-field .select2-search--dropdown .select2-search__field::placeholder,
.lep-shipping-address-field .select2-search--dropdown .select2-search__field::placeholder {
    color: #757575;
    opacity: 1;
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-weight: 400;
}

.lep-patient-field .select2-results__option,
.lep-shipping-address-field .select2-results__option {
    padding: 8px 12px;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 400;
    line-height: 27.2px;
    text-transform: none;
}

.lep-patient-field .select2-results__option--highlighted[aria-selected],
.lep-shipping-address-field .select2-results__option--highlighted[aria-selected] {
    background-color: #2271b1;
    color: #fff;
}

.lep-patient-field .select2-results__option[aria-selected="true"],
.lep-shipping-address-field .select2-results__option[aria-selected="true"] {
    background-color: #f0f0f1;
    color: #2c3338;
}

.lep-patient-field .select2-results__option--selectable,
.lep-shipping-address-field .select2-results__option--selectable {
    cursor: pointer;
}

/* Match WooCommerce form row styling */
.lep-product-fields .lep-field-group:last-child,
.lep-ship-to-field .lep-field-group:last-child,
.lep-patient-field .lep-field-group:last-child,
.lep-shipping-address-field .lep-field-group:last-child {
    margin-bottom: 0;
}

/* Style WooCommerce variation fields to match */
.variations_form .variations td.value {
    width: 100%;
}

.variations_form .variations select {
    width: 100% !important;
    padding: 0.2em 35px 0.2em 0.5em;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 400;
    line-height: 27.2px;
    text-transform: none;
    background-color: #fff;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2714%27%20height%3D%278%27%20viewBox%3D%270%200%2014%208%27%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%3E%3Cpath%20d%3D%27M1%201L7%207L13%201%27%20stroke%3D%27%238C8F94%27%20stroke-width%3D%272%27%20fill%3D%27none%27%20fill-rule%3D%27evenodd%27/%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 100%;
    border: 1px solid var(--global-gray-400);
    border-radius: 0;
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    box-shadow: 0px 0px 0px -7px rgba(0,0,0,0);
    outline: 0;
    transition: border-color 0.15s ease-in-out;
}

.variations_form .variations select:focus {
    border-color: #2271b1;
    outline: 2px solid transparent;
    outline-offset: 0;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Style variation labels */
.variations_form .variations td.label label {
    display: block;
    box-sizing: border-box;
    color: rgb(45, 55, 72);
    font-family: "Noto Sans", sans-serif;
    font-size: 17px;
    font-style: normal;
    font-weight: 700;
    line-height: 37.4px;
    text-align: left;
    margin-bottom: 8px;
}

/* Ensure variations table has proper spacing */
.variations_form .variations {
    width: 100%;
    margin-bottom: 20px;
}

.variations_form .variations tr {
    display: block;
    margin-bottom: 15px;
}

.variations_form .variations td {
    display: block;
    padding: 0;
}

/* Hide the Clear selection link */
.variations_form .reset_variations {
    display: none !important;
}


/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .lep-product-fields {
        margin-top: 10px;
        margin-bottom: 15px;
    }
    
    .lep-product-fields .lep-field-group {
        margin-bottom: 12px;
    }
}

/* Add New Patient/Address Links */
.lep-add-patient-link,
.lep-add-address-link {
    display: inline-block;
    margin-top: 8px;
    color: #2271b1;
    font-size: 14px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.lep-add-patient-link:hover,
.lep-add-address-link:hover {
    color: #135e96;
    text-decoration: underline;
}

/* Modal Styles */
.lep-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.lep-modal-open {
    overflow: hidden;
}

.lep-modal-content {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.lep-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.lep-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #1d2327;
}

.lep-modal-close {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    color: #999;
    background: none;
    border: none;
    padding: 0;
    transition: color 0.2s ease;
}

.lep-modal-close:hover {
    color: #333;
}

/* Form Styles (Patient & Address) */
.lep-patient-form,
.lep-address-form {
    padding: 24px;
}

.lep-form-row {
    margin-bottom: 20px;
}

.lep-form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1d2327;
    font-size: 14px;
}

.lep-form-row label .required,
.lep-product-fields label .required,
.lep-ship-to-field label .required,
.lep-patient-field label .required,
.lep-shipping-address-field label .required {
    color: #dc3232;
    font-weight: 700;
}

.lep-form-row input[type="text"],
.lep-form-row input[type="email"],
.lep-form-row input[type="tel"],
.lep-form-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.lep-form-row input[type="text"]:focus,
.lep-form-row input[type="email"]:focus,
.lep-form-row input[type="tel"]:focus,
.lep-form-row select:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Half-width form rows for address form */
.lep-form-row-half {
    display: flex;
    gap: 16px;
}

.lep-form-row-half .lep-form-col {
    flex: 1;
}

@media screen and (max-width: 480px) {
    .lep-form-row-half {
        flex-direction: column;
        gap: 0;
    }
}

.lep-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.lep-form-actions .button {
    padding: 6px 16px;
    font-size: 14px;
    line-height: 1.5;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.lep-form-actions .button-primary {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.lep-form-actions .button-primary:hover {
    background: #135e96;
    border-color: #135e96;
}

.lep-form-actions .button-primary:disabled {
    background: #68a3d9;
    border-color: #68a3d9;
    cursor: not-allowed;
}

.lep-form-actions .lep-modal-cancel {
    background: #f0f0f1;
    color: #2c3338;
    border-color: #ddd;
}

.lep-form-actions .lep-modal-cancel:hover {
    background: #e5e5e5;
    border-color: #ccc;
}

/* Form Messages */
.lep-form-message {
    padding: 12px 16px;
    margin: 0 24px 24px;
    border-radius: 4px;
    font-size: 14px;
}

.lep-form-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.lep-form-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive Modal */
@media screen and (max-width: 600px) {
    .lep-modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .lep-modal-header {
        padding: 16px 20px;
    }
    
    .lep-patient-form,
    .lep-address-form {
        padding: 20px;
    }
    
    .lep-form-actions {
        flex-wrap: wrap;
    }
    
    .lep-form-actions .button {
        flex: 1;
        min-width: 120px;
    }
}