/* ============================================================
   3DST Reviews — стили формы отзыва.
   Версия 1.8 — компактная drop-zone, единое превью,
   лайтбокс, кастомные уведомления.
   ============================================================ */

.ewr-review-section {
    margin: 16px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
}

/* ============================================================
   КНОПКА ОТКРЫТИЯ ФОРМЫ
   ============================================================ */
.ewr-open-form {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    border-radius: 10px;
    background: #2d9d78;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    border: 2px solid #2d9d78;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    text-align: center;
    box-sizing: border-box;
}

.ewr-open-form::before {
    content: '⭐';
    font-size: 16px;
    line-height: 1;
}

.ewr-open-form:hover {
    background: #247a5c;
    border-color: #247a5c;
}

.ewr-open-form:active {
    transform: scale(0.99);
}

.ewr-open-form[data-status="approved"],
.ewr-open-form[data-status="pending"] {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #4b5563;
    cursor: default;
}
.ewr-open-form[data-status="approved"]::before { content: '✓'; }
.ewr-open-form[data-status="pending"]::before  { content: '⏳'; }

/* ============================================================
   КАРТОЧКА ФОРМЫ
   ============================================================ */
.ewr-review-form {
    display: none;
    margin-top: 12px;
    padding: 20px 22px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #2d9d78;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    box-sizing: border-box;
}

.ewr-review-form__title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.ewr-review-form .tdps-form-group {
    margin-bottom: 14px;
}

.ewr-review-form label:not(.ewr-star) {
    display: block;
    font-weight: 600;
    font-size: 13.5px;
    color: #374151;
    margin-bottom: 6px;
    line-height: 1.3;
}

.ewr-review-form input[type="text"],
.ewr-review-form input[type="email"],
.ewr-review-form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14.5px;
    font-family: inherit;
    color: #1f2937;
    background: #ffffff;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ewr-review-form input[type="text"]:focus,
.ewr-review-form input[type="email"]:focus,
.ewr-review-form textarea:focus {
    outline: none;
    border-color: #2d9d78;
    box-shadow: 0 0 0 3px rgba(45, 157, 120, 0.15);
}

.ewr-review-form textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* ============================================================
   ПЛАШКА УВЕДОМЛЕНИЙ ВМЕСТО alert()
   Живёт в верхней части формы. Появление — плавное.
   ============================================================ */
.ewr-toast {
    display: none;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.5;
    margin-bottom: 14px;
    overflow-wrap: anywhere;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ewr-toast.is-visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.ewr-toast--error {
    background: #fef2f2;
    color: #991b1b;
    border-left: 3px solid #ef4444;
}

.ewr-toast--warning {
    background: #fffbeb;
    color: #92400e;
    border-left: 3px solid #f59e0b;
}

.ewr-toast--success {
    background: #f0fdf4;
    color: #065f46;
    border-left: 3px solid #10b981;
}

/* ============================================================
   ЗВЁЗДЫ РЕЙТИНГА
   ============================================================ */
.ewr-rating {
    display: flex;
    gap: 6px;
    padding: 4px 0;
    transition: background 0.15s ease;
    border-radius: 8px;
}

.ewr-star {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    line-height: 1;
    color: #d1d5db;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.1s ease;
    user-select: none;
    padding: 2px;
    margin: 0;
    font-weight: normal;
}

.ewr-star:hover {
    transform: scale(1.1);
}

.ewr-star.active {
    color: #f59e0b;
}

.ewr-rating.ewr-rating-required {
    background: #fef2f2;
    animation: ewr-rating-pulse 1.2s ease-in-out infinite;
}

.ewr-rating.ewr-rating-required .ewr-star {
    color: #fca5a5;
}

@keyframes ewr-rating-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
    50%      { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.15); }
}

.ewr-rating-hint {
    display: none;
    margin-top: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: #dc2626;
    line-height: 1.3;
}

.ewr-rating-hint.active {
    display: block;
}

/* ============================================================
   ПРЕВЬЮ ПРИЛОЖЕННЫХ ФАЙЛОВ
   Фото и видео — одной высоты (88px). Всё выровнено по линии.
   ============================================================ */
.ewr-media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 10px;
    align-items: flex-start;
}

.ewr-media-preview:empty {
    display: none;
}

