/* ========================================
   Global Search — Ctrl+K Spotlight
   ======================================== */

/* Overlay */
.cx-search-overlay {
    position: fixed; inset: 0; z-index: 100000;
    background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: flex-start; justify-content: center;
    padding-top: 12vh;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
    font-family: 'Tajawal', sans-serif; direction: rtl;
}
.cx-search-overlay.open {
    opacity: 1; pointer-events: auto;
}

/* Modal */
.cx-search-modal {
    width: 92%; max-width: 620px;
    background: rgba(15,23,42,0.98);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    overflow: hidden;
    transform: translateY(-20px) scale(0.96);
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
}
.cx-search-overlay.open .cx-search-modal {
    transform: translateY(0) scale(1);
}

/* Header / Input */
.cx-search-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.cx-search-icon {
    color: var(--primary-light, #818cf8); font-size: 1.1rem; flex-shrink: 0;
}
.cx-search-input {
    flex: 1; background: none; border: none; outline: none;
    font-size: 1.05rem; font-family: 'Tajawal', sans-serif;
    color: #fff; caret-color: #6366f1;
}
.cx-search-input::placeholder { color: rgba(255,255,255,0.3); }
.cx-search-kbd {
    padding: 3px 8px; border-radius: 6px;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.4); font-size: 0.68rem;
    font-family: 'Tajawal', monospace; flex-shrink: 0;
}

/* Results */
.cx-search-results {
    max-height: 400px; overflow-y: auto;
    padding: 8px;
}
.cx-search-results::-webkit-scrollbar { width: 4px; }
.cx-search-results::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Empty state */
.cx-search-empty {
    text-align: center; padding: 32px 16px;
}
.cx-search-empty-icon {
    font-size: 2rem; margin-bottom: 12px; color: rgba(255,255,255,0.15);
}
.cx-search-empty-text {
    font-size: 0.9rem; color: rgba(255,255,255,0.4); margin-bottom: 12px;
}
.cx-search-empty-hint {
    font-size: 0.78rem; color: rgba(255,255,255,0.25);
}
.cx-search-shortcuts {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    margin-top: 4px;
}
.cx-search-shortcuts span {
    font-size: 0.72rem; color: rgba(255,255,255,0.3);
    display: flex; align-items: center; gap: 4px;
}
.cx-search-shortcuts kbd {
    padding: 2px 6px; border-radius: 4px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
    font-size: 0.65rem; font-family: monospace;
}

/* Result item */
.cx-search-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; border-radius: 12px;
    text-decoration: none; color: inherit;
    transition: all 0.15s; cursor: pointer;
    margin-bottom: 2px;
}
.cx-search-item:hover, .cx-search-item.active {
    background: rgba(99,102,241,0.1);
}
.cx-search-item-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; background: rgba(255,255,255,0.04); flex-shrink: 0;
}
.cx-search-item-text { flex: 1; min-width: 0; }
.cx-search-item-title {
    font-size: 0.88rem; font-weight: 600; color: var(--white, #fff);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cx-search-item-title mark {
    background: rgba(99,102,241,0.3); color: #fff; border-radius: 2px; padding: 0 2px;
}
.cx-search-item-desc {
    font-size: 0.72rem; color: var(--gray, #94a3b8);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    margin-top: 1px;
}
.cx-search-item-type {
    font-size: 0.62rem; font-weight: 700;
    padding: 3px 8px; border-radius: 6px;
    white-space: nowrap; flex-shrink: 0;
}

/* Footer */
.cx-search-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    font-size: 0.68rem; color: rgba(255,255,255,0.25);
}
.cx-search-footer i { margin-left: 4px; }

/* Floating trigger button */
.cx-search-trigger {
    position: fixed; bottom: 90px; left: 20px; z-index: 9998;
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #06b6d4);
    color: #fff; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    box-shadow: 0 4px 20px rgba(99,102,241,0.35);
    transition: all 0.25s;
}
.cx-search-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(99,102,241,0.5);
}

/* --- Light Theme --- */
body.light-theme .cx-search-modal {
    background: rgba(248,250,252,0.98); border-color: rgba(99,102,241,0.15);
}
body.light-theme .cx-search-header { border-bottom-color: rgba(0,0,0,0.06); }
body.light-theme .cx-search-input { color: #1e293b; }
body.light-theme .cx-search-input::placeholder { color: rgba(0,0,0,0.3); }
body.light-theme .cx-search-kbd { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.08); color: #94a3b8; }
body.light-theme .cx-search-item:hover, body.light-theme .cx-search-item.active { background: rgba(99,102,241,0.06); }
body.light-theme .cx-search-item-icon { background: rgba(0,0,0,0.03); }
body.light-theme .cx-search-item-title { color: #1e293b; }
body.light-theme .cx-search-item-title mark { background: rgba(99,102,241,0.15); color: #1e293b; }
body.light-theme .cx-search-empty-icon { color: rgba(0,0,0,0.1); }
body.light-theme .cx-search-empty-text { color: rgba(0,0,0,0.35); }
body.light-theme .cx-search-footer { border-top-color: rgba(0,0,0,0.06); color: rgba(0,0,0,0.25); }
body.light-theme .cx-search-results::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); }

/* --- Responsive --- */
@media (max-width: 600px) {
    .cx-search-overlay { padding-top: 5vh; }
    .cx-search-modal { width: 96%; border-radius: 16px; }
    .cx-search-header { padding: 14px 16px; }
    .cx-search-input { font-size: 0.95rem; }
    .cx-search-results { max-height: 55vh; padding: 6px; }
    .cx-search-item { padding: 10px 10px; gap: 10px; }
    .cx-search-trigger { bottom: 80px; left: 14px; width: 40px; height: 40px; font-size: 0.9rem; }
}

/* --- Print: hide --- */
@media print {
    .cx-search-overlay, .cx-search-trigger { display: none !important; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .cx-search-modal { transition-duration: 0.01ms !important; }
    .cx-search-overlay { transition-duration: 0.01ms !important; }
}
