/* ============================================
       THREADS-STYLE REVIEW CARDS
       ============================================ */

    /* Main review: flat, NO card/shadow/border. Separator between reviews */
    .commentlist > li.review,
    .commentlist > li.comment {
        background: transparent !important;
        border: none !important;
        border-bottom: 1px solid #eff3f4 !important;
        border-radius: 0 !important;
        padding: 16px 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        list-style: none !important;
        position: relative;
    }
    .commentlist > li.review:last-child,
    .commentlist > li.comment:last-child {
        border-bottom: none !important;
    }

    /* Remove CusRev default bottom border from comment-text */
    .commentlist > li > .comment_container > .comment-text {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    /* Avatar: circular, 40px — unified for both pet and non-pet reviews */
    .amigo-pet-header .amigo-pet-avatar,
    .amg-review-header > img.avatar,
    .amg-review-header > .amg-user-avatar {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        border-radius: 50% !important;
        object-fit: cover !important;
        flex-shrink: 0 !important;
    }
    /* Hide legacy avatar outside comment-text (now inside header) */
    .commentlist > li > .comment_container > img.avatar {
        display: none !important;
    }

    /* Author name: bold, 15px */
    .commentlist > li > .comment_container .woocommerce-review__author {
        font-size: 15px !important;
        font-weight: 600 !important;
        color: #0f1419 !important;
        line-height: 1.3 !important;
    }

    /* Verified badge: subtle, inline */
    .commentlist > li > .comment_container .woocommerce-review__verified {
        font-size: 12px !important;
        color: #536471 !important;
        font-weight: 400 !important;
        display: inline !important;
    }

    /* Meta author title: horizontal layout (name + verified on one line) */
    .commentlist > li > .comment_container .cr-meta-author-title {
        display: flex !important;
        flex-direction: column !important;
        gap: 1px !important;
    }
    .commentlist > li > .comment_container .cr-meta-author-title > div:first-child {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }

    /* Hide the reply icon SVG in author area (CusRev adds it for child comments) */
    .commentlist > li > .comment_container > .comment-text > .meta .cr-meta-author-featured-date > svg {
        display: none !important;
    }

    /* Rating + date row: compact, aligned */
    .commentlist > li > .comment_container .cr-review-rating-date {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        margin: 6px 0 8px 0 !important;
        flex-wrap: wrap !important;
    }
    .commentlist > li > .comment_container .cr-review-rating-date .crstar-rating {
        font-size: 14px !important;
    }

    /* Date styling: gray, subtle */
    .commentlist > li > .comment_container .woocommerce-review__published-date {
        color: #536471 !important;
        font-size: 13px !important;
        font-weight: 400 !important;
    }
    .commentlist > li > .comment_container .woocommerce-review__relative-date {
        background: #f7f9f9 !important;
        color: #536471 !important;
        font-size: 12px !important;
        font-weight: 400 !important;
        padding: 2px 8px !important;
        border-radius: 12px !important;
    }

    /* Review text: clean, readable */
    .commentlist > li > .comment_container .cr-review-main-content {
        margin: 8px 0 !important;
    }
    .commentlist > li > .comment_container .cr-review-main-content p {
        font-size: 15px !important;
        line-height: 1.55 !important;
        color: #0f1419 !important;
        margin: 0 !important;
    }

    /* Pet info in header: compact details line */
    .amigo-pet-header {
        gap: 12px !important;
    }
    .amigo-pet-info .amigo-pet-details {
        font-size: 13px !important;
        color: #536471 !important;
        margin-top: 1px !important;
    }
    .amigo-pet-info .amigo-pet-friends {
        font-size: 12px !important;
        color: #536471 !important;
        margin-top: 2px !important;
    }

    /* All reviews: avatar is inside header now, so comment-text is full width */
    .comment_container > .comment-text {
        margin-left: 0 !important;
    }

    /* ============================================
       ACTIONS ROW: reply, edit/delete, voting
       ============================================ */

    /* Fix 6: Actions row — no border, cleaner Threads-like */
    .amg-actions-row {
        display: flex;
        align-items: center;
        gap: 4px;
        margin-top: 8px;
        padding-top: 6px;
        border-top: none;
    }
    /* Even less spacing in replies */
    .commentlist ul.children .amg-actions-row {
        padding-top: 4px !important;
        margin-top: 4px !important;
    }

    /* Reply button: Threads-like icon button */
    .amg-reply-btn {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: none;
        border: none;
        border-radius: 20px;
        padding: 6px 14px;
        font-size: 13px;
        color: #536471;
        cursor: pointer;
        transition: all 0.15s ease;
    }
    .amg-reply-btn:hover {
        background: #f7f9f9;
        color: #4a9e6e;
    }
    .amg-reply-btn svg {
        flex-shrink: 0;
    }

    /* Voting container: Threads-like */
    .cr-voting-cont,
    .cr-voting-cont-uni {
        margin-top: 0 !important;
        padding: 0 !important;
    }

    /* Fix 1: Reddit/Threads-like voting pill */
    .cr-voting-cont-uni {
        display: inline-flex !important;
        align-items: center !important;
        gap: 2px !important;
        background: #f7f9f9;
        border-radius: 20px;
        padding: 2px 6px;
    }
    .cr-voting-cont-uni span.cr-voting-upvote,
    .cr-voting-cont-uni span.cr-voting-downvote {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 28px !important;
        height: 28px !important;
        border-radius: 50% !important;
        transition: background 0.15s !important;
        cursor: pointer !important;
    }
    .cr-voting-cont-uni span.cr-voting-upvote:hover {
        background: #ecfdf5 !important;
    }
    .cr-voting-cont-uni span.cr-voting-downvote:hover {
        background: #fff1f2 !important;
    }
    .cr-voting-cont-uni span.cr-voting-upvote.cr-voting-active {
        background: #ecfdf5 !important;
    }
    .cr-voting-cont-uni span.cr-voting-upvote.cr-voting-active svg .cr-voting-svg-ext {
        fill: #059669 !important;
    }
    .cr-voting-cont-uni span.cr-voting-upvote.cr-voting-active svg .cr-voting-svg-int {
        fill: #059669 !important;
        fill-opacity: 0.3 !important;
    }
    .cr-voting-cont-uni span.cr-voting-downvote.cr-voting-active {
        background: #fff1f2 !important;
    }
    .cr-voting-cont-uni span.cr-voting-downvote.cr-voting-active svg .cr-voting-svg-ext {
        fill: #dc2626 !important;
    }
    .cr-voting-cont-uni span.cr-voting-downvote.cr-voting-active svg .cr-voting-svg-int {
        fill: #dc2626 !important;
        fill-opacity: 0.3 !important;
    }
    .cr-voting-cont-uni span.cr-voting-upvote-count,
    .cr-voting-cont-uni span.cr-voting-downvote-count {
        font-size: 12px !important;
        font-weight: 500 !important;
        color: #536471 !important;
        min-width: 14px;
        text-align: center;
    }
    .cr-voting-cont-uni svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* Reply form */
    .amg-reply-form {
        margin-top: 12px;
    }
    .amg-reply-form-inner {
        background: #f7f9f9;
        border: none;
        border-radius: 12px;
        padding: 14px;
    }
    .amg-reply-text {
        width: 100%;
        border: 1px solid #eff3f4;
        border-radius: 12px;
        padding: 12px;
        font-size: 15px;
        font-family: inherit;
        resize: vertical;
        min-height: 60px;
        box-sizing: border-box;
        background: #fff;
        transition: border-color 0.15s;
    }
    .amg-reply-text:focus {
        border-color: #4a9e6e;
        outline: none;
    }
    .amg-reply-fields {
        display: flex;
        gap: 10px;
        margin-top: 10px;
    }
    .amg-reply-fields input {
        flex: 1;
        border: 1px solid #eff3f4;
        border-radius: 12px;
        padding: 10px 12px;
        font-size: 14px;
        font-family: inherit;
        background: #fff;
        transition: border-color 0.15s;
    }
    .amg-reply-fields input:focus {
        border-color: #4a9e6e;
        outline: none;
    }
    .amg-reply-actions {
        display: flex;
        gap: 10px;
        margin-top: 12px;
    }
    .amg-reply-submit {
        background: #4a9e6e;
        color: #fff;
        border: none;
        border-radius: 20px;
        padding: 8px 24px;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: background 0.15s;
    }
    .amg-reply-submit:hover {
        background: #3d8a5e;
    }
    .amg-reply-submit:disabled {
        background: #aaa;
        cursor: not-allowed;
    }
    .amg-reply-cancel {
        background: none;
        border: 1px solid #eff3f4;
        border-radius: 20px;
        padding: 8px 20px;
        font-size: 14px;
        color: #536471;
        cursor: pointer;
        transition: all 0.15s;
    }
    .amg-reply-cancel:hover {
        border-color: #cfd9de;
        background: #f7f9f9;
    }
    .amg-reply-message {
        margin-top: 10px;
        padding: 10px 14px;
        border-radius: 12px;
        font-size: 14px;
    }
    .amg-reply-message.amg-success {
        background: #e8f5e9;
        color: #2e7d32;
    }
    .amg-reply-message.amg-error {
        background: #ffebee;
        color: #c62828;
    }

    /* Pet selector inside reply form */
    .amg-reply-pet-select .amigo-rps-item {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 6px 12px;
        border: 1px solid #eff3f4;
        border-radius: 999px;
        background: #fff;
        cursor: pointer;
        font-size: 13px;
        transition: border-color 0.15s, background 0.15s;
    }
    .amg-reply-pet-select .amigo-rps-item.selected,
    .amg-reply-pet-select .amigo-rps-item:has(input:checked) {
        border-color: #4a9e6e;
        background: #ecfdf5;
    }
    .amg-reply-pet-select .amigo-rps-item input[type="radio"] {
        display: none;
    }
    .amg-reply-pet-select .amigo-rps-photo {
        width: 24px;
        height: 24px;
        flex: 0 0 24px;
        border-radius: 50%;
        overflow: hidden;
        background: #e2e8f0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
    }
    .amg-reply-pet-select .amigo-rps-photo img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        display: block !important;
    }

    /* ============================================
       EDIT / DELETE ACTION BUTTONS
       ============================================ */
    .amg-comment-actions {
        display: inline-flex;
        gap: 4px;
        margin: 0;
    }
    .amg-edit-btn,
    .amg-delete-btn {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        border-radius: 20px;
        padding: 4px 10px;
        font-size: 12px;
        cursor: pointer;
        transition: all 0.15s;
        color: #536471;
    }
    .amg-edit-btn:hover {
        color: #4a9e6e;
        background: #f0fdf4;
    }
    .amg-delete-btn:hover {
        color: #c62828;
        background: #fff5f5;
    }
    .amg-edit-btn svg,
    .amg-delete-btn svg {
        flex-shrink: 0;
    }

    /* Inline edit mode */
    .amg-edit-area {
        width: 100%;
        border: 1px solid #4a9e6e;
        border-radius: 12px;
        padding: 12px;
        font-size: 15px;
        font-family: inherit;
        resize: vertical;
        min-height: 60px;
        box-sizing: border-box;
        margin: 8px 0;
    }
    .amg-edit-actions {
        display: flex;
        gap: 8px;
        margin-top: 6px;
    }
    .amg-edit-save {
        background: #4a9e6e;
        color: #fff;
        border: none;
        border-radius: 20px;
        padding: 6px 16px;
        font-size: 13px;
        cursor: pointer;
    }
    .amg-edit-save:hover { background: #3d8a5e; }
    .amg-edit-save:disabled { background: #aaa; cursor: not-allowed; }
    .amg-edit-cancel-btn {
        background: none;
        border: 1px solid #eff3f4;
        border-radius: 20px;
        padding: 6px 14px;
        font-size: 13px;
        color: #536471;
        cursor: pointer;
    }
    .amg-edit-cancel-btn:hover { border-color: #cfd9de; }

    /* Delete confirmation overlay */
    .amg-delete-confirm {
        background: #fff5f5;
        border: 1px solid #fecaca;
        border-radius: 12px;
        padding: 14px 16px;
        margin-top: 10px;
        font-size: 14px;
    }
    .amg-delete-confirm p {
        margin: 0 0 10px;
        color: #c62828;
    }
    .amg-delete-yes {
        background: #c62828;
        color: #fff;
        border: none;
        border-radius: 20px;
        padding: 6px 16px;
        font-size: 13px;
        cursor: pointer;
        margin-right: 8px;
    }
    .amg-delete-yes:hover { background: #b71c1c; }
    .amg-delete-yes:disabled { background: #aaa; cursor: not-allowed; }
    .amg-delete-no {
        background: none;
        border: 1px solid #eff3f4;
        border-radius: 20px;
        padding: 6px 14px;
        font-size: 13px;
        color: #536471;
        cursor: pointer;
    }
    .amg-delete-no:hover { border-color: #cfd9de; }

    /* ============================================
       THREADS-LIKE REPLY DISPLAY (all depths)
       ============================================ */

    /* Override CusRev: always show ul.children, add thread line + indent */
    .commentlist ul.children {
        display: block !important;
        margin: 0 0 0 20px !important;
        padding: 0 0 0 20px !important;
        border: none !important;
        border-left: 1.5px solid #e8ecee !important;
        list-style: none !important;
        position: relative;
    }
    /* Override CusRev's high-specificity AJAX selector (margin-inline-start: 70px) */
    #reviews.cr-reviews-ajax-reviews #comments.cr-reviews-ajax-comments .cr-ajax-reviews-list ul.children,
    .cr-all-reviews-shortcode ol.commentlist ul.children {
        margin: 0 !important;
        margin-left: 20px !important;
        padding: 0 !important;
        padding-left: 20px !important;
        border-left: 1.5px solid #e8ecee !important;
    }
    /* Remove the old toggle button */
    .cr-toggle-replies {
        display: none !important;
    }
    /* Remove cr-replies-expanded dependency */
    .commentlist li.cr-replies-expanded > ul.children {
        display: block !important;
    }
    /* Deeper nesting: slightly less indent */
    .commentlist ul.children ul.children {
        margin-left: 14px !important;
        padding-left: 14px !important;
    }

    /* Reply items: flat, NO background/border/radius. Thread line is enough */
    .commentlist ul.children > li {
        padding: 8px 0 !important;
        margin-bottom: 0 !important;
        background: transparent !important;
        border-radius: 0 !important;
        border: none !important;
        position: relative;
        list-style: none !important;
    }
    .commentlist ul.children > li:first-child {
        margin-top: 6px !important;
    }

    /* Fix 7: Cap indentation at depth 3+ */
    .commentlist ul.children ul.children ul.children {
        margin-left: 0 !important;
        padding-left: 12px !important;
        border-left-style: dashed !important;
    }
    .commentlist ul.children ul.children ul.children ul.children {
        margin-left: 0 !important;
        padding-left: 0 !important;
        border-left: none !important;
    }
    .commentlist ul.children ul.children ul.children > li {
        background: transparent !important;
    }

    /* First reply: always visible (all depths) */
    .commentlist ul.children > li:first-child {
        display: list-item !important;
    }

    /* Extra replies (2+): hidden by default via JS class */
    .commentlist ul.children > li.amg-thread-hidden {
        display: none !important;
    }
    /* When expanded, show all */
    .commentlist li.amg-thread-expanded > ul.children > li.amg-thread-hidden {
        display: list-item !important;
    }

    /* Fix 8: "Show more" wrapper — higher-specificity selector */
    .commentlist ul.children > li.amg-thread-more-wrap {
        background: none !important;
        padding: 4px 0 0 0 !important;
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        list-style: none !important;
    }
    /* "Показати ще N відповідей" button */
    .amg-thread-more {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: #4a9e6e;
        font-size: 13px;
        font-weight: 500;
        padding: 8px 0 4px 0;
        margin: 0;
        cursor: pointer;
        transition: color 0.15s;
        line-height: 1.4;
    }
    .amg-thread-more:hover {
        color: #3d8a5e;
        text-decoration: underline;
    }
    .amg-thread-more:focus {
        outline: none;
        box-shadow: none;
    }

    /* Reply text inside thread (all depths) */
    .commentlist ul.children .comment-text {
        font-size: 14px !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .commentlist ul.children .woocommerce-review__author {
        font-size: 14px !important;
        font-weight: 600 !important;
        color: #0f1419 !important;
    }
    .commentlist ul.children .cr-review-main-content p {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }
    /* Tighten meta in replies */
    .commentlist ul.children .meta {
        margin-bottom: 4px !important;
    }
    .commentlist ul.children .cr-review-rating-date {
        margin: 3px 0 6px 0 !important;
    }

    /* Fix 11: Remove connector dots */
    .commentlist ul.children::before {
        display: none !important;
    }

    /* Fix 5: Hide avatars in replies for non-pet reviews */
    .commentlist ul.children .amg-review-header > img.avatar,
    .commentlist ul.children .amg-review-header > .amg-user-avatar {
        display: none !important;
    }
    .commentlist ul.children .amg-review-header {
        gap: 0 !important;
    }

    /* Fix 4: Hide verbose pet info in replies — show only avatar + name */
    .commentlist ul.children .amigo-pet-details,
    .commentlist ul.children .amigo-pet-friends {
        display: none !important;
    }
    /* Smaller pet avatar in replies */
    .commentlist ul.children .amigo-pet-avatar {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
    }
    .commentlist ul.children .amigo-pet-header {
        gap: 8px !important;
    }

    /* Reply button inside thread: smaller */
    .commentlist ul.children .amg-reply-btn {
        font-size: 12px;
        padding: 4px 10px;
        margin-top: 4px;
    }
    .commentlist ul.children .amg-reply-btn svg {
        width: 12px;
        height: 12px;
    }
    /* Reply form inside thread: tighter */
    .commentlist ul.children .amg-reply-form-inner {
        padding: 12px;
    }
    .commentlist ul.children .amg-reply-text {
        font-size: 14px;
        min-height: 50px;
    }

    /* ============================================
       PET REVIEW CARD: inline chips for pet card
       ============================================ */
    /* Pet card in review body */
    .amigo-review-pet {
        border-radius: 10px !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* ============================================
       PROS/CONS: refine for card context
       ============================================ */
    .cr-review-pros-cons-wrapper {
        margin: 8px 0 4px 0 !important;
    }
    .cr-review-pros-cons-wrapper p.ivf-custom-question-p {
        border-radius: 12px !important;
    }

    /* ============================================
       VOTING: tighter in card
       ============================================ */
    .commentlist > li > .comment_container .cr-voting-cont,
    .commentlist > li > .comment_container .cr-voting-cont-uni {
        margin: 0 !important;
    }

    /* ============================================
       REVIEW IMAGES: rounded in card context
       ============================================ */
    .commentlist .cr-comment-images img {
        border-radius: 12px !important;
    }

    /* ============================================
       MOBILE RESPONSIVE
       ============================================ */
    @media (max-width: 600px) {
        .commentlist > li.review,
        .commentlist > li.comment {
            padding: 12px 0 !important;
        }
        .commentlist > li > .comment_container .cr-review-main-content p {
            font-size: 14px !important;
        }
        /* Mobile deep nesting — must use high-specificity selector for AJAX context */
        .commentlist ul.children,
        #reviews.cr-reviews-ajax-reviews #comments.cr-reviews-ajax-comments .cr-ajax-reviews-list ul.children {
            margin-left: 8px !important;
            padding-left: 12px !important;
        }
        .commentlist ul.children > li {
            padding: 6px 0 !important;
        }
        .commentlist ul.children ul.children {
            margin-left: 0 !important;
            padding-left: 8px !important;
        }
        .commentlist ul.children ul.children ul.children {
            margin-left: 0 !important;
            padding-left: 0 !important;
            border-left: none !important;
        }
        .amg-reply-fields {
            flex-direction: column;
        }
    }

    /* ============================================
       CLS FIXES FOR /vidguky-amigovet/ PAGE
       ============================================ */

    /* Reserve space for summary bar + add review form */
    .cr-all-reviews-shortcode .cr-summaryBox-wrap {
        min-height: 120px;
    }
    .cr-all-reviews-shortcode .cr-review-form-wrap {
        contain: layout;
    }

    /* Constrain review images to prevent CLS */
    .cr-comment-images a {
        display: inline-block;
        max-width: 100px;
        max-height: 100px;
        overflow: hidden;
    }
    .cr-comment-images img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* Unified review header — avatar + info in a row */
    .amg-review-header,
    .amigo-pet-header {
        display: flex !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .amg-review-header > img.avatar {
        border-radius: 50% !important;
        object-fit: cover !important;
    }

    /* Layout isolation for review cards */
    .cr-all-reviews-shortcode .commentlist > li {
        contain: content;
    }
