/**
 * BizQcity ERP - SEARCH BAR WITH AUTOCOMPLETE
 * Recherche moderne avec arborescence des modules
 */

/* ============================================
   SEARCH CONTAINER
   ============================================ */

.qcity-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 550px;
    flex: 1;
}

.qcity-search-input-wrapper {
    position: relative;
    width: 100%;
}

.qcity-search-input {
    width: 100%;
    height: 44px;
    padding: 10px 50px 10px 44px;
    border: 2px solid #E5E7EB;
    border-radius: 22px;
    font-size: 14px;
    background: #F9FAFB;
    transition: all 0.3s ease;
    outline: none;
}

.qcity-search-input:focus {
    background: white;
    border-color: #009E4E;
    box-shadow: 0 0 0 4px rgba(0, 158, 78, 0.1);
}

.qcity-search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6B7280;
    font-size: 16px;
    pointer-events: none;
}

.qcity-search-input:focus ~ .qcity-search-icon {
    color: #009E4E;
}

.qcity-search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #E5E7EB;
    border: none;
    color: #6B7280;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qcity-search-clear.visible {
    opacity: 1;
}

.qcity-search-clear:hover {
    background: #EF4444;
    color: white;
}

/* ============================================
   AUTOCOMPLETE DROPDOWN
   ============================================ */

.qcity-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border: 2px solid #009E4E;
    max-height: 500px;
    overflow-y: auto;
    overflow-x: visible;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.qcity-search-results.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.qcity-search-results-header {
    padding: 16px 20px;
    border-bottom: 2px solid #E5E7EB;
    background: linear-gradient(135deg, #F9FAFB 0%, white 100%);
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.qcity-search-results-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.qcity-search-count {
    background: #009E4E;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* ============================================
   SEARCH ITEMS
   ============================================ */

.qcity-search-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #F3F4F6;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
}

.qcity-search-item:hover {
    background: linear-gradient(90deg, rgba(0, 158, 78, 0.08) 0%, transparent 100%);
    border-left: 3px solid #009E4E;
    padding-left: 13px;
}

/* Live Preview Popup au Hover */
.qcity-search-item {
    position: relative;
}

.qcity-search-live-preview {
    position: absolute;
    left: calc(100% + 16px);
    top: 50%;
    transform: translateY(-50%);
    width: 400px;
    height: 280px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    border: 3px solid #009E4E;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 10000;
    overflow: hidden;
    pointer-events: none;
}

.qcity-search-item:hover .qcity-search-live-preview {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
}

.qcity-search-live-preview::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    height: 28px;
    background: linear-gradient(135deg, #009E4E 0%, #00B35C 100%);
    border-radius: 8px 8px 0 0;
    z-index: 2;
}

.qcity-search-live-preview::after {
    content: 'Preview';
    position: absolute;
    top: 14px;
    left: 16px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 3;
}

.qcity-search-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    transform: scale(0.8);
    transform-origin: top left;
    width: 125%;
    height: 125%;
}

.qcity-search-preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 1;
}

.qcity-search-preview-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #E5E7EB;
    border-top-color: #009E4E;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.qcity-search-item:last-child {
    border-bottom: none;
}

.qcity-search-item-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.qcity-search-item:hover .qcity-search-item-icon {
    transform: scale(1.1) rotate(-5deg);
}

/* Icon Colors */
.qcity-search-item-icon.primary {
    background: linear-gradient(135deg, rgba(0, 158, 78, 0.1) 0%, rgba(0, 179, 92, 0.1) 100%);
    color: #009E4E;
}

.qcity-search-item-icon.secondary {
    background: linear-gradient(135deg, rgba(255, 182, 18, 0.1) 0%, rgba(255, 202, 78, 0.1) 100%);
    color: #FFB612;
}

.qcity-search-item-icon.accent {
    background: linear-gradient(135deg, rgba(0, 102, 204, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%);
    color: #0066CC;
}

.qcity-search-item-icon.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(52, 211, 153, 0.1) 100%);
    color: #10B981;
}

