/* ═══════════════════════════════════════════════════
   Otomatix Intelligence Search — CSS v3.1
   Auteur : Idevart - Otomatix
   CORRECTIF IMPORTANT : pas de display:grid sur .otomatix-grid
   Isotope positionne les items en position:absolute
═══════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────── */
:root {
    --ots-primary    : #4f46e5;
    --ots-primary-lt : #eef2ff;
    --ots-text       : #111827;
    --ots-muted      : #6b7280;
    --ots-border     : #e5e7eb;
    --ots-bg         : #f9fafb;
    --ots-white      : #ffffff;
    --ots-radius     : 1rem;
    --ots-radius-sm  : .5rem;
    --ots-shadow     : 0 4px 24px rgba(0,0,0,.07);
    --ots-shadow-lg  : 0 12px 40px rgba(79,70,229,.12);
    --ots-transition : .3s cubic-bezier(.4,0,.2,1);
}

/* ── Wrapper section ─────────────────────────────── */
.otomatix-search-section {
    padding: 5rem 0;
    background: var(--ots-white);
    border-bottom: 1px solid var(--ots-border);
}

.otomatix-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── En-tête ─────────────────────────────────────── */
.otomatix-header {
    text-align: center;
    margin-bottom: 3rem;
}

.otomatix-title {
    font-size: clamp(1.6rem, 3vw, 2.25rem);
    font-weight: 800;
    color: var(--ots-text);
    margin-bottom: .5rem;
    letter-spacing: -.02em;
}

.otomatix-subtitle {
    color: var(--ots-muted);
    font-size: .9rem;
}

/* ── Barre de recherche ──────────────────────────── */
.otomatix-search-bar {
    position: relative;
    max-width: 780px;
    margin: 0 auto 2rem;
}

.otomatix-search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--ots-muted);
    pointer-events: none;
    transition: color var(--ots-transition);
}

.otomatix-search-bar:focus-within .otomatix-search-icon {
    color: var(--ots-primary);
}

#main-search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 3.25rem;
    border: 2px solid var(--ots-border);
    border-radius: var(--ots-radius);
    font-size: 1rem;
    font-weight: 500;
    background: var(--ots-bg);
    color: var(--ots-text);
    outline: none;
    transition: border-color var(--ots-transition), background var(--ots-transition), box-shadow var(--ots-transition);
    box-shadow: var(--ots-shadow);
    box-sizing: border-box;
}

#main-search-input:focus {
    border-color: var(--ots-primary);
    background: var(--ots-white);
    box-shadow: 0 0 0 4px rgba(79,70,229,.1);
}

.otomatix-search-clear {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ots-muted);
    font-size: .9rem;
    padding: .25rem;
    line-height: 1;
    transition: color var(--ots-transition);
}
.otomatix-search-clear:hover { color: var(--ots-text); }

/* ── Boutons filtre ──────────────────────────────── */
.otomatix-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .5rem;
    margin-bottom: 1.5rem;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .45rem 1.1rem;
    border-radius: 999px;
    border: 1.5px solid var(--ots-border);
    background: var(--ots-white);
    color: var(--ots-muted);
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    cursor: pointer;
    transition: all var(--ots-transition);
}

.filter-btn:hover {
    border-color: var(--ots-primary);
    color: var(--ots-primary);
    background: var(--ots-primary-lt);
}

.filter-btn.active {
    background: var(--ots-text);
    color: var(--ots-white);
    border-color: var(--ots-text);
    box-shadow: 0 4px 12px rgba(17,24,39,.18);
}

.filter-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .5;
}

