/*
 * 商品评价带图（yitu-site-functions modules/review-photos.php）：表单里的上传框、评价下的缩略图、
 * 评价区顶部「Fotos de clientes」、灯箱。颜色、圆角取主题 elegate 的变量（没有时用 elegate 的值）。
 * 只用本插件 yitu-sf-rp 前缀的 class；和主题表单对齐的那几条用主题的评价容器 .eg-areviews 限定。
 */

.yitu-sf-rp[hidden],
.yitu-sf-rp [hidden],
.yitu-sf-rp-lb [hidden] {
    display: none !important;
}

/* ---------- 上传框（和主题表单的每一行一样：手机上标签在上，768px 起标签占左边 30%） ---------- */
.yitu-sf-rp {
    width: 100%;
    margin: 0 0 1.4em;
}

.yitu-sf-rp__label {
    display: block;
    margin-bottom: 10px;
}

.yitu-sf-rp__optional {
    color: var(--eg-muted, #7c7c7c);
    font-size: .929em;
}

@media (min-width: 768px) {
    .eg-areviews .yitu-sf-rp {
        display: flex;
    }

    .eg-areviews .yitu-sf-rp__label {
        flex-shrink: 0;
        width: 30%;
    }

    .eg-areviews .yitu-sf-rp__body {
        flex: 1 1 auto;
        min-width: 0;
    }
}

.yitu-sf-rp__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 6px 0 0;
    list-style: none;
}

