/*
 * CSS styling section for the form
 * This section is designed to be responsive and work well on various devices (desktop and mobile).
 * It relies on percentages, `max-width`, and Flexbox for automatic adaptation.
 * You can modify these styles to change the entire appearance of the form through the plugin settings.
 *
 * This file contains general form styling and specific adjustments for Select2.
 */

.cod-form-container {
    max-width: 600px;
    margin: 20px auto;
    background: var(--form-bg-color, #f9f9f9);
    border-radius: var(--form-border-radius, 8px);
    padding: var(--form-padding, 20px);
    box-shadow: var(--form-box-shadow, 0 2px 10px rgba(0,0,0,0.1));
    font-family: 'Inter', sans-serif;
    color: var(--label-color, #333); /* Default text color for the container */
}

.cod-form-container h2 {
    color: var(--title-color, #333);
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
}

.cod-form-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--label-color, #333);
    font-size: 16px;
}

.cod-form-container input[type="text"],
.cod-form-container input[type="email"],
.cod-form-container input[type="tel"],
.cod-form-container textarea,
/* Select elements will be hidden by Select2, so no need to style them directly */
.cod-form-container .select2-container--default .select2-selection--single { /* Style for Select2 rendered input */
    width: 100%;
    height: auto !important; /* Allow Select2 to adjust height */
    padding: 12px;
    margin-bottom: 15px; /* Select2 container has its own margin */
    border: 1px solid var(--input-border-color, #ddd) !important;
    border-radius: 6px !important;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 1.5;
    color: var(--input-text-color, #555);
    background-color: var(--input-bg-color, #ffffff) !important;
}
.cod-form-container .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--input-text-color, #555);
    padding: 0 !important; /* Select2 adds default padding, we want to control it from parent */
    line-height: inherit; /* Inherit line-height from parent */
    display: flex; /* Use flexbox for flag and text alignment */
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important; /* Ensure arrow is vertically centered */
    right: 12px !important; /* Position arrow correctly */
}

/* Select2 Dropdown Styling */
.select2-container--default .select2-dropdown {
    border: 1px solid var(--input-border-color, #ddd) !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 99999; /* Ensure dropdown appears above other elements */
    min-width: 250px; /* Set minimum width to ensure content is visible */
    width: auto !important; /* Allow width to adjust to content if larger */
}
.select2-container--default .select2-results__option {
    padding: 10px 12px;
    font-size: 16px;
    color: var(--input-text-color, #555);
}

.select2-container--default .select2-results__option--highlighted {
    background-color: var(--input-hover-bg-color) !important; /* This will be set by JS */
    color: var(--input-text-color, #555) !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--input-selected-bg-color) !important; /* This will be set by JS */
    color: var(--input-text-color, #555) !important;
}

/* Flag icon within Select2 */
.select2-container .flag-icon {
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
    line-height: 0;
    flex-shrink: 0; /* Prevent flag from shrinking */
}
.select2-container .flag-icon svg {
    width: 20px;
    height: 14px;
    border: 1px solid #ccc;
    box-sizing: content-box;
}
.select2-container .dial-code-text {
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
    flex-shrink: 0; /* Prevent text from shrinking */
}
.select2-container .country-name-text {
    flex-grow: 1; /* Allow country name to take remaining space */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* Phone/WhatsApp Table Layout */
.phone-whatsapp-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.phone-whatsapp-table td {
    padding: 0;
    vertical-align: top;
}

/* Adjusted widths for table cells to prevent wrapping */
.phone-whatsapp-table td:first-child {
    width: 1px; /* Make it as narrow as its content */
    white-space: nowrap; /* Prevent content from wrapping */
    padding-right: 10px; /* Space between columns */
}

.phone-whatsapp-table td:last-child {
    width: auto; /* Take remaining space */
}

/* Ensure inputs/selects within table cells take full available width */
.phone-whatsapp-table .select2-container,
.phone-whatsapp-table input[type="tel"] {
    width: 100% !important;
    margin-bottom: 0 !important;
}


/* Coupon section styles */
.coupon-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}
.coupon-table td {
    padding: 0;
    vertical-align: top;
}
.coupon-table td:first-child {
    width: 70%; /* Coupon input field width */
    padding-right: 10px;
}
.coupon-table td:last-child {
    width: 30%; /* Apply button width */
}
.coupon-table input[type="text"],
.coupon-table button {
    width: 100% !important; /* Ensure they fill their table cell */
    margin-bottom: 0 !important; /* Remove extra margin */
}
.coupon-table button {
    padding: 10px 15px; /* Smaller padding for button */
    font-size: 16px; /* Smaller font for button */
}

.coupon-message {
    margin-top: 10px;
    font-size: 14px;
}

/* Product information styles */
.product-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 6px;
}
.product-info img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}
.product-info .details {
    flex-grow: 1;
}
.product-info .details h3 {
    margin: 0 0 5px 0;
    font-size: 18px;
    color: #333;
}
.product-info .details .price {
    font-size: 18px;
    font-weight: bold;
    color: #0073aa;
}

/* Invoice details box styles */
.invoice-details-box {
    background-color: #eef;
    border: 1px solid #ccd;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}
.invoice-details-box h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 20px;
    color: #0073aa;
    text-align: center;
}
.invoice-details-box table {
    width: 100%;
    border-collapse: collapse;
}
.invoice-details-box table td {
    padding: 8px 0;
    border-bottom: 1px dashed #e0e0e0;
}
.invoice-details-box table td:first-child {
    font-weight: bold;
    color: #555;
}
.invoice-details-box table tr:last-child td {
    border-bottom: none;
}
.invoice-details-box table .total-row td {
    font-size: 18px;
    font-weight: bold;
    color: #000;
    padding-top: 15px;
}

/* Separator line styles */
.cod-form-container hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 25px 0;
}

/* "Add something else" option styles */
.additional-option {
    margin-bottom: 20px;
}
.additional-option input[type="checkbox"] {
    width: auto; /* Allow default size */
    margin-right: 10px;
    vertical-align: middle;
    margin-bottom: 0; /* Remove default bottom margin */
}
.additional-option label {
    display: inline-block; /* To place label next to checkbox */
    vertical-align: middle;
    font-weight: normal; /* Make text normal instead of bold */
    cursor: pointer; /* Indicate it's clickable */
}


/* Media Queries for better responsiveness on very small screens */
@media (max-width: 480px) {
    /* Coupon section stacks vertically */
    .coupon-table td:first-child,
    .coupon-table td:last-child {
        width: 100%; /* Make them stack vertically on small screens */
        display: block; /* Ensure they take full width */
        padding-right: 0;
    }
    .coupon-table input[type="text"],
    .coupon-table button {
        margin-bottom: 15px !important; /* Add space between coupon field and button when stacked */
    }
    .coupon-table button {
        margin-bottom: 0 !important; /* Remove bottom margin from the last element */
    }


    /* Table layout for phone/WhatsApp on small screens */
    .phone-whatsapp-table td:first-child {
        width: 40%; /* Adjust width for dial code on small screens */
        padding-right: 5px;
    }
    .phone-whatsapp-table td:last-child {
        width: 60%; /* Adjust width for local number on small screens */
    }

    /* General responsive adjustments */
    .product-info {
        flex-direction: column;
        text-align: center;
    }
    .product-info img {
        margin-bottom: 10px;
    }
}