/* ================================================================
   AEM Recherche avec filtres — Styles (Ticket #2)
   Hérite des variables CSS de aem-carte.css
   ================================================================ */

/* ----------------------------------------------------------------
   Wrapper
   ---------------------------------------------------------------- */
.aem-rech-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 20px 80px;
    font-family: 'Plus Jakarta Sans', 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #1a1c1c;
    position: relative;
}

/* ----------------------------------------------------------------
   Barre de filtres (desktop — sticky)
   ---------------------------------------------------------------- */
.aem-rech-filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e8eaed;
    border-radius: 10px;
    margin-bottom: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.aem-rech-search-wrap {
    flex: 1;
    min-width: 180px;
    max-width: 300px;
    position: relative;
}

.aem-rech-input {
    width: 100%;
    /* hérite de .aem-ct-search */
}

.aem-rech-filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.aem-rech-filter-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.aem-rech-select {
    height: 44px;
    padding: 0 10px;
    border: 2px solid #e8eaed;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1a1c1c;
    background: #fff;
    cursor: pointer;
    min-width: 160px;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.aem-rech-select:focus {
    border-color: #ba0031;
    outline: none;
}

.aem-rech-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aem-rech-btn-apply {
    height: 44px;
    padding: 0 20px;
    background: #ba0031;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    min-width: 120px;
    transition: background 0.2s;
    align-self: flex-end;
}

.aem-rech-btn-apply:hover {
    background: #9a0028;
}

.aem-rech-btn-apply--full {
    width: 100%;
    height: 48px;
}

.aem-rech-btn-cancel {
    width: 100%;
    height: 44px;
    background: none;
    border: 2px solid #e8eaed;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #666;
    cursor: pointer;
    transition: border-color 0.2s;
}

.aem-rech-btn-cancel:hover {
    border-color: #ba0031;
    color: #ba0031;
}

/* Bouton "Filtrer" (mobile uniquement) */
.aem-rech-drawer-trigger {
    display: none;
    width: 100%;
    height: 48px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff;
    border: 2px solid #e8eaed;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    color: #1a1c1c;
    cursor: pointer;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.aem-rech-drawer-trigger:hover {
    border-color: #ba0031;
    color: #ba0031;
}

.aem-rech-filter-count {
    background: #ba0031;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

.aem-rech-filter-count.has-filters {
    display: inline-flex;
}

/* Mobile */
@media (max-width: 768px) {
    .aem-rech-filterbar {
        display: none;
    }

    .aem-rech-drawer-trigger {
        display: flex;
    }
}

/* ----------------------------------------------------------------
   Bottom sheet drawer (mobile)
   ---------------------------------------------------------------- */
.aem-rech-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9996;
    animation: aem-fade-in 0.2s ease;
}

@keyframes aem-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.aem-rech-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9997;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 0 20px calc(20px + env(safe-area-inset-bottom, 0px));
    max-height: 82vh;
    overflow-y: auto;
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.aem-rech-drawer.is-open {
    transform: translateY(0);
}

.aem-rech-drawer-handle {
    width: 44px;
    height: 5px;
    background: #ddd;
    border-radius: 3px;
    margin: 14px auto 20px;
}

.aem-rech-drawer-title {
    font-size: 18px;
    font-weight: 800;
    margin: 0 0 20px;
    color: #1a1c1c;
}

.aem-rech-drawer-field {
    margin-bottom: 16px;
}

.aem-rech-drawer-field .aem-rech-select {
    width: 100%;
    min-width: unset;
}

.aem-rech-drawer-field .aem-ct-search-wrap {
    max-width: none;
}

.aem-rech-drawer-field .aem-ct-search {
    width: 100%;
    box-sizing: border-box;
}

.aem-rech-drawer-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}

/* ----------------------------------------------------------------
   Compteur de résultats
   ---------------------------------------------------------------- */
.aem-rech-count {
    font-size: 14px;
    color: #666;
    margin-bottom: 14px;
    min-height: 20px;
}

.aem-rech-count strong {
    color: #1a1c1c;
}

/* ----------------------------------------------------------------
   Grille de cards — vue liste
   ---------------------------------------------------------------- */
.aem-rech-cards {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Card auto-école — layout horizontal Precision Navigator */
.aem-rech-card {
    background: #fff;
    border: 1px solid #f0e8e8;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: row;
    gap: 20px;
    transition: background 0.2s, box-shadow 0.25s;
    list-style: none;
    overflow: hidden;
}

.aem-rech-card:hover {
    background: #fff5f5;
    box-shadow: 0 8px 32px rgba(186, 0, 49, 0.06);
}

/* Zone image / placeholder */
.aem-rech-card-img {
    flex-shrink: 0;
    width: 200px;
    min-height: 160px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aem-rech-card-img-inner {
    width: 100%;
    height: 100%;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 800;
    color: rgba(255,255,255,0.9);
    letter-spacing: -1px;
    user-select: none;
}

.aem-rech-card-img-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(26,28,28,0.88);
    color: #fff;
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    padding: 3px 7px;
    border-radius: 4px;
    backdrop-filter: blur(8px);
}

/* Contenu de la card */
.aem-rech-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.aem-rech-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.aem-rech-card-info {
    flex: 1;
    min-width: 0;
}

.aem-rech-card-name {
    font-size: 20px;
    font-weight: 800;
    color: #1a1c1c;
    margin: 0 0 4px;
    line-height: 1.2;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Étoiles Google */
.aem-rech-stars {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.aem-rech-stars-icons {
    display: flex;
    gap: 1px;
    color: #ba0031;
    font-size: 14px;
}

.aem-rech-stars-icons .star-filled { color: #ba0031; }
.aem-rech-stars-icons .star-half   { color: #ba0031; opacity: 0.6; }
.aem-rech-stars-icons .star-empty  { color: #ddd; }

.aem-rech-stars-meta {
    font-size: 11px;
    color: #777;
    font-weight: 500;
}

/* Bloc taux à droite */
.aem-rech-taux {
    flex-shrink: 0;
    text-align: right;
}

.aem-rech-taux-top-label {
    display: block;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin-bottom: 2px;
}

.aem-rech-taux-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 18px;
    color: #fff;
    white-space: nowrap;
    line-height: 1;
}

.aem-rech-taux-sub {
    display: block;
    font-size: 9px;
    color: #888;
    text-align: right;
    margin-top: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Badges CPF / Permis1€ */
.aem-rech-service-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.aem-rech-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    background: #f0f0f0;
    color: #444;
}

.aem-rech-chip--p1e   { background: #edf7ed; color: #2e7d32; }
.aem-rech-chip--cpf   { background: #e8f4fd; color: #1565c0; }
.aem-rech-chip--qual  { background: #fff8e1; color: #f57f17; }
.aem-rech-chip--aac   { background: #f3e5f5; color: #6a1b9a; }
.aem-rech-chip--cs    { background: #fce4ec; color: #c62828; }
.aem-rech-chip--ligne { background: #e8f5e9; color: #1b5e20; }

/* Formations proposées */
.aem-rech-formations {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.aem-rech-formations-label {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #999;
    width: 100%;
    margin-bottom: 2px;
}

.aem-rech-formation-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 7px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    background: #f5f5f5;
    color: #555;
    border: 1px solid #ebebeb;
}

/* Footer card */
.aem-rech-card-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f0eded;
}

.aem-rech-card-address {
    font-size: 11px;
    color: #777;
    line-height: 1.5;
}

.aem-rech-card-address-line {
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: 500;
}

.aem-rech-card-address-cp {
    font-weight: 700;
    color: #ba0031;
    margin-top: 2px;
}

.aem-rech-card-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.aem-rech-compare-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    color: #888;
    transition: color 0.15s;
    white-space: nowrap;
}

.aem-rech-compare-label:hover {
    color: #1a1c1c;
}

.aem-rech-compare-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    border: 2px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    accent-color: #ba0031;
}

.aem-rech-btn-fiche {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    background: #1a1c1c;
    color: #fff;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    min-height: 40px;
    white-space: nowrap;
    transition: background 0.2s;
}

.aem-rech-btn-fiche:hover {
    background: #ba0031;
    color: #fff;
}

/* Bouton comparer (legacy — gardé pour la compare bar) */
.aem-rech-btn-comparer {
    display: none;
}

/* ----------------------------------------------------------------
   Responsive : mobile stack
   ---------------------------------------------------------------- */
@media (max-width: 640px) {
    .aem-rech-card {
        flex-direction: column;
    }

    .aem-rech-card-img {
        width: 100%;
        min-height: 140px;
    }

    .aem-rech-card-name {
        font-size: 16px;
        white-space: normal;
    }

    .aem-rech-card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .aem-rech-card-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .aem-rech-btn-fiche {
        flex: 1;
    }
}

/* ----------------------------------------------------------------
   Pagination
   ---------------------------------------------------------------- */
.aem-rech-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #e8eaed;
}

.aem-rech-page-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border: 2px solid #e8eaed;
    background: #fff;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: #1a1c1c;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.aem-rech-page-btn:hover {
    border-color: #ba0031;
    color: #ba0031;
}

.aem-rech-page-btn[aria-current="page"] {
    background: #ba0031;
    border-color: #ba0031;
    color: #fff;
    font-weight: 700;
}

.aem-rech-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.aem-rech-page-ellipsis {
    color: #666;
    padding: 0 4px;
    font-size: 14px;
}

/* ----------------------------------------------------------------
   Barre de comparaison flottante
   ---------------------------------------------------------------- */
.aem-rech-compare-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1c1c;
    color: #fff;
    padding: 14px 20px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    z-index: 9000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
}

.aem-rech-compare-bar.is-visible {
    transform: translateY(0);
}

.aem-rech-compare-bar span {
    font-size: 14px;
    font-weight: 600;
}

.aem-rech-compare-launch {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    background: #e31e44;
    color: #fff;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    text-decoration: none;
    min-height: 44px;
    white-space: nowrap;
    transition: background 0.2s;
}

.aem-rech-compare-launch:hover {
    background: #ba0031;
    color: #fff;
}

/* ----------------------------------------------------------------
   Loading skeleton
   ---------------------------------------------------------------- */
.aem-rech-skeleton-card {
    background: #fff;
    border: 1px solid #f0e8e8;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 20px;
    overflow: hidden;
}

.aem-rech-skeleton-line {
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: aem-skeleton-shimmer 1.4s infinite;
    border-radius: 4px;
}

@keyframes aem-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ----------------------------------------------------------------
   Badges (partagés avec comparaison)
   ---------------------------------------------------------------- */
.aem-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: #f0f0f0;
    color: #444;
}

.aem-badge--permis1euro { background: #edf7ed; color: #2e7d32; }
.aem-badge--qualite     { background: #fff8e1; color: #f57f17; }
.aem-badge--aac         { background: #e8f4fd; color: #1565c0; }
.aem-badge--enligne     { background: #f3e5f5; color: #6a1b9a; }
