/**
 * مودال جستجو و فیلتر شهر - نسخه شیشه‌ای
 * ✅ افزایش ارتفاع مودال برای مشاهده بهتر نتایج
 * ✅ رفع باگ نمایش نتایج
 * ✅ بهبود UX در موبایل
 * 
 * @package SadTik\Modules\SearchModal
 * @version 7.6.5
 */

/* ============================================================
   ✅ فونت‌ها توسط Font Manager متمرکز بارگذاری می‌شوند
   ============================================================ */

/* --- نسخه 7.6.5: افزایش ارتفاع، رفع باگ نتایج --- */

/* 1. Reset Fonts: استفاده از فونت پیش‌فرض المنتور */
.tik100-modal-content, 
.tik100-modal-content input, 
.tik100-modal-content select, 
.tik100-modal-content button,
.tik100-modal-content span,
.tik100-modal-content div,
.tik100-modal-content h3,
.tik100-modal-content h4 {
    font-family: inherit;
    box-sizing: border-box;
}

.glass-banking-theme {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 50, 100, 0.2);
    padding: 0;
    overflow: hidden;
    width: 95%;
    max-width: 480px;
    margin: 3% auto; /* کاهش margin برای ارتفاع بیشتر */
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 92vh; /* افزایش حداکثر ارتفاع */
}

/* Header Settings */
.modal-header-glass {
    padding: 20px 25px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: #fff;
    border-bottom: 1px solid #f2f2f2;
    position: relative;
    min-height: 70px;
    flex-shrink: 0; /* جلوگیری از کوچک شدن هدر */
}

