/*
 * 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.
 */

.my-custom-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 */
}

.my-custom-form-container h2 {
    color: var(--title-color, #333);
    margin-top: 0;
    margin-bottom: 15px;
    text-align: center;
}

.my-custom-form-container label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--label-color, #333);
    font-size: 16px;
}

.my-custom-form-container input[type="text"],
.my-custom-form-container input[type="email"],
.my-custom-form-container input[type="tel"],
.my-custom-form-container textarea,
/* Select elements will be hidden by Select2, so no need to style them directly */
.my-custom-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;
}
.my-custom-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; /* تحديد أدنى عرض لضمان ظهور المحتوى بشكل جيد */
    width: auto !important; /* السماح للعرض بالتكيف مع المحتوى إذا كان أكبر */
}
.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 input group styles (using Flexbox for flexible layout) */
.phone-input-group {
    display: flex;
    align-items: center; /* Align items vertically */
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: nowrap; /* Ensure they stay on one line on larger screens */
}
.phone-input-group .select2-container { /* Select2 container for dial code */
    flex-basis: 120px; /* Preferred width */
    flex-grow: 0;      /* Don't grow */
    flex-shrink: 0;    /* Don't shrink below content, but allow it to be 120px */
    width: auto !important; /* Let flexbox handle width */
    min-width: 100px;  /* Ensure it doesn't get too small */
    max-width: 150px;  /* Prevent it from getting too wide if content allows */
    margin-bottom: 0;
}
.phone-input-group input[type="tel"] {
    flex-grow: 1; /* Allow it to grow and take remaining space */
    min-width: 150px; /* Ensure phone number input is readable */
    margin-bottom: 0;
}


/* Coupon section styles */
.coupon-section {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap; /* For responsiveness on small screens */
}
.coupon-section input[type="text"] {
    flex-grow: 1;
    margin-bottom: 0; /* Remove extra bottom margin within flex group */
}
.coupon-section button {
    flex-shrink: 0;
    width: auto; /* Allow button to adapt to content */
    padding: 10px 15px; /* Smaller padding for button */
    font-size: 16px; /* Smaller font for button */
    margin-bottom: 0;
}
.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 */
.my-custom-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 {
        flex-direction: column;
        gap: 0;
    }
    .coupon-section input[type="text"],
    .coupon-section button {
        width: 100% !important; /* تجعل حقل الكوبون وزر التطبيق يأخذان عرض 100% */
        margin-bottom: 15px; /* تترك مسافة بين حقل الكوبون وزر التطبيق */
    }

    /* تعديل حقول الهاتف والواتساب لتظل على سطر واحد ومرنة */
    .phone-input-group {
        flex-wrap: nowrap; /* تأكد من عدم التفاف العناصر إلى سطر جديد */
        gap: 5px; /* تقليل المسافة بين العناصر على الشاشات الصغيرة جداً */
        min-width: 0; /* السماح للحاوية بالانكماش إلى 0 إذا لزم الأمر */
    }
    .phone-input-group .select2-container {
        flex-grow: 1;      /* السماح بالنمو */
        flex-shrink: 1;    /* السماح بالانكماش */
        flex-basis: 35%;   /* قاعدة مرنة للعرض، تبدأ من 35% */
        max-width: 100px;  /* تحديد أقصى عرض لرمز الدولة */
        min-width: 70px;   /* تحديد أدنى عرض لرمز الدولة للسماح بالانكماش */
        width: auto !important; /* تجاوز أي عرض مضمن من Select2 */
    }
    .phone-input-group input[type="tel"] {
        flex-grow: 2;      /* السماح بالنمو أكثر من رمز الدولة */
        flex-shrink: 1;    /* السماح بالانكماش */
        flex-basis: 65%;   /* قاعدة مرنة للعرض، تبدأ من 65% */
        min-width: 100px;  /* تحديد أدنى عرض لرقم الهاتف ليكون مقروءاً */
        width: auto;       /* السماح لـ flexbox بالتعامل مع العرض */
    }

    /* تعديلات عامة للمظهر المتجاوب */
    .product-info {
        flex-direction: column;
        text-align: center;
    }
    .product-info img {
        margin-bottom: 10px;
    }
}
