/* ============================================
   Fuzzy Search Component CSS
   ============================================ */

/* ===== Input Wrapper ===== */
.fuzzy-search-wrap { position: relative; width: 100%; }

.fuzzy-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.fuzzy-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 1;
}

.fuzzy-search-input {
    padding-left: 36px !important;
    padding-right: 40px !important;
    height: 44px;
    font-size: 0.9rem;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.fuzzy-search-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
    outline: none;
}

.fuzzy-search-input::placeholder {
    color: #94a3b8;
}

/* Voice Button */
.fuzzy-voice-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 2;
    font-size: 1rem;
}

.fuzzy-voice-btn:hover {
    background: rgba(99,102,241,0.08);
    color: #6366f1;
}

.fuzzy-voice-btn.recording {
    color: #ef4444;
    background: rgba(239,68,68,0.08);
    animation: fuzzyPulse 1s infinite;
}

@keyframes fuzzyPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
    50% { box-shadow: 0 0 0 10px rgba(239,68,68,0); }
}

/* ===== Desktop Dropdown ===== */
.fuzzy-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.12);
    z-index: 1060;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.fuzzy-dropdown.show {
    display: block;
    animation: fuzzySlideDown 0.2s ease;
}

@keyframes fuzzySlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.fuzzy-group-label {
    padding: 8px 14px 4px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 1;
}

.fuzzy-option {
    padding: 10px 14px;
    font-size: 0.88rem;
    color: #334155;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
}

.fuzzy-option:hover,
.fuzzy-option.highlighted {
    background: rgba(99,102,241,0.05);
}

.fuzzy-option.selected {
    background: rgba(99,102,241,0.08);
    color: #6366f1;
    font-weight: 500;
}

.fuzzy-option mark {
    background: #fef08a;
    padding: 0;
    border-radius: 2px;
    color: inherit;
    font-weight: inherit;
}

.fuzzy-no-results {
    padding: 24px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
}

/* ===== Mobile Full-Screen Sheet ===== */
.fuzzy-mobile-sheet {
    display: none;
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 9999;
    flex-direction: column;
}

.fuzzy-mobile-sheet.active {
    display: flex;
    animation: fuzzySheetIn 0.25s ease;
}

@keyframes fuzzySheetIn {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.fuzzy-sheet-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    min-height: 56px;
    padding-top: calc(12px + env(safe-area-inset-top, 0));
}

.fuzzy-sheet-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    font-size: 1.25rem;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.fuzzy-sheet-title {
    font-weight: 600;
    font-size: 1rem;
    color: #0f172a;
}

.fuzzy-sheet-input-wrap {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
}

.fuzzy-sheet-input-wrap .form-control {
    height: 48px;
    font-size: 16px !important;
    border-radius: 12px;
    border: 1.5px solid #e2e8f0;
}

.fuzzy-sheet-results {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px;
}

.fuzzy-sheet-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: #fff;
    font-size: 0.95rem;
    color: #334155;
    text-align: left;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.15s;
    min-height: 52px;
    gap: 8px;
}

.fuzzy-sheet-option:active {
    background: #f1f5f9;
}

.fuzzy-sheet-option.selected {
    background: rgba(99,102,241,0.08);
    color: #6366f1;
    font-weight: 500;
}

.fuzzy-sheet-option mark {
    background: #fef08a;
    padding: 0;
    border-radius: 2px;
}

.fuzzy-sheet-option small {
    font-size: 0.72rem;
    flex-shrink: 0;
}

/* ===== Desktop override ===== */
@media (min-width: 768px) {
    .fuzzy-mobile-sheet {
        display: none !important;
    }
}

/* ===== Integration with admin forms ===== */
.fuzzy-search-wrap .form-control {
    font-size: 0.9rem;
}

/* Inside card-body */
.card .fuzzy-search-wrap {
    margin-bottom: 0;
}

/* Inline fuzzy search in tables */
.table .fuzzy-search-wrap {
    max-width: 300px;
}
