/**
 * حقل الجوال الموحّد — مصدر CSS الوحيد (signup, profile, …)
 */

.phone-field-unified-wrap {
    position: relative;
    z-index: 1;
}

.phone-field-unified-wrap.is-country-open {
    z-index: 1060;
}

.phone-field-unified-wrap.is-country-open .phone-field-unified {
    overflow: visible;
}

/* لوحة الدول داخل الغلاف (نمط التسجيل والنماذج) — تُثبَّت عبر JS عند الفتح */
.phone-field-unified-wrap .phone-country-sheet {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    min-height: 280px;
    z-index: 20;
}

.phone-field-unified-wrap .phone-country-sheet.phone-country-sheet--floating {
    position: fixed;
    inset: auto;
    top: var(--sheet-top, auto);
    bottom: var(--sheet-bottom, auto);
    left: var(--sheet-left, 0);
    width: var(--sheet-width, 100%);
    min-height: 0;
    max-height: var(--sheet-max-height, 400px);
    z-index: 1065;
    border-radius: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
    transform: translateY(6px);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease, visibility 0.22s;
}

.phone-field-unified-wrap .phone-country-sheet.phone-country-sheet--floating.show {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* لوحة الدول تغطي نافذة الربط بالكامل */
.phone-modal-content {
    position: relative;
}

.phone-modal-content.is-country-open {
    z-index: 1;
}

.phone-modal-content > .phone-country-sheet {
    position: absolute;
    inset: 0;
    z-index: 25;
    border-radius: 20px;
    min-height: 100%;
}

.phone-field-unified {
    display: flex;
    align-items: stretch;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.phone-field-unified:focus-within {
    border-color: #0089BF;
    box-shadow: 0 0 0 4px rgba(0, 137, 191, 0.1);
}

.phone-field-unified.is-invalid,
.phone-field-unified-wrap.is-invalid .phone-field-unified {
    border-color: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.08);
}

.phone-field-country {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
    border: none;
    background: #f8fafc;
    flex-shrink: 0;
    width: 160px;
    max-width: 42%;
    cursor: pointer;
    transition: background 0.15s ease;
}

.phone-field-country:hover {
    background: #f1f5f9;
}

.phone-field-country[aria-expanded="true"] {
    background: #e0f2fe;
}

.phone-field-flag {
    width: 28px;
    height: 20px;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
}

.phone-field-flag img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.phone-field-country-meta {
    text-align: start;
    min-width: 0;
    line-height: 1.2;
}

.phone-field-country-name {
    display: block;
    font-size: 0.625rem;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

.phone-field-country-code {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: #01305F;
    direction: ltr;
    line-height: 1.15;
}

.phone-field-chevron {
    font-size: 0.75rem;
    color: #94a3b8;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.phone-field-country[aria-expanded="true"] .phone-field-chevron {
    transform: rotate(180deg);
    color: #0089BF;
}

.phone-field-divider {
    width: 1px;
    background: #e2e8f0;
    flex-shrink: 0;
}

.phone-field-input {
    flex: 1;
    min-width: 0;
    border: none;
    padding: 0.85rem 1rem;
    font-size: 1.0625rem;
    font-weight: 600;
    color: #01305F;
    background: transparent;
    direction: ltr;
    text-align: left;
}

.phone-field-input:focus {
    outline: none;
    box-shadow: none;
}

.phone-field-input::placeholder {
    color: #cbd5e1;
    font-weight: 500;
}

.phone-country-sheet {
    background: #fff;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.3s;
}

.phone-country-sheet.show {
    transform: translateY(0);
    visibility: visible;
}

.phone-country-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.15rem 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.phone-country-sheet-header h6 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: #01305F;
}

.phone-country-sheet-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease;
}

.phone-country-sheet-close:hover {
    background: #e2e8f0;
    color: #01305F;
}

.phone-country-search {
    padding: 0.75rem 1.15rem;
    flex-shrink: 0;
}

.phone-country-search-inner {
    position: relative;
}

.phone-country-search-inner i {
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.phone-country-search input {
    width: 100%;
    padding: 0.7rem 2.25rem 0.7rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.875rem;
    background: #f8fafc;
}

html[dir="rtl"] .phone-country-search input {
    text-align: right;
    direction: rtl;
}

html[dir="ltr"] .phone-country-search input {
    text-align: left;
    direction: ltr;
}

.phone-country-search input:focus {
    outline: none;
    border-color: #0089BF;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 137, 191, 0.1);
}

.phone-country-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 1rem;
    -webkit-overflow-scrolling: touch;
}

.phone-field-unified-wrap .phone-country-list {
    max-height: none;
    flex: 1;
    min-height: 0;
}

.phone-country-sheet.phone-country-sheet--floating .phone-country-list {
    max-height: calc(var(--sheet-max-height, 400px) - 7.5rem);
}

.phone-country-list {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.phone-country-list::-webkit-scrollbar {
    width: 6px;
}

.phone-country-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 999px;
}

.phone-country-list::-webkit-scrollbar-track {
    background: transparent;
}

.phone-modal-content > .phone-country-sheet .phone-country-list {
    max-height: none;
}

.phone-country-group-label {
    padding: 0.5rem 0.65rem 0.35rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.03em;
}

.phone-country-item {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.65rem 0.75rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

html[dir="rtl"] .phone-country-item {
    text-align: right;
    direction: rtl;
}

html[dir="ltr"] .phone-country-item {
    text-align: left;
    direction: ltr;
}

.phone-country-item:hover,
.phone-country-item:focus {
    background: #f0f9ff;
    outline: none;
}

.phone-country-item.selected {
    background: linear-gradient(135deg, rgba(0, 137, 191, 0.1) 0%, rgba(1, 48, 95, 0.06) 100%);
}

.phone-country-item img {
    width: 28px;
    height: 20px;
    border-radius: 4px;
    object-fit: cover;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.phone-country-item-body {
    flex: 1;
    min-width: 0;
}

.phone-country-item-name {
    display: block;
    font-size: 0.875rem;
    font-weight: 700;
    color: #01305F;
}

.phone-country-item-code {
    font-size: 0.8125rem;
    color: #64748b;
    direction: ltr;
    display: inline-block;
}

.phone-country-item-check {
    color: #0089BF;
    font-size: 1.125rem;
    opacity: 0;
    flex-shrink: 0;
}

.phone-country-item.selected .phone-country-item-check {
    opacity: 1;
}

.phone-country-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.875rem;
}