.ewr-media-placeholder {
    position: relative;
    height: 88px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    background: #ffffff;
    box-sizing: border-box;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ewr-media-placeholder:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Фото — квадрат 88×88. */
.ewr-media-placeholder[data-media-kind="photo"] {
    width: 88px;
}

/* Видео — 16:9 от 88px, т.е. 156×88. */
.ewr-media-placeholder[data-media-kind="video"] {
    width: 156px;
    background: #000;
}

/* Общее для img и video в превью — заполняют плейсхолдер. */
.ewr-media-thumb-img,
.ewr-media-thumb-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ewr-media-thumb-video {
    pointer-events: none; /* не реагирует на встроенное управление */
    background: #000;
}

/* Плейсхолдер с спиннером. */
.ewr-media-loading {
    width: 88px;
    background: #f0fdf4;
    border-color: #a7e0c4;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.ewr-photo-spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid #c7e5d5;
    border-top-color: #2d9d78;
    border-radius: 50%;
    animation: ewr-spin 0.8s linear infinite;
}

@keyframes ewr-spin {
    to { transform: rotate(360deg); }
}

/* Кнопка удаления — ✕ в углу. */
.ewr-media-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    z-index: 2;
}

.ewr-media-placeholder:hover .ewr-media-remove,
.ewr-media-remove:focus {
    opacity: 1;
}

.ewr-media-remove:hover {
    background: #dc2626;
}

@media (hover: none) {
    .ewr-media-remove {
        opacity: 1;
        background: rgba(0, 0, 0, 0.75);
    }
}

/* ============================================================
   DROP-ZONE — КОМПАКТНАЯ ВЕРСИЯ
   ============================================================ */
.ewr-media-dropzone {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 14px 16px;
    min-height: 84px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    background: #fafbfc;
    cursor: pointer;
    text-align: left;
    transition:
        border-color 0.2s ease,
        background 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
    box-sizing: border-box;
    user-select: none;
    overflow: hidden;
}

/* Input полностью скрыт. Открывается из JS. */
.ewr-media-dropzone .ewr-media-input {
    display: none !important;
}

.ewr-media-dropzone:hover {
    border-color: #9ca3af;
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.ewr-media-dropzone:active {
    transform: scale(0.995);
}

.ewr-media-dropzone:focus,
.ewr-media-dropzone:focus-visible {
    outline: none;
    border-color: #2d9d78;
    box-shadow: 0 0 0 4px rgba(45, 157, 120, 0.15);
}

.ewr-media-dropzone.is-dragover {
    border-color: #2d9d78;
    border-style: solid;
    background: #f0fdf4;
    box-shadow: 0 0 0 4px rgba(45, 157, 120, 0.12);
}

.ewr-media-dropzone.is-dragover .ewr-media-dropzone__icon {
    transform: translateY(-3px) scale(1.08);
    color: #2d9d78;
}

.ewr-media-dropzone.is-dragover .ewr-media-dropzone__text strong {
    color: #2d9d78;
}

.ewr-media-dropzone.is-filled {
    border-color: #a7e0c4;
    background: #f6fdf9;
}

/* Иконка — компактная. */
.ewr-media-dropzone__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    color: #9ca3af;
    transition: transform 0.2s ease, color 0.2s ease;
}

.ewr-media-dropzone__icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Текстовый блок. */
.ewr-media-dropzone__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.35;
    min-width: 0;
    flex: 1;
}

.ewr-media-dropzone__text strong {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    transition: color 0.2s ease;
}

.ewr-media-dropzone__sub {
    font-size: 12px;
    color: #6b7280;
}

/* Чип с форматами. */
.ewr-media-dropzone__formats {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 10.5px;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   ЛАЙТБОКС
   Затемнение фона + увеличенное фото или видео с плеером.
   ============================================================ */
.ewr-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ewr-lightbox-in 0.2s ease;
}

@keyframes ewr-lightbox-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ewr-lightbox__img,
.ewr-lightbox__video {
    max-width: 92vw;
    max-height: 88vh;
    display: block;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

.ewr-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
    line-height: 1;
    padding: 0;
    z-index: 2;
}

.ewr-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.ewr-lightbox__close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ============================================================
   СОВМЕСТИМОСТЬ СО СТАРЫМИ КЛАССАМИ
   ============================================================ */
.ewr-photo-previews,
.ewr-video-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 0;
}

.ewr-photo-counter {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: #6b7280;
    margin: 4px 0 6px;
    line-height: 1.3;
}

.ewr-photo-counter--full {
    color: #dc2626;
    font-weight: 600;
}

.ewr-photo-thumb-wrapper,
.ewr-video-thumb-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    box-sizing: border-box;
}

.ewr-video-thumb-wrapper {
    width: 114px;
    height: 64px;
    background: #000;
}