.qcity-search-item-icon.warning {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1) 0%, rgba(251, 191, 36, 0.1) 100%);
    color: #F59E0B;
}

.qcity-search-item-icon.danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(248, 113, 113, 0.1) 100%);
    color: #EF4444;
}

.qcity-search-item-icon.purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(167, 139, 250, 0.1) 100%);
    color: #8B5CF6;
}

.qcity-search-item-icon.skyblue {
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.1) 0%, rgba(125, 211, 252, 0.1) 100%);
    color: #38BDF8;
}

.qcity-search-item-icon.info {
    background: linear-gradient(135deg, rgba(23, 162, 184, 0.1) 0%, rgba(52, 192, 208, 0.1) 100%);
    color: #17a2b8;
}

.qcity-search-item-content {
    flex: 1;
    min-width: 0;
}

.qcity-search-item-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.qcity-search-item-title mark {
    background: #FFB612;
    color: #1F2937;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 700;
}

.qcity-search-item-breadcrumb {
    font-size: 12px;
    color: #6B7280;
    display: flex;
    align-items: center;
    gap: 6px;
}

.qcity-search-item-breadcrumb i {
    font-size: 10px;
    color: #9CA3AF;
}

.qcity-search-item-breadcrumb span {
    color: #009E4E;
    font-weight: 500;
}

/* Badge pour le type */
.qcity-search-badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.qcity-search-badge.module {
    background: #009E4E;
    color: white;
}

.qcity-search-badge.item {
    background: #E5E7EB;
    color: #6B7280;
}

.qcity-search-badge.level2 {
    background: linear-gradient(135deg, #0066CC 0%, #4A9EFF 100%);
    color: white;
}

.qcity-search-badge.level3 {
    background: linear-gradient(135deg, #8B5CF6 0%, #A78BFA 100%);
    color: white;
}

/* Subtitle pour modules */
.qcity-search-item-subtitle {
    font-size: 11px;
    color: #9CA3AF;
    font-style: italic;
    margin-top: 3px;
    line-height: 1.4;
}

/* Arrow indicator */
.qcity-search-item-arrow {
    color: #9CA3AF;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
}

.qcity-search-item:hover .qcity-search-item-arrow {
    opacity: 1;
    transform: translateX(4px);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.qcity-search-empty {
    padding: 40px 20px;
    text-align: center;
}

.qcity-search-empty i {
    font-size: 48px;
    color: #D1D5DB;
    margin-bottom: 12px;
}

.qcity-search-empty p {
    color: #6B7280;
    font-size: 14px;
    margin: 0;
}

/* ============================================
   LOADING STATE
   ============================================ */

.qcity-search-loading {
    padding: 24px;
    text-align: center;
}

.qcity-search-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #E5E7EB;
    border-top-color: #009E4E;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   KEYBOARD NAVIGATION
   ============================================ */

.qcity-search-item.focused {
    background: linear-gradient(90deg, rgba(0, 158, 78, 0.12) 0%, rgba(0, 158, 78, 0.04) 100%);
    border-left: 3px solid #009E4E;
    padding-left: 17px;
}

/* ============================================
   SCROLLBAR
   ============================================ */

.qcity-search-results::-webkit-scrollbar {
    width: 6px;
}

.qcity-search-results::-webkit-scrollbar-track {
    background: #F3F4F6;
}

.qcity-search-results::-webkit-scrollbar-thumb {
    background: #9CA3AF;
    border-radius: 3px;
}

.qcity-search-results::-webkit-scrollbar-thumb:hover {
    background: #009E4E;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .qcity-search-wrapper {
        max-width: 100%;
    }
    
    .qcity-search-results {
        max-height: 400px;
    }
    
    .qcity-search-item {
        padding: 12px 16px;
    }
    
    .qcity-search-item-icon {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