.header-titles {
    text-align: right;
    padding-left: 45px;
}
.header-titles h3 { margin: 0 0 4px; font-size: 17px; color: #00244B; font-weight: 800; }
.header-titles .sub-title { font-size: 12px; color: #777; display: block; }

/* دکمه خروج: طلایی و سمت چپ */
.close-modal-glass {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #FFC107 0%, #FF9800 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 4px 10px rgba(255, 193, 7, 0.4);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10;
    border: none;
}

.close-modal-glass:hover { 
    transform: translateY(-50%) rotate(90deg) scale(1.1); 
    box-shadow: 0 6px 15px rgba(255, 193, 7, 0.6);
}

.close-modal-glass:focus-visible {
    outline: 2px solid #00244B;
    outline-offset: 2px;
}

/* ============================================
   ✅ افزایش ارتفاع بخش جستجو
   ============================================ */
.search-body { 
    padding: 20px 25px 10px; 
    flex-shrink: 0; 
    background: #fff;
}

/* --- Inputs & Filters --- */
.glass-input-wrapper { position: relative; margin-bottom: 15px; }

.glass-input-wrapper input {
    width: 100%;
    height: 55px;
    padding: 10px 15px 10px 50px;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 10px;
    font-size: 15px;
    color: #333;
    transition: 0.3s;
    font-weight: 500;
    font-family: inherit;
}

.glass-input-wrapper input:focus {
    border-color: #0373ec;
    outline: none;
    box-shadow: 0 0 0 3px rgba(3, 115, 236, 0.12);
}

.glass-input-wrapper input::placeholder {
    color: #a0a0a0;
}

.input-icon-left {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #0373ec;
    font-size: 22px;
    pointer-events: none;
    font-weight: bold;
}

/* Dropdowns */
.glass-select-wrapper {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    height: 48px;
    padding: 0 10px;
    position: relative;
    margin-bottom: 10px;
}

.select-label { 
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    margin-left: 10px;
}

.glass-select-wrapper select {
    width: 100%;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    color: #333;
    font-weight: 700;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-left: 20px;
    font-family: inherit;
}

.glass-select-wrapper select:focus {
    outline: 2px solid #0373ec;
    outline-offset: 2px;
}

.select-arrow {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #333;
    font-size: 12px;
    pointer-events: none;
}

/* --- Custom City Selector --- */
.custom-city-selector {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    padding: 12px;
    position: relative;
    min-height: 48px;
}

.selector-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.selector-head .label-text { 
    font-size: 12px;
    color: #444;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}

.selector-head .action-icon {
    color: #0044bb;
    font-size: 14px;
    font-weight: bold;
}

/* Tags Area */
.selected-tags-area {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 5px;
}

.selected-tags-area:empty { margin-top: 0; }

.placeholder-text {
    font-size: 11px;
    color: #bbb;
    margin-top: 2px;
    display: block;
}

.city-tag {
    background: #eef4ff;
    color: #0044bb;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
}

.remove-tag-btn {
    color: #ff6b6b;
    cursor: pointer;
    font-size: 12px;
    background: none;
    border: none;
    padding: 0;
}

.remove-tag-btn:hover {
    color: #dc2626;
}

.remove-tag-btn:focus-visible {
    outline: 2px solid #ff6b6b;
    outline-offset: 2px;
}

/* Dropdown Panel - افزایش ارتفاع */
.city-dropdown-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    z-index: 100;
    margin-top: 5px;
    padding: 10px;
    display: none;
    max-height: 250px; /* افزایش ارتفاع */
    overflow: hidden;
}

.city-dropdown-panel.active { display: block; }

.dropdown-search-box input {
    width: 100%;
    height: 35px;
    border: 1px solid #eee;
    background: #f9f9f9;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 12px;
    margin-bottom: 8px;
    font-family: inherit;
}

.dropdown-search-box input:focus {
    border-color: #0373ec;
    outline: none;
}

.city-options-list {
    max-height: 180px;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
}

.province-group-wrapper { margin-bottom: 5px; }

.opt-group-label {
    background: #f8f8f8;
    padding: 5px 10px;
    font-size: 11px;
    color: #666;
    font-weight: bold;
    margin-bottom: 2px;
    border-radius: 4px;
    position: sticky;
    top: 0;
    z-index: 1;
}

.city-item {
    padding: 8px 10px;
    font-size: 12px;
    border-bottom: 1px solid #fcfcfc;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    color: #555;
}

.city-item:hover { background: #f0f7ff; color: #0044bb; }

.city-item.selected { 
    color: #0044bb;
    font-weight: bold;
    background: #f0f7ff;
}

.city-item .check-icon { display: none; }
.city-item.selected .check-icon { display: block; font-size: 10px; }

/* ============================================
   ✅ افزایش ارتفاع بخش نتایج - رفع باگ اصلی
   ============================================ */
.results-scroll-area {
    background: #fbfbfd;
    flex: 1 1 auto; /* رشد خودکار */
    overflow-y: auto;
    padding: 15px 25px;
    border-top: 1px solid #f2f2f2;
    min-height: 150px; /* حداقل ارتفاع */
    max-height: 400px; /* حداکثر ارتفاع برای اسکرول */
}

/* رفع باگ نمایش نتایج */
.results-scroll-area .tik100-results-list {
    min-height: 100px;
}

.results-header-styled {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8faff;
    border-radius: 12px;
}

.count-badge {
    background: #0044bb;
    color: #fff;
    width: auto;
    min-width: 30px;
    height: 30px;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

.results-header-styled .text {
    font-size: 13px;
    color: #777;
    font-weight: 500;
}

/* Item Card */
.tik100-result-item { 
    margin-bottom: 12px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tik100-result-item a {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    transition: all 0.2s;
    text-decoration: none;
    border: 1px solid #ffde59;
    position: relative;
    overflow: hidden;
}

.tik100-result-item a:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.06);
}

.tik100-result-item a:focus-visible {
    outline: 2px solid #0373ec;
    outline-offset: 2px;
}

/* حالت VIP */
.tik100-result-item.is-vip-item a {
    border: 1px solid #ffde59;
    box-shadow: 0 4px 15px rgba(255, 222, 89, 0.15);
}

/* حالت معمولی */
.tik100-result-item:not(.is-vip-item) a {
    border: 1px solid #eee;
}

/* Image Style */
.result-thumb-box {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.res-img {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: cover;
    background: #f0f0f0;
}

/* VIP Icon: Bolt */
.vip-bolt-circle {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    background: #ffb300;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    border: 2px solid #fff;
    z-index: 2;
}

/* Info */
.result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-title {
    margin: 0;
    font-size: 14px;
    font-weight: 800;
    color: #222;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.result-excerpt {
    font-size: 11px;
    color: #888;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 2px;
}

.result-cat-btn {
    font-size: 11px;
    background: #eef2ff;
    color: #0044bb;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    border: none;
}

.result-city {
    font-size: 11px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
}

/* Loading */
.glass-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: #0044bb;
    border-radius: 50%;
    margin: 0 auto 10px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-state, .initial-msg, .no-result {
    text-align: center;
    margin-top: 30px;
    color: #aaa;
    font-size: 13px;
}

.empty-state-img {
    font-size: 40px;
    margin-bottom: 10px;
    opacity: 0.2;
    color: #0044bb;
}

/* ============================================
   ✅ رفع باگ: پیام‌های خطا و خالی
   ============================================ */
.error-msg {
    text-align: center;
    padding: 20px;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 12px;
    margin: 10px 0;
}

.error-msg i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.no-result {
    text-align: center;
    padding: 30px 20px;
    color: #999;
}

.no-result i {
    font-size: 36px;
    display: block;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* ============================================
   ✅ دسترسی پذیری - کاهش انیمیشن
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .glass-spinner {
        animation: none;
        border-top-color: transparent;
    }
    
    .close-modal-glass:hover {
        transform: translateY(-50%);
    }
    
    .tik100-result-item a:hover {
        transform: none;
    }
}

/* ============================================
   ✅ ریسپانسیو موبایل - اصلاحات ویژه
   ============================================ */
@media screen and (max-width: 600px) {
    /* اصلاح نمایش موبایل: باکس شناور و گوشه‌دار */
    .glass-banking-theme {
        width: 95% !important;
        height: auto !important;
        margin: 2vh auto !important;
        border-radius: 20px !important;
        max-height: 90vh !important;
        top: auto;
        left: auto;
        right: auto;
        bottom: auto;
    }
    
    /* افزایش ارتفاع بخش نتایج در موبایل */
    .results-scroll-area {
        max-height: 300px; /* ارتفاع مناسب موبایل */
        min-height: 120px;
        padding-bottom: 20px;
    }
    
    .modal-header-glass {
        padding: 15px 20px;
        min-height: 60px;
    }
    
    .header-titles h3 {
        font-size: 15px;
    }
    
    .close-modal-glass {
        width: 32px;
        height: 32px;
        font-size: 14px;
        left: 15px;
    }
    
    .search-body {
        padding: 15px 20px 10px;
    }
    
    .glass-input-wrapper input {
        height: 48px;
        font-size: 14px;
        padding: 8px 12px 8px 45px;
    }
    
    .input-icon-left {
        font-size: 18px;
        left: 12px;
    }
    
    .result-title {
        font-size: 13px;
    }
    
    .result-thumb-box {
        width: 56px;
        height: 56px;
    }
    
    /* دراپ‌داون شهر در موبایل */
    .city-dropdown-panel {
        max-height: 200px;
        position: fixed;
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 10px;
        border-radius: 16px;
        max-height: 60vh;
        box-shadow: 0 -5px 30px rgba(0,0,0,0.15);
    }
    
    .city-options-list {
        max-height: 40vh;
    }
    
    /* بهبود فاصله‌ها */
    .tik100-result-item {
        margin-bottom: 10px;
    }
    
    .tik100-result-item a {
        padding: 10px;
        gap: 12px;
    }
}

/* ============================================
   ✅ بهبود برای صفحه‌های کوچکتر
   ============================================ */
@media screen and (max-width: 400px) {
    .glass-banking-theme {
        width: 98% !important;
        margin: 1vh auto !important;
        border-radius: 16px !important;
        max-height: 95vh !important;
    }
    
    .results-scroll-area {
        max-height: 250px;
        padding: 12px 15px;
    }
    
    .search-body {
        padding: 12px 15px 8px;
    }
    
    .modal-header-glass {
        padding: 12px 15px;
        min-height: 50px;
    }
    
    .header-titles h3 {
        font-size: 14px;
    }
    
    .header-titles .sub-title {
        font-size: 10px;
    }
    
    .close-modal-glass {
        width: 28px;
        height: 28px;
        font-size: 12px;
        left: 10px;
    }
}