/**
 * Module aw_reviews - Styles front
 *
 * La couleur des étoiles vient de la configuration du module, injectée en
 * variable CSS sur le bloc : --aw-star-color.
 *
 * @author Alexandre MERY - ACMP-WEB
 */

.aw-reviews,
.aw-page,
.aw-home-widget,
.aw-modal {
    --aw-star-color: #f2b01e;
    --aw-star-off: #d9d9d9;
    --aw-line: #e6e6e6;
    --aw-muted: #7a7a7a;
    --aw-soft: #fafafa;
    --aw-verified: #2f8a3b;
    --aw-verified-bg: #eaf5ec;
    --aw-pending: #9a6400;
    --aw-pending-bg: #fff4e5;
}

/* ---- Étoiles ----------------------------------------------------------- */
.aw-stars { display: inline-flex; gap: 1px; line-height: 1; color: var(--aw-star-off); vertical-align: middle; }
.aw-stars .is-on { color: var(--aw-star-color); }
.aw-stars--sm { font-size: 14px; }
.aw-stars--md { font-size: 17px; }
.aw-stars--lg { font-size: 22px; }

.aw-rating-input { display: inline-flex; flex-direction: row-reverse; gap: 2px; }
.aw-rating-input input { position: absolute; opacity: 0; width: 0; height: 0; }
.aw-rating-input label {
    margin: 0; font-size: 24px; line-height: 1; color: var(--aw-star-off);
    cursor: pointer; transition: color .15s ease;
}
.aw-rating-input input:checked ~ label,
.aw-rating-input label:hover,
.aw-rating-input label:hover ~ label { color: var(--aw-star-color); }
.aw-rating-input input:focus-visible + label { outline: 2px solid var(--aw-star-color); outline-offset: 2px; }

/* ---- Grille du bloc ---------------------------------------------------- */
.aw-reviews {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 48px;
    align-items: start;
    margin: 24px 0;
}

/* En-tête : la mise en forme vient des classes du thème
   (tvcms-main-title / tvmain-sub-title / tvmain-title). Il occupe toute la
   largeur, au-dessus des deux colonnes du bloc. */
.aw-reviews__heading { grid-column: 1 / -1; }
.aw-reviews__heading h2,
.aw-reviews__heading h4 { margin: 0; }

/* ---- Colonne de synthèse ----------------------------------------------- */
.aw-summary__title { margin: 0 0 4px; font-size: 24px; font-weight: 400; }
.aw-summary__score { font-size: 40px; font-weight: 700; line-height: 1.1; }
.aw-summary__count { display: block; margin-top: 2px; color: var(--aw-muted); font-size: 14px; }
.aw-summary__hint { margin: 22px 0 10px; font-size: 14px; }
.aw-summary__none { color: var(--aw-muted); }

