/**
 * Portal Tom Select RTL Theme & Custom Overrides
 * البوابة الرقمية للقباب الصغرى
 */

.ts-wrapper.rtl,
.ts-wrapper.form-control {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

.ts-control {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    border-radius: 6px !important;
    border: 1px solid #ced4da !important;
    min-height: 40px !important;
    padding: 6px 12px 6px 36px !important;
    background-color: #ffffff !important;
    color: #2d3748 !important;
    font-size: 0.92rem !important;
    box-shadow: none !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

.ts-wrapper.focus .ts-control {
    border-color: #17528e !important;
    box-shadow: 0 0 0 0.2rem rgba(23, 82, 142, 0.2) !important;
}

.ts-wrapper.is-invalid .ts-control {
    border-color: #dc3545 !important;
}

/* Custom Dropdown Arrow for RTL */
.ts-wrapper::after {
    left: 12px !important;
    right: auto !important;
}

/* Dropdown Menu */
.ts-dropdown {
    direction: rtl !important;
    text-align: right !important;
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    border-radius: 6px !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1) !important;
    margin-top: 4px !important;
    font-size: 0.9rem !important;
    z-index: 1050 !important;
}

.ts-dropdown .active {
    background-color: #e8f0fe !important;
    color: #17528e !important;
    font-weight: 600 !important;
}

.ts-dropdown .option {
    padding: 8px 14px !important;
    border-bottom: 1px solid #f1f5f9;
}

.ts-dropdown .option:last-child {
    border-bottom: none;
}

/* Rich Option Items */
.ts-option-rich {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.ts-option-title {
    font-weight: 600;
    color: #1e293b;
    word-break: break-word;
}

.ts-option-subtitle {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 2px;
    word-break: break-word;
}

.ts-option-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: #f1f5f9;
    color: #475569;
    font-weight: normal;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
}

/* Clear Button */
.ts-wrapper .clear-button {
    left: 28px !important;
    right: auto !important;
    color: #94a3b8 !important;
}

.ts-wrapper .clear-button:hover {
    color: #dc3545 !important;
}

/* Dropdown scrolling on touch devices */
.ts-dropdown .ts-dropdown-content {
    max-height: 260px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Touch Optimization */
@media (max-width: 767.98px) {
    .ts-control {
        min-height: 44px !important;
        font-size: 1rem !important;
    }

    .ts-dropdown .option {
        padding: 10px 14px !important;
        min-height: 44px !important;
    }
}

/* Graceful Fallback for No-JS */
.no-js .tom-select-enhanced,
noscript select {
    display: block !important;
}

