/**
 * Estilos para el Sistema de Búsqueda Global
 * OS10 Coquimbo
 * VERSIÓN FINAL: Brillo en borde, placeholder con ícono de lupa SVG
 */

/* ===== BOTÓN DE BÚSQUEDA EN BANNER ===== */
.banner-search-button,
#global-search-button {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin: 0 1rem 0 0;
    position: relative;
}

/* Estilo del icono (SOLO MÓVIL - Usa el SVG inline del HTML) */
#global-search-button .search-icon {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    transition: all 0.2s ease;
}

/* Hover effect sutil */
#global-search-button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

#global-search-button:active {
    transform: scale(0.95);
}

/* ===== SOLO EN PC: BARRA DE BÚSQUEDA E ÍCONO ===== */
@media (min-width: 1024px) {
    #global-search-button {
        background: transparent;
        border: 2px solid #dadde2;       /* rectangulo color*/
        border-radius: 12px;
        padding: 4px 28px;
        min-width: 960px;
        margin-right: 1.5rem;
        position: relative;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* Ocultar el ícono SVG inline (el del HTML) en PC */
    #global-search-button .search-icon {
        display: none;
    }

    /* Texto placeholder en gris */
    #global-search-button::before {
        content: 'Buscar en la pagina';
        color: #9ca3af;
        font-size: 16px;
        font-weight: 400;
        letter-spacing: 0.3px;
        opacity: 0.8;
        transition: opacity 0.3s ease, color 0.3s ease;
        margin-right: 6px;
    }

    /* Ícono de lupa SVG (Usando Máscara CSS para controlar el color) */
    #global-search-button::after {
        content: '';
        width: 23px;
        height: 23px;
        display: block;
        
        /* El color del icono se define aquí */
        background-color: #9ca3af; 
        
        /* Definimos la forma del icono usando el SVG como máscara */
        -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
        mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.35-4.35'%3E%3C/path%3E%3C/svg%3E");
        
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-size: contain;
        mask-size: contain;

        opacity: 0.8;
        transition: opacity 0.3s ease, background-color 0.3s ease;
    }

    /* Efecto hover */
    #global-search-button:hover {
        background: rgba(0, 0, 0, 0.02);
        border-color: #3d92fb; /* Efecto hover COLOR AZUL */
        transform: scale(1.02);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    #global-search-button:hover::before {
        opacity: 1;
        color: #a8a4a3;  /* letra al lado de la lupa*/
    }

    /* Cambia el color del icono SVG al hacer hover */
    #global-search-button:hover::after {
        opacity: 1;
        background-color: #92ada4; /* #43584b El icono cambia a verde */
    }
}

/* ===== MANTENER LUPA EN MÓVIL ===== */
@media (max-width: 1023px) {
    #global-search-button .search-icon {
        width: 26px;
        height: 26px;
        display: block;
    }

    #global-search-button {
        background: transparent;
        border: none;
        padding: 8px;
        border-radius: 50%;
        min-width: auto;
    }

    #global-search-button::before,
    #global-search-button::after {
        display: none;
    }
}

/* ===== MODAL DE BÚSQUEDA ===== */
#global-search-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

#global-search-modal.search-modal-hidden {
    display: none;
}

#global-search-modal.search-modal-visible {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.search-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.search-modal-content {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 70vh;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: slideDown 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* ===== HEADER DE BÚSQUEDA ===== */
.search-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.search-input-wrapper {
    position: relative;
}

.search-input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    pointer-events: none;
}

#global-search-input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    outline: none;
    transition: all 0.2s ease;
    background: #f9fafb;
}

#global-search-input:focus {
    border-color: #146314;
    background: white;
    box-shadow: 0 0 0 3px rgba(20, 99, 20, 0.1);
}

.search-shortcuts {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}

.shortcut-badge {
    padding: 4px 8px;
    background: #f3f4f6;
    border-radius: 6px;
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
    border: 1px solid #e5e7eb;
}

/* ===== CONTENEDOR DE RESULTADOS ===== */
.search-results-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

#search-results {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#search-results.hidden {
    display: none;
}

/* ===== ITEMS DE RESULTADO ===== */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.search-result-item:hover {
    background: #f9fafb;
    border-color: #146314;
    transform: translateX(4px);
}

.search-result-item.selected {
    background: #f0fdf4;
    border-color: #146314;
    box-shadow: 0 0 0 2px rgba(20, 99, 20, 0.1);
}

.result-section-badge {
    position: absolute;
    top: 8px;
    right: 40px;
    padding: 2px 8px;
    background: #146314;
    color: white;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-content {
    flex: 1;
    padding-right: 60px;
}

.result-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px 0;
    line-height: 1.4;
}

.result-description {
    font-size: 12px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    transition: all 0.2s ease;
}

.search-result-item:hover .result-arrow {
    color: #146314;
    transform: translateY(-50%) translateX(2px);
}

mark {
    background: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* ===== NO HAY RESULTADOS ===== */
#search-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

#search-no-results.hidden {
    display: none;
}

#search-no-results svg {
    color: #d1d5db;
    margin-bottom: 16px;
}

#search-no-results p {
    font-size: 16px;
    font-weight: 600;
    color: #6b7280;
    margin: 0 0 8px 0;
}

#search-no-results small {
    font-size: 14px;
    color: #9ca3af;
}

/* ===== AYUDA DE BÚSQUEDA ===== */
.search-help {
    padding: 20px;
}

.search-help.hidden {
    display: none;
}

.search-help h4 {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
}

.search-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-pill {
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.suggestion-pill:hover {
    background: #146314;
    color: white;
    border-color: #146314;
    transform: scale(1.05);
}

/* ===== SCROLLBAR PERSONALIZADA ===== */
.search-results-container::-webkit-scrollbar {
    width: 8px;
}

.search-results-container::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 4px;
}

.search-results-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.search-results-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    #global-search-modal {
        padding-top: 5vh;
    }
    
    .search-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .search-shortcuts {
        display: none;
    }
    
    #global-search-input {
        font-size: 16px;
    }
    
    .result-section-badge {
        position: static;
        margin-bottom: 4px;
        display: inline-block;
    }
    
    .result-content {
        padding-right: 0;
    }
    
    .result-arrow {
        display: none;
    }
    
    .suggestion-pill {
        font-size: 12px;
        padding: 5px 10px;
    }
}

@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.loading-skeleton {
    background: linear-gradient(
        90deg,
        #f3f4f6 25%,
        #e5e7eb 50%,
        #f3f4f6 75%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

#global-search-modal {
    z-index: 10000;
}

#global-search-modal * {
    box-sizing: border-box;
}
