/* ============================================
   Market Phone Input Component
   مستقل عن أي مكتبة خارجية
   ============================================ */

.market-phone {
    position: relative;
    width: 100%;
    margin-bottom: 0;
}

/* Label */
.market-phone__label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

/* Wrapper around button + input */
.market-phone__control {
    display: flex;
    align-items: stretch;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background-color: #ffffff;
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.market-phone__control:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59,130,246,0.35);
}

/* Country button */
.market-phone__country-btn {
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border: 0;
    background: #f9fafb;
    cursor: pointer;
    outline: none;
    min-width: 90px;
    white-space: nowrap;
    border-inline-end: 1px solid #e5e7eb;

    /* ✅ لا يتمدد */
    flex: 0 0 auto;
}

.market-phone__country-btn:focus {
    outline: none;
}

/* Flag in the button */
.market-phone__flag {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
    margin-inline-end: 6px;
}

/* Dial code in the button */
.market-phone__dial {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
}

/* Small caret */
.market-phone__caret {
    font-size: 10px;
    color: #6b7280;
    margin-inline-start: 4px;
}

/* Input itself */
.market-phone__input {
    flex: 1 1 auto;
    min-width: 0;               /* ✅ مهم جداً لمنع نزول سطر */
    width: 100%;
    border: none;
    outline: none;
    padding: 8px 10px;
    font-size: 14px;
    background: transparent;
}

/* لو استُخدم الكلاس العام */
.js-phone-input {
    flex: 1 1 auto;
    min-width: 0;               /* ✅ مهم جداً لمنع نزول سطر */
    width: 100%;
}

.market-phone__input::placeholder {
    color: #9ca3af;
}

/* Dropdown wrapper */
.market-phone__dropdown {
    position: absolute;
    inset-inline-start: 0;
    inset-inline-end: 0;
    top: 100%;
    margin-top: 4px;
    background: #ffffff;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
    z-index: 40;
    max-height: 260px;
    display: none;
    flex-direction: column;
}

.market-phone__dropdown[hidden] {
    display: none !important;
}

/* Search box inside dropdown */
.market-phone__search {
    padding: 6px;
    border-bottom: 1px solid #e5e7eb;
}

.market-phone__search-input {
    width: 100%;
    border-radius: 4px;
    border: 1px solid #d1d5db;
    padding: 4px 8px;
    font-size: 13px;
}

/* List of countries */
.market-phone__list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.market-phone__item {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    transition: background .12s ease;
}

.market-phone__item:hover {
    background: #f3f4f6;
}

/* Flag in list item */
.market-phone__item-flag {
    width: 20px;
    height: 14px;
    border-radius: 2px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
    margin-inline-end: 6px;
}

/* Country name & dial */
.market-phone__item-name {
    flex: 1;
    color: #111827;
}

.market-phone__item-dial {
    color: #6b7280;
    margin-inline-start: 6px;
    font-weight: 500;
}

/* Scrollbar style */
.market-phone__list::-webkit-scrollbar {
    width: 6px;
}
.market-phone__list::-webkit-scrollbar-thumb {
    background: #c4c4c4;
    border-radius: 3px;
}

/* RTL support */
html[dir="rtl"] .market-phone__country-btn {
    border-inline-end: none;
    border-inline-start: 1px solid #e5e7eb;
}
html[dir="rtl"] .market-phone__flag {
    margin-inline-end: 0;
    margin-inline-start: 6px;
}
html[dir="rtl"] .market-phone__caret {
    margin-inline-start: 0;
    margin-inline-end: 4px;
}
html[dir="rtl"] .market-phone__item-flag {
    margin-inline-end: 0;
    margin-inline-start: 6px;
}

/* ✅ القائمة RTL طبيعي */
html[dir="rtl"] .market-phone__dropdown {
    direction: rtl;
}

/* ======================================
   FINAL: Fix Arabic layout properly
   - نعكس حقل النص فقط في RTL (حقل الرقم)
   - ونثبت السطر بدون نزول
   - ونحمي الأرقام من تداخل bidi
   ====================================== */

/* السطر ثابت */
.market-phone__control {
    flex-wrap: nowrap;
}

/* ✅ بالعربي: حقل الرقم RTL */
html[dir="rtl"] .market-phone__input,
html[dir="rtl"] .js-phone-input {
    direction: rtl;
    text-align: right;
    unicode-bidi: plaintext;
}

/* (اختياري) لو تحب الكود/العلم يبقى على نفس مكانه بدون تقليب */
html[dir="rtl"] .market-phone__control {
    flex-direction: row;
}

/* ======================================
   Optional: Reserve space for extra buttons
   إذا عندك أزرار خارجية فوق حقل الرقم
   (اتركها إذا ما تحتاج)
   ====================================== */
/*
.market-phone-wrap .market-phone__input,
.market-phone-wrap .js-phone-input{
    padding-inline-end: 92px !important;
}
*/
