/* ============================================================
   Live Search Dropdown — CodeKick Academy
   Compatible with both LTR and RTL layouts.
   ============================================================ */

/* ── Wrapper ─────────────────────────────────────────────── */
.ls-wrapper {
    position: relative;
    width: 100%;
}

/* ── Spinner ─────────────────────────────────────────────── */
.ls-spinner {
    display: none;
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: var(--color-primary, #4f46e5);
    border-radius: 50%;
    animation: ls-spin 0.7s linear infinite;
    z-index: 10;
    pointer-events: none;
}
.ls-spinner--active { display: block; }
@keyframes ls-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* RTL spinner position */
body.rtl .ls-spinner { right: auto; left: 12px; }

/* ── Dropdown container ──────────────────────────────────── */
.ls-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}
.ls-dropdown::-webkit-scrollbar { width: 4px; }
.ls-dropdown::-webkit-scrollbar-track { background: transparent; }
.ls-dropdown::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.ls-dropdown--open { display: block; }

/* Dark mode */
.dark-mode .ls-dropdown {
    background: #1e2130;
    border-color: #2d3148;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* ── List reset ──────────────────────────────────────────── */
.ls-dropdown-list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

/* ── Category header ─────────────────────────────────────── */
.ls-category-header {
    padding: 6px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
    user-select: none;
}
.dark-mode .ls-category-header { color: #6b7280; }

/* ── Item ────────────────────────────────────────────────── */
.ls-item {
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.ls-item:hover,
.ls-item--active {
    background: #f3f4f6;
}
.dark-mode .ls-item:hover,
.dark-mode .ls-item--active {
    background: #2d3148;
}

/* ── Item link ───────────────────────────────────────────── */
.ls-item-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    text-decoration: none !important;
    color: #111827;
    flex: 1;
    min-width: 0;
}
.dark-mode .ls-item-link { color: #e5e7eb; }
.ls-item-link:hover { color: inherit; }

/* ── Item image ──────────────────────────────────────────── */
.ls-item-img {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f3f4f6;
}

/* ── Item icon (fallback) ────────────────────────────────── */
.ls-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: #f3f4f6;
    flex-shrink: 0;
    color: #6b7280;
}
.dark-mode .ls-item-icon { background: #374151; color: #9ca3af; }

/* ── Item text block ─────────────────────────────────────── */
.ls-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Item label ──────────────────────────────────────────── */
.ls-item-label {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* ── Item subtitle ───────────────────────────────────────── */
.ls-item-subtitle {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin-top: 2px;
}
.dark-mode .ls-item-subtitle { color: #9ca3af; }

/* ── Highlight matched text ──────────────────────────────── */
.ls-highlight {
    background: transparent;
    color: var(--color-primary, #4f46e5);
    font-weight: 700;
    padding: 0;
}
.dark-mode .ls-highlight { color: #818cf8; }

/* ── No results ──────────────────────────────────────────── */
.ls-no-results {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    color: #6b7280;
    font-size: 14px;
}
.dark-mode .ls-no-results { color: #9ca3af; }

/* ── See all results footer ──────────────────────────────── */
.ls-see-all {
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
}
.dark-mode .ls-see-all { border-color: #2d3148; }
.ls-see-all a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-primary, #4f46e5);
    text-decoration: none !important;
    transition: background 0.15s;
}
.ls-see-all a:hover { background: #f3f4f6; border-radius: 0 0 12px 12px; }
.dark-mode .ls-see-all a { color: #818cf8; }
.dark-mode .ls-see-all a:hover { background: #2d3148; }

/* ── Recent search delete button ────────────────────────── */
.ls-recent-del {
    background: none;
    border: none;
    cursor: pointer;
    color: #9ca3af;
    font-size: 16px;
    line-height: 1;
    padding: 4px 12px;
    flex-shrink: 0;
    transition: color 0.15s;
}
.ls-recent-del:hover { color: #ef4444; }

/* ── RTL adjustments ─────────────────────────────────────── */
body.rtl .ls-item-link { flex-direction: row-reverse; }
body.rtl .ls-item-text { text-align: right; }
body.rtl .ls-see-all a { flex-direction: row-reverse; }
body.rtl .ls-no-results { flex-direction: row-reverse; }
body.rtl .ls-recent-del { margin-right: auto; margin-left: 0; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 576px) {
    .ls-dropdown { max-height: 320px; }
    .ls-item-img,
    .ls-item-icon { width: 30px; height: 30px; }
    .ls-item-label { font-size: 13px; }
}

/* ── Panel / Admin header search box ────────────────────── */
.panel-header-search,
.admin-header-search {
    position: relative;
    width: 260px;
}
.panel-header-search .form-control,
.admin-header-search .form-control {
    padding-right: 36px;
    border-radius: 8px;
}
body.rtl .panel-header-search .form-control,
body.rtl .admin-header-search .form-control {
    padding-right: 12px;
    padding-left: 36px;
}
.panel-header-search .search-icon,
.admin-header-search .search-icon {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    pointer-events: none;
}
body.rtl .panel-header-search .search-icon,
body.rtl .admin-header-search .search-icon {
    right: auto;
    left: 10px;
}
