/**
 * FICHE-PAIE.FR — Styles page de recherche (Smart Search Hybride)
 *
 * @copyright 2025-2026 Purple Telecom EURL
 * @license   Proprietary - All Rights Reserved
 * @author    Fabien HIRIART <contact@polygonlab.ai>
 * @link      https://fiche-paie.fr
 *
 * Dépend des variables CSS définies dans style.css (:root).
 * Couleurs par catégorie :
 *   blog    → --gp-turquoise  (#5ec5c8)
 *   outil   → --gp-bleu-marine (#1e3760)
 *   metier  → #8b5cf6 (violet)
 *   page    → --gp-gris       (#6b7280)
 *   landing → --gp-orange     (#f7931e)
 */

/* ============================================================
   CONTENEUR PRINCIPAL
   ============================================================ */

.recherche-page {
    max-width: 860px;
    margin: 2rem auto 4rem;
    padding: 0 1rem;
}

.recherche-page h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gp-bleu-marine);
    margin-bottom: 1.5rem;
}

/* ============================================================
   BARRE DE RECHERCHE
   ============================================================ */

.search-bar-wrapper {
    position: relative;
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.search-input-container {
    position: relative;
    flex: 1;
}

.search-input-container .search-icon {
    position: absolute;
    left: .875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--gp-gris);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: .75rem 1rem .75rem 2.75rem;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: .5rem;
    background: #fff;
    color: var(--gp-bleu-marine);
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--gp-turquoise);
    box-shadow: 0 0 0 3px rgba(94, 197, 200, .2);
}

.search-input::placeholder {
    color: #9ca3af;
}

.search-btn {
    padding: .75rem 1.5rem;
    background: var(--gp-bleu-marine);
    color: #fff;
    border: none;
    border-radius: .5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s, transform .1s;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.search-btn:hover {
    background: #162b4d;
}

.search-btn:active {
    transform: scale(.98);
}

.search-btn svg {
    width: 18px;
    height: 18px;
}

/* ============================================================
   SPINNER DE CHARGEMENT
   ============================================================ */

.search-spinner {
    position: absolute;
    right: .875rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--gp-turquoise);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: none;
}

.search-spinner.visible {
    display: block;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ============================================================
   DROPDOWN AUTOCOMPLETE
   ============================================================ */

.search-dropdown {
    position: absolute;
    top: calc(100% + .375rem);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: .5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    z-index: 1000;
    overflow: hidden;
    max-height: 380px;
    overflow-y: auto;

    /* Animation slide-down */
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease;
    pointer-events: none;
}

.search-dropdown.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.search-dropdown-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .625rem 1rem;
    cursor: pointer;
    transition: background .1s;
    text-decoration: none;
    color: inherit;
}

.search-dropdown-item:hover,
.search-dropdown-item.active {
    background: var(--gp-gris-clair);
}

.search-dropdown-item .item-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gp-gris);
}

.search-dropdown-item .item-content {
    flex: 1;
    min-width: 0;
}

.search-dropdown-item .item-title {
    font-size: .9rem;
    font-weight: 500;
    color: var(--gp-bleu-marine);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================================
   BADGES DE CATÉGORIE
   ============================================================ */

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-badge.badge-blog {
    background: rgba(94, 197, 200, .15);
    color: #1a9ea1;
}

.category-badge.badge-outil {
    background: rgba(30, 55, 96, .12);
    color: var(--gp-bleu-marine);
}

.category-badge.badge-metier {
    background: rgba(139, 92, 246, .12);
    color: #6d28d9;
}

.category-badge.badge-page {
    background: rgba(107, 114, 128, .12);
    color: var(--gp-gris);
}

.category-badge.badge-landing {
    background: rgba(247, 147, 30, .15);
    color: #d97706;
}

/* ============================================================
   "VOULIEZ-VOUS DIRE ?"
   ============================================================ */

.did-you-mean {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .625rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--gp-jaune-pale);
    border: 1px solid var(--gp-jaune-bordure);
    border-radius: .5rem;
    font-size: .9rem;
    color: var(--gp-jaune-fonce);
}