.aw-bars { list-style: none; margin: 0 0 18px; padding: 0; }
.aw-bars button {
    display: grid; grid-template-columns: 12px auto 1fr 32px;
    align-items: center; gap: 8px;
    width: 100%; padding: 4px 6px; margin-left: -6px;
    background: none; border: 0; border-radius: 4px;
    font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.aw-bars button:hover { background: var(--aw-soft); }
.aw-bars button[aria-pressed="true"] { background: #fff6dd; }
.aw-bars__note { color: var(--aw-muted); font-size: 13px; }
.aw-bars__track { height: 6px; background: #efefef; border-radius: 3px; overflow: hidden; }
.aw-bars__fill { display: block; height: 100%; background: var(--aw-star-color); }
.aw-bars__nb { color: var(--aw-muted); font-size: 13px; text-align: right; }

.aw-reset {
    display: none; margin-bottom: 20px; padding: 0;
    background: none; border: 0; font: inherit;
    text-decoration: underline; cursor: pointer;
}
.aw-reset.is-visible { display: inline; }

.aw-cta { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--aw-line); }
.aw-cta p { margin: 0 0 10px; font-size: 14px; }
.aw-cta__btn {
    display: block; width: 100%; padding: 11px 16px;
    background: #232323; color: #fff; border: 0; border-radius: 4px;
    font: inherit; font-weight: 600; text-align: center; cursor: pointer;
}
.aw-cta__btn:hover { background: #000; color: #fff; }

/* ---- Barre d'outils ---------------------------------------------------- */
.aw-toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding-bottom: 14px; border-bottom: 1px solid var(--aw-line);
}
.aw-toolbar label { margin: 0; color: var(--aw-muted); font-size: 14px; font-weight: 400; }
.aw-toolbar select { max-width: 220px; }
.aw-toolbar__filtered { color: var(--aw-muted); font-size: 13px; }
.aw-write {
    margin-left: auto; padding: 9px 18px;
    background: #232323; color: #fff; border: 0; border-radius: 4px;
    font: inherit; font-weight: 600; cursor: pointer;
}
.aw-write:hover { background: #000; }

.aw-items.is-loading { opacity: .5; pointer-events: none; }

/* ---- Un avis ----------------------------------------------------------- */
.aw-item {
    display: grid;
    grid-template-columns: 108px 190px minmax(0, 1fr);
    gap: 28px;
    padding: 24px 0;
    border-bottom: 1px solid var(--aw-line);
}
.aw-item__media { display: flex; flex-wrap: wrap; gap: 6px; }
.aw-item__photo {
    position: relative; display: block; width: 100%; aspect-ratio: 1;
    padding: 0; border: 0; border-radius: 4px; overflow: hidden;
    background: #eee; cursor: zoom-in;
}
.aw-item__photo img,
.aw-item__product img { width: 100%; height: 100%; display: block; }
.aw-item__photo img { object-fit: cover; }
.aw-item__photo--more::after {
    content: attr(data-more);
    position: absolute; right: 4px; bottom: 4px;
    padding: 1px 7px; border-radius: 10px;
    background: rgba(0, 0, 0, .62); color: #fff; font-size: 12px; font-weight: 600;
}
.aw-item__avatar {
    width: 56px; height: 56px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 17px; font-weight: 700; letter-spacing: .5px;
}
.aw-item__product {
    width: 100%; aspect-ratio: 1; border-radius: 4px; overflow: hidden;
    background: var(--aw-soft); border: 1px solid #f0f0f0;
}
.aw-item__product img { object-fit: contain; }

.aw-item__meta { font-size: 14px; }
.aw-item__author { margin: 6px 0 2px; font-size: 16px; font-weight: 600; }
.aw-item__date { color: var(--aw-muted); font-style: italic; }

.aw-badge { display: inline-block; margin-top: 8px; padding: 2px 9px; border-radius: 11px; font-size: 12px; font-weight: 600; }
.aw-badge--verified { background: var(--aw-verified-bg); color: var(--aw-verified); }
.aw-badge--pending { background: var(--aw-pending-bg); color: var(--aw-pending); }

.aw-item__product-link { display: inline-block; margin-bottom: 6px; font-size: 14px; }
.aw-item__title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.aw-item__text { margin: 0; }
.aw-item__gallery { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.aw-item__thumb {
    width: 72px; height: 72px; padding: 0; border: 0; border-radius: 4px;
    overflow: hidden; cursor: zoom-in; background: #eee;
}
.aw-item__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aw-item__recommend { margin: 10px 0 0; font-size: 13px; color: var(--aw-verified); }
.aw-item__answer {
    margin-top: 14px; padding: 12px 16px;
    background: var(--aw-soft); border-left: 3px solid var(--aw-star-color); border-radius: 0 4px 4px 0;
    font-size: 14px;
}
.aw-item__answer strong { display: block; margin-bottom: 3px; }
.aw-item__answer p { margin: 0; }
.aw-item__report {
    margin-top: 12px; padding: 0; background: none; border: 0;
    color: var(--aw-muted); font: inherit; font-size: 12px;
    text-decoration: underline; cursor: pointer;
}

.aw-empty { padding: 30px 0; color: var(--aw-muted); }
.aw-reviews__all { margin-top: 18px; font-size: 14px; }

/* ---- Pagination -------------------------------------------------------- */
.aw-pagination { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 0; }
.aw-pagination__page {
    min-width: 34px; padding: 6px 9px;
    border: 1px solid var(--aw-line); background: #fff; border-radius: 4px;
    color: inherit; text-align: center; text-decoration: none; cursor: pointer;
}
.aw-pagination__page.is-current {
    background: var(--aw-star-color); border-color: var(--aw-star-color);
    color: #fff; font-weight: 600;
}

/* ---- Modale ------------------------------------------------------------ */
.aw-modal[hidden] { display: none; }
.aw-modal {
    position: fixed; inset: 0; z-index: 1050;
    display: grid; place-items: center; padding: 24px;
    background: rgba(0, 0, 0, .45);
}
.aw-modal__dialog {
    position: relative; width: min(920px, 100%); max-height: 90vh; overflow: auto;
    background: #fff; border-radius: 6px; box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
}
.aw-modal__close {
    position: absolute; top: 12px; right: 14px; z-index: 2;
    width: 34px; height: 34px; padding: 0;
    background: none; border: 0; border-radius: 4px;
    font-size: 26px; line-height: 1; color: #555; cursor: pointer;
}
.aw-modal__close:hover { background: var(--aw-soft); color: #000; }
.aw-modal__grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 36px; padding: 34px 38px 30px; }
.aw-modal__product { text-align: center; }
.aw-modal__product img { display: block; width: 190px; height: 190px; object-fit: contain; margin: 0 auto 18px; }
.aw-modal__product h4 { margin: 0; font-size: 16px; font-weight: 400; line-height: 1.45; }
.aw-modal__required { margin: 22px 0 0; color: var(--aw-muted); font-size: 13px; }
.req { color: #c53030; }

/* ---- Formulaire -------------------------------------------------------- */
.aw-form h3 { margin: 0 0 18px; font-size: 22px; font-weight: 400; }
.aw-form__reward { margin: 0 0 20px; padding: 10px 14px; background: #fffbe6; border-radius: 4px; font-size: 14px; }
.aw-form__criteria {
    display: grid; grid-template-columns: max-content auto;
    gap: 6px 20px; align-items: center; margin-bottom: 22px;
}
.aw-form__criterion { display: contents; }
.aw-form__criterion span { margin: 0; font-size: 15px; }

.aw-field { margin-bottom: 16px; }
.aw-field label { display: block; margin-bottom: 5px; font-size: 14px; font-weight: 600; }
.aw-field input[type="text"], .aw-field textarea { width: 100%; }
.aw-field textarea { min-height: 110px; resize: vertical; }

.aw-form__row { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 18px; font-size: 14px; }
.aw-form__row label { margin: 0; font-weight: 400; }

.aw-upload { margin-bottom: 6px; }
.aw-upload__btn {
    width: 100%; padding: 12px 16px;
    background: #fff; border: 1px dashed #b9b9b9; border-radius: 4px;
    font: inherit; font-weight: 600; cursor: pointer;
}
.aw-upload__btn:hover { border-color: #232323; background: var(--aw-soft); }
.aw-upload__btn[disabled] { opacity: .5; cursor: not-allowed; }
.aw-upload__hint { margin: 6px 0 0; color: var(--aw-muted); font-size: 13px; }
.aw-upload__previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.aw-upload__thumb { position: relative; width: 68px; height: 68px; border-radius: 4px; overflow: hidden; background: #eee; }
.aw-upload__thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.aw-upload__thumb button {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; padding: 0;
    background: rgba(0, 0, 0, .6); color: #fff; border: 0; border-radius: 50%;
    font-size: 12px; line-height: 1; cursor: pointer;
}

.aw-form__feedback:not(:empty) { margin: 14px 0; padding: 10px 14px; border-radius: 4px; }
.aw-form__feedback.is-success { background: var(--aw-verified-bg); color: var(--aw-verified); }
.aw-form__feedback.is-error { background: #fdecea; color: #b3261e; }

.aw-form__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 22px; }
.aw-form__submit {
    padding: 11px 26px; background: #232323; color: #fff;
    border: 0; border-radius: 4px; font: inherit; font-weight: 600; cursor: pointer;
}
.aw-form__submit:hover { background: #000; }
.aw-form__submit[disabled] { opacity: .6; cursor: wait; }
.aw-form__cancel { padding: 0; background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; }
.aw-form__notice { margin: 14px 0 0; color: var(--aw-muted); font-size: 13px; text-align: right; }

/* ---- Visionneuse ------------------------------------------------------- */
.aw-lightbox[hidden] { display: none; }
.aw-lightbox {
    position: fixed; inset: 0; z-index: 1060;
    display: grid; place-items: center; padding: 32px;
    background: rgba(0, 0, 0, .82);
}
.aw-lightbox img { max-width: 100%; max-height: 90vh; border-radius: 4px; }
.aw-lightbox__close {
    position: absolute; top: 16px; right: 20px;
    width: 40px; height: 40px; padding: 0;
    background: none; border: 0; color: #fff; font-size: 32px; line-height: 1; cursor: pointer;
}

/* ---- Moyennes par critère (colonne de synthèse) ------------------------ */
.aw-criteria { list-style: none; margin: 0 0 18px; padding: 0; }
.aw-criteria li { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.aw-criteria__name { font-size: 13px; color: var(--aw-muted); }

/* ---- Page de dépôt depuis l'email de relance --------------------------- */
.aw-submit__form { padding: 24px; border: 1px solid var(--aw-line); border-radius: 6px; margin-bottom: 24px; }
.aw-submit__product { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.aw-submit__product img { width: 72px; height: 72px; object-fit: contain; border-radius: 4px; background: var(--aw-soft); }
.aw-submit__product h3 { margin: 0; font-size: 17px; }
.aw-form__criterion-name { color: var(--aw-muted); font-size: 13px; }

/* ---- Page « tous les avis » et espace client --------------------------- */
.aw-page__header { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 24px; }
.aw-page__average { font-size: 40px; font-weight: 700; line-height: 1; }
.aw-page__count { color: var(--aw-muted); }
.aw-account__row { border-bottom: 0; }

/* ---- Étoiles compactes (sous le prix, miniatures de liste) -------------
   La taille est appliquée ici, et non sur .aw-stars--sm : cette classe sert
   aussi aux lignes de répartition, aux moyennes par critère et au carrousel,
   qui doivent rester compacts. */
.aw-summary--inline { display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; margin-bottom: 5px; }
/* Produit sans avis : hauteur réservée pour l'alignement des vignettes.
   Mêmes marges que le bloc rempli, sinon les vignettes se désalignent. */
.aw-summary--empty { display: block; height: 24px; }
.aw-summary--inline .aw-stars { font-size: 24px; }
.aw-summary--inline a,
.aw-summary__link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.aw-summary__link:hover { text-decoration: none; }

/* Cible de l'ancre : on laisse la place d'un en-tête fixe au-dessus du bloc. */
#aw-reviews { scroll-margin-top: 110px; }
.aw-summary__count-inline { color: var(--aw-muted); font-size: 14px; }

/* ---- Widget accueil ---------------------------------------------------- */
.aw-home-widget {
    margin: 30px 0;
    clear: both;
    max-width: 100%;
    box-sizing: border-box;
    background: #fff;
    border-radius: 6px;
}
/* Une grille impose sinon sa largeur intrinsèque au parent :
   min-width 0 autorise le bloc à se rétrécir au conteneur du thème. */
.aw-home-widget, .aw-home-widget__track { min-width: 0; }
.aw-home-widget * { box-sizing: border-box; }

/* Étoiles du bloc d'accueil : la note moyenne comme celles de chaque avis. */
.aw-home-widget .aw-stars--sm { font-size: 22px; }

/* Titres : la mise en forme vient des classes du thème
   (tvcms-main-title / tvmain-sub-title / tvmain-title). */
.aw-home-widget__heading h2,
.aw-home-widget__heading h4 { margin: 0; }

.aw-home-widget__average {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    margin: 0 0 20px; color: var(--aw-muted); font-size: 14px;
}

/* Carrousel : n avis de front (variable --aw-home-cols posée par le template),
   les suivants accessibles au défilement horizontal. */
.aw-home-widget__carousel { position: relative; }
.aw-home-widget__track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: calc((100% - (var(--aw-home-cols, 4) - 1) * 16px) / var(--aw-home-cols, 4));
    gap: 16px;
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding-bottom: 4px;
}
.aw-home-widget__track::-webkit-scrollbar { display: none; }
.aw-home-widget__item { scroll-snap-align: start; }

.aw-home-widget__nav {
    position: absolute; top: 50%; z-index: 2;
    width: 36px; height: 36px; margin-top: -18px; padding: 0;
    display: grid; place-items: center;
    background: #fff; border: 1px solid var(--aw-line); border-radius: 50%;
    font-size: 22px; line-height: 1; color: inherit; cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}
.aw-home-widget__nav:hover { background: var(--aw-soft); }
.aw-home-widget__nav--prev { left: -18px; }
.aw-home-widget__nav--next { right: -18px; }
.aw-home-widget__item {
    padding: 16px;
    border: 1px solid var(--aw-line);
    border-radius: 6px;
    background: #fff;
}
.aw-home-widget__item h3 { font-size: 15px; margin: 8px 0 4px; }
.aw-home-widget__content { font-size: 14px; }
.aw-home-widget__product { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.aw-home-widget__product img { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; }
.aw-home-widget__item footer { margin-top: 10px; font-size: 12px; color: var(--aw-muted); }
.aw-home-widget__all { margin: 18px 0 0; text-align: center; font-size: 14px; }

@media (max-width: 991px) {
    .aw-home-widget__track { grid-auto-columns: calc((100% - 16px) / 2); }
    .aw-home-widget__nav { display: none; }
}
@media (max-width: 575px) {
    .aw-home-widget__track { grid-auto-columns: 88%; }
}

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 991px) {
    .aw-reviews { grid-template-columns: 1fr; gap: 28px; }
    .aw-item { grid-template-columns: 84px minmax(0, 1fr); gap: 18px; }
    .aw-item__meta { grid-column: 2; }
    .aw-item__body { grid-column: 1 / -1; }
    .aw-write { width: 100%; margin-left: 0; }

    .aw-modal { padding: 0; }
    .aw-modal__dialog { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; }
    .aw-modal__grid { grid-template-columns: 1fr; gap: 22px; padding: 26px 20px; }
    .aw-modal__product img { width: 120px; height: 120px; margin-bottom: 10px; }
    .aw-modal__required { display: none; }
    .aw-form__criteria { grid-template-columns: 1fr; gap: 2px; }
    .aw-form__criterion span { margin-top: 8px; }
    .aw-form__actions { justify-content: space-between; }
}
