/* ============================================================================
 * city_picker.css
 * ----------------------------------------------------------------------------
 * تنسيق dropdown اختيار المدينة الذي ينسدل من الشريط العلوي.
 * يستخدم نفس نمط Glassmorphism الموجود في topbar.css و style.css.
 * ============================================================================
 */

/* ----------- زر الـ slot-city (إعدادات إضافية لجعله يبدو كزر) ---------- */
.khaliq-topbar .slot-city {
    cursor: pointer;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 4px 10px;
    color: inherit;
    font: inherit;
    transition: background 0.18s, border-color 0.18s, transform 0.12s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.khaliq-topbar .slot-city:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(120, 140, 180, 0.25);
}

.khaliq-topbar .slot-city:active {
    transform: translateY(1px);
}

.khaliq-topbar .slot-city[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.30);
    border-color: rgba(120, 140, 180, 0.40);
}

.cp-caret {
    font-size: 0.72em;
    opacity: 0.65;
    transition: transform 0.2s;
}

.khaliq-topbar .slot-city[aria-expanded="true"] .cp-caret {
    transform: rotate(180deg);
}

/* ---------- حاوية الـ Dropdown ---------- */
.cp-dropdown {
    position: fixed;
    top: 62px; /* خلف الشريط العلوي (56px) + 6px فجوة */
    right: 50%;
    transform: translateX(50%);
    width: min(420px, calc(100vw - 24px));
    max-height: calc(100vh - 80px);
    background: var(--main-bg-glass, rgba(255, 255, 255, 0.95));
    backdrop-filter: blur(14px) saturate(160%);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    border: 1px solid rgba(120, 140, 180, 0.25);
    border-radius: 14px;
    box-shadow:
        0 16px 48px rgba(20, 30, 60, 0.20),
        0 4px 14px rgba(20, 30, 60, 0.08);
    z-index: 100;
    overflow: hidden;
    animation: cp-fade-in 0.18s ease-out;
}

.cp-dropdown[hidden] {
    display: none;
}

@keyframes cp-fade-in {
    from {
        opacity: 0;
        transform: translateX(50%) translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(50%) translateY(0);
    }
}

.cp-dropdown-inner {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
}

/* ---------- مربع البحث ---------- */
.cp-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.cp-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted, #8a96b1);
    font-size: 0.95em;
    pointer-events: none;
}

.cp-search-input {
    width: 100%;
    padding: 10px 38px 10px 40px;
    border: 1px solid rgba(120, 140, 180, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.65);
    color: var(--text-main, #2c3a5a);
    font: inherit;
    font-size: 1rem;
    direction: rtl;
    transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.cp-search-input:focus {
    outline: none;
    border-color: rgba(40, 110, 220, 0.55);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 3px rgba(40, 110, 220, 0.15);
}

.cp-close-btn {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.5em;
    line-height: 1;
    color: var(--text-muted, #8a96b1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.cp-close-btn:hover {
    background: rgba(200, 60, 60, 0.10);
    color: #c83c3c;
}

/* ---------- قائمة النتائج ---------- */
.cp-results,
.cp-recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cp-results[hidden],
.cp-recent-list[hidden] {
    display: none;
}

.cp-result-item,
.cp-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-main, #2c3a5a);
    font-size: 0.95rem;
    transition: background 0.13s;
    border: 1px solid transparent;
}

.cp-result-item:hover,
.cp-recent-item:hover,
.cp-result-item.cp-active,
.cp-recent-item.cp-active {
    background: rgba(40, 110, 220, 0.10);
    border-color: rgba(40, 110, 220, 0.20);
}

.cp-result-item i,
.cp-recent-item i {
    color: rgba(40, 110, 220, 0.75);
    font-size: 0.85em;
    width: 16px;
    text-align: center;
}

.cp-result-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cp-result-meta {
    font-size: 0.78em;
    color: var(--text-muted, #8a96b1);
    opacity: 0.85;
}

.cp-recent-current {
    font-size: 0.75em;
    color: rgba(40, 110, 220, 0.85);
    background: rgba(40, 110, 220, 0.12);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ---------- العناوين والحالات الفارغة ---------- */
.cp-section-title {
    font-size: 0.85em;
    color: var(--text-muted, #8a96b1);
    margin: 0 0 6px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.cp-empty {
    text-align: center;
    color: var(--text-muted, #8a96b1);
    font-size: 0.9em;
    padding: 12px;
    opacity: 0.75;
}

.cp-loading {
    text-align: center;
    color: var(--text-muted, #8a96b1);
    font-size: 0.88em;
    padding: 10px;
    opacity: 0.7;
}

/* ---------- الوضع الليلي ---------- */
[data-theme="dark"] .cp-dropdown {
    background: rgba(30, 38, 58, 0.92);
    border-color: rgba(120, 140, 180, 0.20);
}

[data-theme="dark"] .cp-search-input {
    background: rgba(20, 28, 48, 0.65);
    color: #e3e8f1;
    border-color: rgba(120, 140, 180, 0.25);
}

[data-theme="dark"] .cp-search-input:focus {
    background: rgba(20, 28, 48, 0.85);
}

[data-theme="dark"] .cp-result-item,
[data-theme="dark"] .cp-recent-item {
    color: #e3e8f1;
}

[data-theme="dark"] .cp-result-item:hover,
[data-theme="dark"] .cp-recent-item:hover,
[data-theme="dark"] .cp-result-item.cp-active,
[data-theme="dark"] .cp-recent-item.cp-active {
    background: rgba(80, 140, 240, 0.18);
    border-color: rgba(80, 140, 240, 0.30);
}

[data-theme="dark"] .khaliq-topbar .slot-city:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(120, 140, 180, 0.20);
}

[data-theme="dark"] .khaliq-topbar .slot-city[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(120, 140, 180, 0.30);
}

/* ---------- استجابة الموبايل ---------- */
@media (max-width: 540px) {
    .cp-dropdown {
        top: 60px;
        right: 8px;
        left: 8px;
        transform: none;
        width: auto;
    }

    @keyframes cp-fade-in {
        from {
            opacity: 0;
            transform: translateY(-8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ============================================================================
 * زر "موقعي" — ثابت أعلى القائمة
 * ============================================================================ */
.cp-mylocation-wrap {
    margin: 8px 0 12px 0;
    padding: 0 2px;
}

.cp-mylocation-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(40, 110, 220, 0.25);
    border-radius: 10px;
    background: rgba(40, 110, 220, 0.08);
    color: var(--text-main, #2c3a5a);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease, border-color 0.15s ease;
    font-family: inherit;
}

.cp-mylocation-btn:hover:not(:disabled) {
    background: rgba(40, 110, 220, 0.16);
    border-color: rgba(40, 110, 220, 0.40);
}

.cp-mylocation-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.cp-mylocation-btn:disabled,
.cp-mylocation-btn.is-busy {
    opacity: 0.65;
    cursor: progress;
}

.cp-mylocation-btn i {
    color: rgba(40, 110, 220, 0.85);
    font-size: 0.95em;
}

.cp-mylocation-btn.is-busy i {
    animation: cp-spin 1s linear infinite;
}

@keyframes cp-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.cp-mylocation-msg {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
}

.cp-mylocation-msg[data-tone="info"]    { background: rgba(40, 110, 220, 0.10); color: var(--text-main, #2c3a5a); }
.cp-mylocation-msg[data-tone="success"] { background: rgba(56, 161, 105, 0.15);  color: #1f7a4a; }
.cp-mylocation-msg[data-tone="error"]   { background: rgba(211, 47, 47, 0.12);   color: #b3261e; }
