/* assets/css/search.css */

/* -----------------------------------------------------------
   Wheel Tags
----------------------------------------------------------- */
.wheel-tags-wrapper {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wheel-tag {
    display: inline-flex;
    align-items: center;
    background: #d32f2f;
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    overflow: visible; /* critical fix */
    gap: 4px;
}

.wheel-img {
    width: 16px;
    height: 16px;
    display: inline-block;
    object-fit: contain;
}

/* -----------------------------------------------------------
   Main Search Wrapper
   ----------------------------------------------------------- */
.ts-search-wrapper {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 0 auto;
    font-family: inherit;
    direction: rtl;
    padding-bottom: 25px;

    /* تنظیمات حیاتی برای عملکرد صحیح Select2 */
    position: relative;
    overflow: visible !important;
    z-index: 10;
}

/* -----------------------------------------------------------
   Top Main Tabs (سواری / کامیونت)
   ----------------------------------------------------------- */
.ts-main-tabs {
    display: flex;
    background: #f1f1f1;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    overflow: hidden;
}

.ts-main-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f1f1f1;
    color: #555;
    border-bottom: 1px solid #ddd;
}

.ts-main-tab:first-child {
    border-top-right-radius: 15px;
}

.ts-main-tab:last-child {
    border-top-left-radius: 15px;
}

.ts-main-tab.active {
    background: #c60000;
    color: #fff;
    border-bottom-color: #c60000;
}

.ts-main-tab .ts-icon svg {
    width: 28px;
    height: auto;
    margin: 0 8px;
    vertical-align: middle;
    fill: currentColor;
}

.ts-main-tab .ts-text {
    font-size: 16px;
    font-weight: bold;
}

/* -----------------------------------------------------------
   Body & Sub Tabs (نوع خودرو / سایز)
   ----------------------------------------------------------- */
.ts-body {
    padding: 20px 25px;
    background: #fff;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
}

.ts-sub-tabs {
    display: flex;
    justify-content: center;
    border-bottom: 2px solid #eee;
    margin-bottom: 25px;
}

.ts-sub-tab {
    background: none;
    border: none !important;
    padding: 10px 15px;
    font-size: 14px !important;
    font-weight: bold;
    color: #777 !important;
    cursor: pointer;
    position: relative;
    outline: none;
    transition: color 0.3s;
}

.ts-sub-tab:hover {
    color: #000;
    background-color: unset !important;
}

.ts-sub-tab.active {
    color: #000 !important;
    background-color: unset !important;
}

.ts-sub-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: #c60000 !important;
}

/* -----------------------------------------------------------
   Form & Select2 Customization
   ----------------------------------------------------------- */
.ts-form-group {
    margin-bottom: 15px;
}

/* کانتینر اصلی اینپوت سلکت2 */
.select2-container--default .select2-selection--single {
    background-color: #fff;
    border: 2px solid #c60000 !important;
    border-radius: 10px !important;
    height: 48px !important; /* ارتفاع کلی */
    outline: none;
    box-shadow: none;
    display: block; /* برای جلوگیری از باگ بسته شدن */
}

/* متن داخل اینپوت */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #333 !important;
    font-weight: bold;
    font-size: 14px;
    padding-right: 15px !important;
    padding-left: 30px !important;
    padding-top: 3px !important;

    /* تنظیم تراز عمودی متن */
    line-height: 44px !important; /* ارتفاع منهای حاشیه ها (48 - 4) */
    height: 44px !important;

    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* فلش سمت چپ */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
    left: 10px !important;
    right: auto !important; /* RTL */
    width: 20px !important;
    position: absolute !important;
    top: 1px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: #333 transparent transparent transparent !important;
    border-width: 6px 5px 0 5px !important;
    top: 50% !important;
    margin-top: -3px !important;
    left: 50% !important;
    margin-left: -5px !important;
}

/* دراپ‌داون باز شده */
.select2-dropdown {
    border: 2px solid #c60000 !important;
    border-radius: 10px !important;
    z-index: 9999 !important;
    overflow: hidden;
    margin-top: 2px; /* فاصله کم از اینپوت */
}

/* فیلد جستجو داخل دراپ‌داون */
.select2-search--dropdown .select2-search__field {
    border: 1px solid #ccc !important;
    border-radius: 6px !important;
    padding: 6px !important;
    font-family: inherit;
}

/* گزینه‌های لیست */
.select2-results__option {
    padding: 8px 15px !important;
    font-size: 13px;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #c60000 !important; /* قرمز هنگام هاور */
    color: white !important;
}

/* -----------------------------------------------------------
   Submit Button
   ----------------------------------------------------------- */
.ts-submit-wrap {
    margin-top: 25px;
}

.ts-submit-btn {
    width: 100% !important;
    background-color: #c60000 !important;
    color: #fff !important;
    border: none !important;
    padding: 14px !important;
    font-weight: bold !important;
    border-radius: 10px !important;
    cursor: pointer !important;
    transition: background 0.3s, transform 0.1s !important;
    box-shadow: 0 4px 6px rgba(198, 0, 0, 0.2) !important;
}

.ts-submit-btn:hover {
    background-color: #a50000 !important;
}

.ts-submit-btn:active {
    transform: scale(0.98) !important;
}

/* Loading State Styles */

/* کمی شفاف کردن فیلد هنگام لودینگ */
.ts-loading-state .select2-selection {
    opacity: 0.7;
    cursor: wait !important;
    background-color: #f9f9f9 !important;
}

/* اضافه کردن آیکون چرخشی (Spinner) */
.ts-loading-state .select2-selection__rendered::after {
    content: "";
    position: absolute;
    left: 10px; /* موقعیت در سمت چپ فیلد */
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px; /* نصف ارتفاع برای وسط‌چین دقیق */
    border: 2px solid #ccc;
    border-top-color: #d32f2f; /* رنگ قرمز تایرسان */
    border-radius: 50%;
    animation: ts-spin 0.8s linear infinite;
    z-index: 99;
}

/* انیمیشن چرخش */
@keyframes ts-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Full Form Loading Overlay Styles --- */

/* Ensure the wrapper can hold the absolute overlay */
.ts-search-wrapper {
    position: relative;
    /* overflow: hidden; -> Don't use hidden if you want Select2 dropdowns to overflow,
       but for loading overlay inside, relative is enough. */
}

.ts-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.7); /* Semi-transparent white */
    backdrop-filter: blur(2px); /* Modern blur effect */
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 14px; /* Matches your wrapper border-radius */
    animation: ts-fade-in 0.2s ease-in-out;
}

/* Spinner Circle */
.ts-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e5e5;
    border-top: 4px solid #bb0000; /* Tirestan Red */
    border-radius: 50%;
    animation: ts-spin 1s linear infinite;
}

@keyframes ts-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes ts-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}