/* ===================================================
   Custom Select Dropdown Styles
   نسخه: 1.0
   تاریخ: 2025-02-06
   =================================================== */

.custom-select-wrapper {
    position: relative;
}

.custom-select-wrapper .custom-select-box {
    position: relative;
    cursor: pointer;
}

.custom-select-wrapper .selected-display {
    padding: 0.45rem 0.75rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background: white;
    min-height: 38px;
    display: flex;
    align-items: center;
    transition: border-color 0.2s;
}

.custom-select-wrapper .selected-display:hover {
    border-color: #adb5bd;
}

.custom-select-wrapper .custom-select-box.active .selected-display {
    border-color: #3b82f6;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.2);
}

.custom-select-wrapper .placeholder-text {
    color: #999;
}

.custom-select-wrapper .dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d0d7de;
    border-radius: 8px;
    margin-top: 6px;
    z-index: 1050;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    overflow: hidden;
}

.custom-select-wrapper .custom-select-box.active .dropdown-content {
    display: block;
}

.custom-select-wrapper .search-box {
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
    position: relative;
    background: #f8f9fa;
}

.custom-select-wrapper .search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.custom-select-wrapper .search-box input {
    padding-left: 32px;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.custom-select-wrapper .search-box input:focus {
    outline: none;
    border-color: #4c9aff;
}

.custom-select-wrapper .options-container {
    overflow-y: auto;
}

.custom-select-wrapper .option-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #e9ecef;
}

.custom-select-wrapper .option-item:last-child {
    border-bottom: none;
}

.custom-select-wrapper .option-item:hover {
    background: #f0f7ff;
}

.custom-select-wrapper .option-item.selected {
    background: #dbeafe;
}

.custom-select-wrapper .option-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.custom-select-wrapper .option-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Hide icon when icon-type="none" is set on the tag helper */
.custom-select-wrapper.no-icon .option-icon {
    display: none;
}

.custom-select-wrapper .option-details {
    flex: 1;
    min-width: 0;
}

.custom-select-wrapper .option-title {
    font-weight: 500;
    font-size: 0.9rem;
    color: #1e293b;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-wrapper .option-subtitle {
    font-size: 0.85em;
    color: #666;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.custom-select-wrapper .option-subtitle span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.custom-select-wrapper .option-subtitle i {
    font-size: 0.9em;
}

/* Multi-Select Checkbox */
.custom-select-wrapper .option-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    flex-shrink: 0;
    transition: all 0.2s;
}

.custom-select-wrapper .option-item.selected .option-checkbox {
    background: #2196F3;
    border-color: #2196F3;
    color: white;
}

/* Selected Tags (Multi-Select) */
.custom-select-wrapper .selected-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #e3f2fd;
    border-radius: 16px;
    font-size: 0.9em;
}

.custom-select-wrapper .selected-tag .remove-tag {
    cursor: pointer;
    color: #666;
    font-weight: bold;
    font-size: 1.2em;
    line-height: 1;
    transition: color 0.2s;
}

.custom-select-wrapper .selected-tag .remove-tag:hover {
    color: #f44336;
}

/* Scrollbar Styling */
.custom-select-wrapper .options-container::-webkit-scrollbar {
    width: 8px;
}

.custom-select-wrapper .options-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.custom-select-wrapper .options-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.custom-select-wrapper .options-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* RTL Support */
[dir="rtl"] .search-box i {
    left: auto;
    right: 16px;
}

[dir="rtl"] .search-box input {
    padding-left: 12px;
    padding-right: 32px;
}

/* Responsive */
@media (max-width: 768px) {
    .dropdown-content {
        position: fixed;
        top: auto !important;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
    }

    .options-container {
        max-height: 60vh !important;
    }
}

/* ===================================================
   AJAX Select Styles (اضافه شده برای AJAX Support)
   =================================================== */

.custom-select-ajax-wrapper {
    position: relative;
}

.custom-select-ajax-box {
    position: relative;
    cursor: pointer;
}

.custom-select-ajax-box.active .dropdown-content {
    display: block;
}

.ajax-results-container {
    padding: 0;
}

.ajax-result-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 0;
    margin-bottom: 0;
    border-bottom: 1px solid #e9ecef;
}

.ajax-result-item:last-child {
    border-bottom: none;
}

.ajax-result-item:hover {
    background: #f0f7ff;
}

.ajax-result-item.selected {
    background: #dbeafe;
    border-bottom: 1px solid #e9ecef;
}

.ajax-result-item .option-content {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ⭐⭐⭐ Checkbox for AJAX items */
.ajax-result-item .option-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    flex-shrink: 0;
    transition: all 0.2s;
}

.ajax-result-item.selected .option-checkbox {
    background: #2196F3;
    border-color: #2196F3;
    color: white;
}

.ajax-result-item.selected .option-checkbox i {
    opacity: 1;
}

/* ⭐⭐⭐ Bulk Actions Bar (داخل Custom Select) - با scope محدود */
.custom-select-ajax-box .bulk-actions-bar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.custom-select-ajax-box .btn-bulk-action {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.875rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.custom-select-ajax-box .btn-bulk-action:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.custom-select-ajax-box .btn-bulk-action:active {
    transform: scale(0.98);
}

.custom-select-ajax-box .btn-bulk-action i {
    font-size: 0.875rem;
}

.custom-select-ajax-box .btn-select-all-ajax {
    border-color: #0d6efd;
    color: #0d6efd;
}

.custom-select-ajax-box .btn-select-all-ajax:hover {
    background: #0d6efd;
    color: white;
}

.custom-select-ajax-box .btn-clear-all-ajax {
    border-color: #6c757d;
    color: #6c757d;
}

.custom-select-ajax-box .btn-clear-all-ajax:hover {
    background: #6c757d;
    color: white;
}

/* Loading Animation */
.ajax-results-container .fa-spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