/* ── Compteur ────────────────────────────────────── */
.otomatix-count {
    text-align: center;
    font-size: .78rem;
    font-weight: 600;
    color: var(--ots-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    min-height: 1rem;
}

/* ════════════════════════════════════════════════════
   GRILLE ISOTOPE
   NE PAS utiliser display:grid ici — Isotope positionne
   les items en position:absolute via son propre layout.
   Le conteneur doit être en display:block avec position:relative.
════════════════════════════════════════════════════ */
.otomatix-grid {
    position: relative;  /* REQUIS pour Isotope */
    display: block;      /* REQUIS — pas de display:grid */
    min-height: 400px;
    transition: opacity .3s ease;
}

/* ── Items Isotope ───────────────────────────────── */
.otomatix-item {
    /* La largeur est définie en % via style inline dans le PHP */
    padding: .75rem;
    box-sizing: border-box;
}

/* ── Carte ───────────────────────────────────────── */
.otomatix-card {
    background: var(--ots-white);
    border-radius: var(--ots-radius);
    border: 1px solid var(--ots-border);
    overflow: hidden;
    transition: box-shadow var(--ots-transition), transform var(--ots-transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.otomatix-card:hover {
    box-shadow: var(--ots-shadow-lg);
    transform: translateY(-3px);
}

/* Vignette */
.otomatix-card-thumb {
    position: relative;
    height: 160px;
    overflow: hidden;
    background: var(--ots-bg);
}

.otomatix-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s ease;
    display: block;
}

.otomatix-card:hover .otomatix-card-img {
    transform: scale(1.06);
}

/* Placeholder image manquante */
.otomatix-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f0f5 0%, #e8e8f0 100%);
}

.otomatix-card-placeholder svg {
    width: 2.5rem;
    height: 2.5rem;
    color: #c0c0d0;
}

/* Badge score */
.otomatix-score-badge {
    position: absolute;
    top: .6rem;
    left: .6rem;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(6px);
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 800;
    color: var(--ots-primary);
    letter-spacing: .03em;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
    pointer-events: none;
}

/* Badge catégorie */
.otomatix-cat-badge {
    position: absolute;
    bottom: .6rem;
    right: .6rem;
    background: rgba(17,24,39,.72);
    color: #fff;
    padding: .2rem .55rem;
    border-radius: 999px;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    pointer-events: none;
}

/* Corps de carte */
.otomatix-card-body {
    padding: 1rem 1.1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.otomatix-card-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--ots-text);
    line-height: 1.35;
    margin-bottom: .5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--ots-transition);
}

.otomatix-card:hover .otomatix-card-title {
    color: var(--ots-primary);
}

.otomatix-card-excerpt {
    font-size: .8rem;
    color: var(--ots-muted);
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: .75rem;
}

/* Footer de carte */
.otomatix-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: .75rem;
    border-top: 1px solid var(--ots-border);
    margin-top: auto;
}

.otomatix-date {
    font-size: .68rem;
    color: var(--ots-muted);
    font-style: italic;
}

.otomatix-read-more {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    font-size: .7rem;
    font-weight: 700;
    color: var(--ots-text);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .05em;
    transition: color var(--ots-transition), gap var(--ots-transition);
}

.otomatix-read-more svg {
    width: .9rem;
    height: .9rem;
    transition: transform var(--ots-transition);
}

.otomatix-read-more:hover {
    color: var(--ots-primary);
    gap: .5rem;
}

.otomatix-read-more:hover svg {
    transform: translateX(3px);
}

/* ── Loader ──────────────────────────────────────── */
.otomatix-loader {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.otomatix-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--ots-border);
    border-top-color: var(--ots-primary);
    border-radius: 50%;
    animation: ots-spin .7s linear infinite;
}

@keyframes ots-spin {
    to { transform: rotate(360deg); }
}

/* ── Aucun résultat ──────────────────────────────── */
.otomatix-no-results {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--ots-muted);
}

.otomatix-no-results svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    display: block;
    opacity: .4;
}

.otomatix-no-results p {
    font-size: .9rem;
    font-weight: 500;
}

/* ── Bouton charger plus ─────────────────────────── */
.otomatix-load-more-wrap {
    text-align: center;
    margin-top: 3rem;
}

.otomatix-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 2rem;
    border: 2px solid var(--ots-text);
    border-radius: 999px;
    background: transparent;
    color: var(--ots-text);
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    cursor: pointer;
    transition: all var(--ots-transition);
}

.otomatix-load-more-btn svg {
    width: 1rem;
    height: 1rem;
    transition: transform var(--ots-transition);
}

.otomatix-load-more-btn:hover {
    background: var(--ots-text);
    color: var(--ots-white);
}

.otomatix-load-more-btn:hover svg {
    transform: translateY(2px);
}

.otomatix-load-more-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
    .otomatix-item {
        /* 2 colonnes sur tablette quelle que soit la config */
        width: 50% !important;
    }
}

@media (max-width: 640px) {
    .otomatix-search-section {
        padding: 3rem 0;
    }

    .otomatix-item {
        /* 1 colonne sur mobile */
        width: 100% !important;
    }

    /* Sur mobile, Isotope peut être désactivé pour un flow normal */
    .otomatix-grid {
        position: static;
        height: auto !important;
    }

    .otomatix-item {
        position: static !important;
        top: auto !important;
        left: auto !important;
    }
}