.yitu-sf-rp__item,
.yitu-sf-rp__add-item {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* 图片的选择器要比主题的 .eg-product__below .woocommerce-Tabs-panel img（height: auto）更具体，方形裁切才不会被压掉 */
.yitu-sf-rp .yitu-sf-rp__grid img.yitu-sf-rp__thumb {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    border: 1px solid var(--eg-line, #ddd);
    border-radius: var(--eg-radius, 8px);
    object-fit: cover;
}

/* 删除按钮：看起来 26px 的圆点，可点区域 44px */
.yitu-sf-rp__btn-remove {
    position: absolute;
    top: -14px;
    right: -14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    z-index: 1; /* 自己成一层，下面的圆点（::before）不会被缩略图盖住 */
}

.yitu-sf-rp__btn-remove::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 9px;
    z-index: -1;
    width: 26px;
    height: 26px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: rgb(31 41 51 / .82);
    transition: background-color 200ms ease;
}

.yitu-sf-rp__btn-remove:hover::before,
.yitu-sf-rp__btn-remove:focus-visible::before {
    background: var(--eg-l-error, #c0392b);
}

.yitu-sf-rp__btn-remove:focus-visible {
    outline: 2px solid var(--eg-focus, #68a5fe);
    outline-offset: -6px;
}

.yitu-sf-rp__item {
    z-index: 0;
}

.yitu-sf-rp__add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 1.5px dashed var(--eg-primary, #00abc5);
    border-radius: var(--eg-radius, 8px);
    background: #fff;
    color: var(--eg-primary-dark, #0097ae);
    font-size: 12px;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background-color 200ms ease;
}

.yitu-sf-rp__add:hover,
.yitu-sf-rp__add:focus-within {
    background: rgb(0 171 197 / .08);
}

.yitu-sf-rp__add:focus-within {
    outline: 2px solid var(--eg-focus, #68a5fe);
    outline-offset: 2px;
}

/* 文件框本身看不见但能被键盘聚焦（焦点框画在外面的 label 上） */
.yitu-sf-rp__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    border: 0;
    opacity: 0;
}

.yitu-sf-rp__count {
    margin: 8px 0 0;
    font-size: .929em;
    font-weight: 600;
}

.yitu-sf-rp__hint {
    margin: 8px 0 0;
    color: var(--eg-muted, #7c7c7c);
    font-size: .857em;
    line-height: 1.5;
}

.yitu-sf-rp__msg {
    margin: 8px 0 0;
    color: var(--eg-l-error, #c0392b);
    font-size: .929em;
    line-height: 1.5;
}

.yitu-sf-rp.is-busy .yitu-sf-rp__grid {
    opacity: .6;
}

.yitu-sf-rp__status {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: .929em;
}

.yitu-sf-rp__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgb(0 171 197 / .25);
    border-top-color: var(--eg-primary, #00abc5);
    border-radius: 50%;
    animation: yitu-sf-rp-spin .8s linear infinite;
}

.yitu-sf-rp__bar {
    flex-basis: 100%;
    height: 6px;
    overflow: hidden;
    border-radius: 3px;
    background: var(--eg-bg-bar, #eaeaea);
}

.yitu-sf-rp__bar-fill {
    display: block;
    width: 0;
    height: 100%;
    background: var(--eg-primary, #00abc5);
    transition: width 200ms ease;
}

.yitu-sf-rp__slow {
    flex-basis: 100%;
    color: #8a5300;
}

@keyframes yitu-sf-rp-spin {
    to {
        transform: rotate(360deg);
    }
}

/* 作者本人看自己待审的评价 */
.yitu-sf-rp-pending {
    margin: 0 0 1em;
    color: var(--eg-muted, #7c7c7c);
    font-size: .929em;
    font-style: italic;
}

/* ---------- 评价下的缩略图 ---------- */
.yitu-sf-rp-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: -.5em 0 1.5em;
    padding: 0;
    list-style: none;
}

.yitu-sf-rp-photos__item {
    margin: 0;
    padding: 0;
    list-style: none;
}

.yitu-sf-rp-photos__link,
.yitu-sf-rp-strip__link {
    display: block;
    overflow: hidden;
    border: 1px solid var(--eg-line, #ddd);
    border-radius: var(--eg-radius, 8px);
    background: var(--eg-bg-soft, #f8f8f8);
}

.yitu-sf-rp-photos__link {
    width: 80px;
    height: 80px;
}

.yitu-sf-rp-photos .yitu-sf-rp-photos__link img.yitu-sf-rp-photos__img,
.yitu-sf-rp-strip .yitu-sf-rp-strip__link img.yitu-sf-rp-strip__img {
    display: block;
    width: 100%;
    max-width: none;
    height: 100%;
    object-fit: cover;
    transition: transform 200ms ease;
}

.yitu-sf-rp-photos .yitu-sf-rp-photos__link:hover img.yitu-sf-rp-photos__img,
.yitu-sf-rp-strip .yitu-sf-rp-strip__link:hover img.yitu-sf-rp-strip__img {
    transform: scale(1.05);
}

.yitu-sf-rp-photos__link:focus-visible,
.yitu-sf-rp-strip__link:focus-visible {
    outline: 2px solid var(--eg-focus, #68a5fe);
    outline-offset: 2px;
}

/* ---------- 评价区顶部「Fotos de clientes」：一排，手机上横向滑 ---------- */
.yitu-sf-rp-strip {
    margin: 0 0 2em;
}

.yitu-sf-rp-strip__title {
    margin: 0 0 .75em;
    padding: 0;
    border: 0;
    font-size: 1.143em;
    font-weight: 700;
    line-height: 1.3;
}

.yitu-sf-rp-strip__list {
    display: flex;
    gap: 8px;
    margin: 0;
    padding: 2px 2px 8px;
    overflow-x: auto;
    list-style: none;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

.yitu-sf-rp-strip__item {
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    list-style: none;
    scroll-snap-align: start;
}

.yitu-sf-rp-strip__link {
    width: 88px;
    height: 88px;
}

@media (max-width: 575.98px) {
    .yitu-sf-rp-photos__link {
        width: 72px;
        height: 72px;
    }

    .yitu-sf-rp-strip__link {
        width: 76px;
        height: 76px;
    }
}

/* 从顶部一排跳过来时，那条评价闪一下 */
.yitu-sf-rp-flash {
    animation: yitu-sf-rp-flash 2s ease;
}

@keyframes yitu-sf-rp-flash {
    0%,
    35% {
        background-color: rgb(0 171 197 / .12);
    }

    100% {
        background-color: transparent;
    }
}

/* ---------- 灯箱（原生 <dialog>，在最顶层，盖住页头） ---------- */
.yitu-sf-rp-lock {
    overflow: hidden;
}

.yitu-sf-rp-lb {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgb(0 0 0 / .92);
    color: #fff;
}

.yitu-sf-rp-lb::backdrop {
    background: rgb(0 0 0 / .6);
}

.yitu-sf-rp-lb[open] {
    animation: yitu-sf-rp-fade 200ms ease;
}

.yitu-sf-rp-lb__stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    padding: 64px 12px 52px;
}

.yitu-sf-rp-lb__img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    object-fit: contain;
    user-select: none;
}

.yitu-sf-rp-lb__spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid rgb(255 255 255 / .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: yitu-sf-rp-spin .8s linear infinite;
}

.yitu-sf-rp-lb__error {
    position: absolute;
    top: 50%;
    right: 16px;
    left: 16px;
    margin: 0;
    transform: translateY(-50%);
    font-size: 15px;
    text-align: center;
}

.yitu-sf-rp-lb__btn-close,
.yitu-sf-rp-lb__btn-prev,
.yitu-sf-rp-lb__btn-next {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0 0 3px;
    border: 0;
    border-radius: 50%;
    background: rgb(255 255 255 / .16);
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 200ms ease;
}

.yitu-sf-rp-lb__btn-close:hover,
.yitu-sf-rp-lb__btn-prev:hover,
.yitu-sf-rp-lb__btn-next:hover,
.yitu-sf-rp-lb__btn-close:focus-visible,
.yitu-sf-rp-lb__btn-prev:focus-visible,
.yitu-sf-rp-lb__btn-next:focus-visible {
    background: rgb(255 255 255 / .32);
    color: #fff;
}

.yitu-sf-rp-lb__btn-close:focus-visible,
.yitu-sf-rp-lb__btn-prev:focus-visible,
.yitu-sf-rp-lb__btn-next:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.yitu-sf-rp-lb__btn-close {
    top: 12px;
    right: 12px;
}

.yitu-sf-rp-lb__btn-prev,
.yitu-sf-rp-lb__btn-next {
    top: 50%;
    margin-top: -22px;
}

.yitu-sf-rp-lb__btn-prev {
    left: 12px;
}

.yitu-sf-rp-lb__btn-next {
    right: 12px;
}

.yitu-sf-rp-lb__count {
    position: absolute;
    right: 0;
    bottom: 16px;
    left: 0;
    margin: 0;
    font-size: 14px;
    text-align: center;
}

@keyframes yitu-sf-rp-fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yitu-sf-rp__spinner,
    .yitu-sf-rp-lb__spinner {
        animation-duration: 2.4s;
    }

    .yitu-sf-rp-flash,
    .yitu-sf-rp-lb[open] {
        animation: none;
    }

    .yitu-sf-rp__add,
    .yitu-sf-rp__bar-fill,
    .yitu-sf-rp__btn-remove::before,
    .yitu-sf-rp-photos .yitu-sf-rp-photos__link img.yitu-sf-rp-photos__img,
    .yitu-sf-rp-strip .yitu-sf-rp-strip__link img.yitu-sf-rp-strip__img,
    .yitu-sf-rp-lb__btn-close,
    .yitu-sf-rp-lb__btn-prev,
    .yitu-sf-rp-lb__btn-next {
        transition: none;
    }

    .yitu-sf-rp-photos .yitu-sf-rp-photos__link:hover img.yitu-sf-rp-photos__img,
    .yitu-sf-rp-strip .yitu-sf-rp-strip__link:hover img.yitu-sf-rp-strip__img {
        transform: none;
    }
}
