/* =====================================================
   GLOBAL SEARCH - Buscador Global Premium
   Glassmorphism + Animaciones modernas
   ===================================================== */

/* --- Contenedor Principal --- */
.global-search-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* Fix para Syncfusion Toolbar - habilitar eventos en inputs */
.app-toolbar .global-search-container,
.app-toolbar .global-search-container * {
    pointer-events: auto !important;
}

.app-toolbar .search-input {
    pointer-events: auto !important;
    -webkit-user-select: text !important;
    user-select: text !important;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(68, 89, 215, 0.15);
    border-radius: 14px;
    padding: 0 12px;
    height: 44px;
    width: 320px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.global-search-container.expanded .search-wrapper,
.search-wrapper:focus-within {
    width: 380px;
    background: rgba(255, 255, 255, 1);
    border-color: rgba(68, 89, 215, 0.25);
    box-shadow:
        0 4px 20px rgba(68, 89, 215, 0.12),
        0 0 0 3px rgba(54, 193, 255, 0.1);
}

/* --- Icono de Busqueda --- */
.search-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--pidt-primary-dark);
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 8px;
    transition: all 0.25s ease;
}

.search-icon-btn:hover {
    background: rgba(68, 89, 215, 0.1);
    transform: scale(1.05);
}

/* --- Input de Busqueda --- */
.search-input {
    flex: 1;
    min-width: 120px;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    font-family: var(--pidt-font-primary);
    color: var(--pidt-text);
    padding: 8px 12px;
    height: 100%;
}

.search-input::placeholder {
    color: var(--pidt-text-light);
    font-size: 13px;
}

.search-input:focus {
    outline: none;
}

/* --- Boton Limpiar --- */
.search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(255, 107, 107, 0.1);
    border-radius: 6px;
    cursor: pointer;
    color: #FF6B6B;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.search-clear:hover {
    background: rgba(255, 107, 107, 0.2);
    transform: scale(1.1);
}

/* --- Shortcut Indicator --- */
.search-shortcut {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-left: 8px;
    opacity: 0.6;
    flex-shrink: 0;
}

.search-shortcut kbd {
    font-size: 10px;
    font-family: var(--pidt-font-secondary);
    font-weight: 600;
    background: rgba(68, 89, 215, 0.08);
    border: 1px solid rgba(68, 89, 215, 0.15);
    border-radius: 4px;
    padding: 2px 5px;
    color: var(--pidt-text-light);
}

.global-search-container.expanded .search-shortcut {
    display: none;
}

/* --- Panel de Resultados --- */
.search-results {
    position: absolute;
    top: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    width: 440px;
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.99) 0%,
        rgba(248, 250, 255, 0.99) 100%);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 20px;
    box-shadow:
        0 20px 60px rgba(6, 0, 81, 0.15),
        0 8px 24px rgba(68, 89, 215, 0.12),
        0 0 0 1px rgba(68, 89, 215, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border: none;
    padding: 6px;
    animation: resultsAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Linea de acento superior */
.search-results::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20px;
    right: 20px;
    height: 3px;
    background: linear-gradient(90deg,
        transparent 0%,
        #36C1FF 20%,
        #4459D7 50%,
        #6877F7 80%,
        transparent 100%);
    border-radius: 0 0 3px 3px;
}

@keyframes resultsAppear {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* --- Seccion de Resultados --- */
.results-section {
    margin-bottom: 4px;
    padding: 8px;
    background: rgba(248, 250, 255, 0.5);
    border-radius: 14px;
}

.results-section:last-child {
    margin-bottom: 0;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--pidt-primary-dark);
    opacity: 0.7;
}

.section-header svg {
    color: var(--pidt-primary);
    opacity: 0.8;
}

/* --- Item de Resultado --- */
.result-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    background: rgba(255, 255, 255, 0.6);
    margin-bottom: 4px;
}

.result-item:last-child {
    margin-bottom: 0;
}

.result-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: linear-gradient(180deg, var(--pidt-primary), var(--pidt-secondary));
    border-radius: 0 3px 3px 0;
    transition: height 0.2s ease;
}

.result-item:hover,
.result-item.selected {
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.95) 0%,
        rgba(248, 250, 255, 0.95) 100%);
    box-shadow: 0 4px 12px rgba(68, 89, 215, 0.1);
    transform: translateX(6px);
}

.result-item:hover::before,
.result-item.selected::before {
    height: 60%;
}

/* --- Icono del Resultado --- */
.result-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s ease;
}

.result-item:hover .result-icon {
    transform: scale(1.1);
}

.result-icon.module {
    background: linear-gradient(135deg,
        rgba(68, 89, 215, 0.12) 0%,
        rgba(104, 119, 247, 0.12) 100%);
    color: var(--pidt-primary-dark);
}

.result-icon.worker {
    background: linear-gradient(135deg,
        var(--pidt-primary-dark) 0%,
        var(--pidt-secondary) 100%);
    color: white;
    font-size: 12px;
    text-transform: uppercase;
}

/* --- Contenido del Resultado --- */
.result-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--pidt-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-subtitle {
    font-size: 12px;
    color: var(--pidt-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Acciones --- */
.result-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    color: var(--pidt-text-light);
    opacity: 0;
    transition: all 0.2s ease;
}

.result-item:hover .result-action {
    opacity: 1;
    background: rgba(68, 89, 215, 0.1);
    color: var(--pidt-primary-dark);
}

.result-badge {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(67, 160, 71, 0.1);
    color: #43A047;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.result-item:hover .result-badge {
    opacity: 1;
}

/* --- Estado de Carga --- */
.search-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 36px 24px;
}

.loading-spinner {
    position: relative;
    width: 32px;
    height: 32px;
}

/* Tres puntos animados */
.loading-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--pidt-primary), var(--pidt-secondary));
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.search-loading-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--pidt-text-light);
    letter-spacing: 0.3px;
}

/* --- Sin Resultados --- */
.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px 24px;
    color: var(--pidt-text-light);
}

.no-results svg {
    opacity: 0.3;
    color: var(--pidt-primary-dark);
}

.no-results span {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.7;
}

/* --- Scrollbar --- */
.search-results::-webkit-scrollbar {
    width: 4px;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: rgba(68, 89, 215, 0.2);
    border-radius: 4px;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .search-wrapper {
        width: 260px;
    }

    .global-search-container.expanded .search-wrapper,
    .search-wrapper:focus-within {
        width: 320px;
    }

    .search-results {
        width: 360px;
    }

    .search-shortcut {
        display: none;
    }
}

@media (max-width: 768px) {
    .search-wrapper {
        width: 200px;
    }

    .global-search-container.expanded .search-wrapper,
    .search-wrapper:focus-within {
        width: 260px;
    }

    .search-results {
        width: 300px;
    }
}

@media (max-width: 480px) {
    .search-wrapper {
        width: 160px;
    }

    .global-search-container.expanded .search-wrapper,
    .search-wrapper:focus-within {
        width: 200px;
    }

    .search-results {
        width: 240px;
        left: auto;
        right: 0;
        transform: none;
    }

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