.did-you-mean svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.did-you-mean a {
    color: var(--gp-bleu-marine);
    font-weight: 700;
    text-decoration: none;
    border-bottom: 1px dashed var(--gp-bleu-marine);
}

.did-you-mean a:hover {
    color: var(--gp-turquoise);
    border-color: var(--gp-turquoise);
}

/* ============================================================
   FILTRES PAR CATÉGORIE (pills)
   ============================================================ */

.search-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.filter-btn {
    padding: .375rem .875rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    color: var(--gp-gris);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.filter-btn:hover {
    border-color: var(--gp-turquoise);
    color: var(--gp-bleu-marine);
}

.filter-btn.active {
    background: var(--gp-bleu-marine);
    border-color: var(--gp-bleu-marine);
    color: #fff;
}

.filter-btn .filter-count {
    font-size: .75rem;
    opacity: .75;
}

/* ============================================================
   RÉSULTATS
   ============================================================ */

.search-results-header {
    font-size: .9rem;
    color: var(--gp-gris);
    margin-bottom: 1rem;
}

.search-results-header strong {
    color: var(--gp-bleu-marine);
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-result-card {
    padding: 1rem 1.25rem;
    border: 1px solid #e5e7eb;
    border-radius: .625rem;
    background: #fff;
    transition: box-shadow .15s, border-color .15s, transform .1s;
    text-decoration: none;
    display: block;
    color: inherit;
}

.search-result-card:hover {
    border-color: var(--gp-turquoise);
    box-shadow: 0 4px 16px rgba(94, 197, 200, .15);
    transform: translateY(-1px);
}

.search-result-card-header {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    margin-bottom: .5rem;
}

.search-result-card-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: .375rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-result-card-icon.icon-blog    { background: rgba(94, 197, 200, .12);  color: #1a9ea1; }
.search-result-card-icon.icon-outil   { background: rgba(30, 55, 96, .1);     color: var(--gp-bleu-marine); }
.search-result-card-icon.icon-metier  { background: rgba(139, 92, 246, .1);   color: #6d28d9; }
.search-result-card-icon.icon-page    { background: rgba(107, 114, 128, .1);  color: var(--gp-gris); }
.search-result-card-icon.icon-landing { background: rgba(247, 147, 30, .12);  color: #d97706; }

.search-result-card-icon svg {
    width: 20px;
    height: 20px;
}

.search-result-card-meta {
    flex: 1;
    min-width: 0;
}

.search-result-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--gp-bleu-marine);
    margin-bottom: .2rem;
    line-height: 1.3;
}

.search-result-card-url {
    font-size: .75rem;
    color: var(--gp-gris);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-card-description {
    font-size: .875rem;
    color: #374151;
    line-height: 1.55;
    margin: 0;
}

/* Highlight des termes recherchés */
mark.search-highlight {
    background: rgba(247, 147, 30, .25);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ============================================================
   ÉTAT VIDE
   ============================================================ */

.search-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gp-gris);
}

.search-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: .4;
}

.search-empty h3 {
    font-size: 1.1rem;
    color: var(--gp-bleu-marine);
    margin-bottom: .5rem;
}

.search-empty p {
    font-size: .9rem;
    margin-bottom: 1.5rem;
}

.search-empty-suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
}

.search-empty-suggestions a {
    padding: .375rem .875rem;
    background: var(--gp-gris-clair);
    border-radius: 999px;
    font-size: .85rem;
    color: var(--gp-bleu-marine);
    text-decoration: none;
    transition: background .15s;
}

.search-empty-suggestions a:hover {
    background: #e5e7eb;
}

/* ============================================================
   ÉTAT INITIAL (pas encore de recherche)
   ============================================================ */

.search-initial {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gp-gris);
}

.search-initial svg {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
    color: var(--gp-turquoise);
    opacity: .6;
}

.search-initial p {
    font-size: .95rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 600px) {
    .search-bar-wrapper {
        flex-direction: column;
    }

    .search-btn {
        justify-content: center;
    }

    .search-dropdown {
        left: 0;
        right: 0;
    }

    .search-filters {
        gap: .375rem;
    }

    .filter-btn {
        font-size: .8rem;
        padding: .3rem .75rem;
    }

    .recherche-page h1 {
        font-size: 1.4rem;
    }
}