/* ============================================================
   КНОПКИ
   ============================================================ */
.ewr-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #e5e7eb;
    align-items: center;
}

.ewr-form-actions .tdps-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 22px;
    border-radius: 8px;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.3;
    border: 2px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    min-height: 44px;
    box-sizing: border-box;
}

.ewr-form-actions .tdps-btn-primary {
    background: #2d9d78;
    border-color: #2d9d78;
    color: #ffffff;
    flex: 1 1 auto;
}

.ewr-form-actions .tdps-btn-primary:hover {
    background: #247a5c;
    border-color: #247a5c;
}

.ewr-form-actions .tdps-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ewr-form-actions .tdps-btn-secondary {
    background: transparent;
    border-color: #e5e7eb;
    color: #9ca3af;
    flex: 0 0 auto;
    padding: 11px 18px;
    min-width: 100px;
}

.ewr-form-actions .tdps-btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #6b7280;
}

/* ============================================================
   СООБЩЕНИЯ (старая плашка под формой)
   ============================================================ */
.ewr-message {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13.5px;
    line-height: 1.5;
    display: none;
    overflow-wrap: anywhere;
}

.ewr-message.success {
    display: block;
    background: #f0fdf4;
    color: #065f46;
    border-left: 3px solid #10b981;
}

.ewr-message.error {
    display: block;
    background: #fef2f2;
    color: #991b1b;
    border-left: 3px solid #ef4444;
}

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 768px) {
    .ewr-review-form {
        padding: 16px 16px;
    }
    .ewr-review-form__title {
        font-size: 15px;
    }
    .ewr-star {
        font-size: 26px;
    }
    .ewr-media-placeholder {
        height: 72px;
    }
    .ewr-media-placeholder[data-media-kind="photo"] {
        width: 72px;
    }
    .ewr-media-placeholder[data-media-kind="video"] {
        width: 128px;
    }
    .ewr-media-loading {
        width: 72px;
    }
    .ewr-media-dropzone {
        padding: 12px 14px;
        min-height: 72px;
        gap: 10px;
    }
    .ewr-media-dropzone__icon {
        width: 28px;
        height: 28px;
    }
    .ewr-media-dropzone__text strong {
        font-size: 13px;
    }
    .ewr-media-dropzone__sub {
        font-size: 11.5px;
    }
    .ewr-media-dropzone__formats {
        display: none; /* на узких экранах чип с форматами скрываем */
    }
    .ewr-form-actions {
        flex-direction: column;
    }
    .ewr-form-actions .tdps-btn {
        width: 100%;
    }
    .ewr-form-actions .tdps-btn-secondary {
        min-width: 0;
        padding: 11px 22px;
    }
    .ewr-lightbox__close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}

/* ============================================================
   МЕДИА В СПИСКЕ ОТЗЫВОВ (страница товара)
   Фото и видео — на разных строках.
   ============================================================ */
.tdps-review-media {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.tdps-review-media-block {
    display: block;
}

.tdps-review-photos,
.tdps-review-videos {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

/* Превью видео — первый кадр, без controls. */
.tdps-review-video-preview {
    position: relative;
    display: block;
    padding: 0;
    border: 1px solid var(--tdps-color-border, #e5e7eb);
    background: #000;
    border-radius: var(--tdps-radius-md, 8px);
    overflow: hidden;
    cursor: pointer;
    max-width: 200px;
    aspect-ratio: 16 / 9;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tdps-review-video-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.tdps-review-video-preview video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Иконка play. */
.tdps-review-video-preview__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

.tdps-review-video-preview__play::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-40%, -50%);
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 14px solid #ffffff;
}

.tdps-review-video-preview:hover .tdps-review-video-preview__play {
    background: rgba(45, 157, 120, 0.85);
}

/* ============================================================
   ЛАЙТБОКС
   ============================================================ */
.ewr-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: ewr-lightbox-in 0.2s ease;
}

@keyframes ewr-lightbox-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ewr-lightbox__img,
.ewr-lightbox__video {
    max-width: 92vw;
    max-height: 88vh;
    display: block;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

.ewr-lightbox__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
    line-height: 1;
    padding: 0;
    z-index: 2;
}

.ewr-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* ============================================================
   АДАПТИВ
   ============================================================ */
@media (max-width: 480px) {
    .tdps-review-video-preview {
        max-width: 160px;
    }
    .tdps-review-video-preview__play {
        width: 40px;
        height: 40px;
    }
    .ewr-lightbox__close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
}