/* Shared comment section for products, subscriptions and articles. Same visual language as profile.css; classes are prefixed with cm- */

/* Tokens are shared by the section and the rating line next to the price */
.cm-section, .cm-top-rating {
    --cm-blue: #0078D4;
    --cm-blue-soft: #EAF3FC;
    --cm-text: #1F1F1F;
    --cm-muted: #6B6B6B;
    --cm-border: #E6E6E6;
    --cm-card: #FFFFFF;
    --cm-green: #0E7A0D;
    --cm-green-soft: #E7F4E4;
    --cm-star: #F5A623;
    --cm-star-empty: #D9D9D9;
    --cm-radius: 12px;
    --cm-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
}

.cm-section {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 16px;
    color: var(--cm-text);
    direction: rtl;
    text-align: right;
    box-sizing: border-box;
}

/* On shop pages: same outer width as .ProductDescription.section above it (90% / max 1400px plus its 40px side padding) */
.cm-section.section {
    width: 90%;
    max-width: 1480px;
    padding: 0;
}

.cm-section *, .cm-section *::before, .cm-section *::after {
    box-sizing: border-box;
}

.cm-title {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: bold;
}

.cm-card {
    background: var(--cm-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    box-shadow: var(--cm-shadow);
}

.cm-muted {
    color: var(--cm-muted);
    font-size: 12px;
}

/* ---------- Form ---------- */

.cm-form-card {
    padding: 18px 20px;
    margin-bottom: 20px;
}

.cm-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--cm-muted);
}

.cm-form textarea {
    display: block;
    width: 100%;
    min-height: 110px;
    padding: 10px 12px;
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.8;
    color: var(--cm-text);
    resize: vertical;
}

.cm-form textarea:focus {
    outline: none;
    border-color: var(--cm-blue);
    box-shadow: 0 0 0 3px var(--cm-blue-soft);
}

.cm-form-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
    margin-top: 14px;
}

.cm-rate-input {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Star 1 is on the right, matching the reading direction */
.cm-rate-star {
    border: 0;
    background: none;
    padding: 0 2px;
    font-size: 28px;
    line-height: 1;
    color: var(--cm-star-empty);
    cursor: pointer;
    transition: transform 0.1s ease, color 0.1s ease;
}

.cm-rate-star.is-on {
    color: var(--cm-star);
}

.cm-rate-star:hover {
    transform: scale(1.15);
}

.cm-rate-star:focus-visible, .cm-react:focus-visible, .cm-btn:focus-visible {
    outline: 2px solid var(--cm-blue);
    outline-offset: 2px;
}

.cm-rate-clear {
    margin-right: 10px;
    border: 0;
    background: none;
    font-family: inherit;
    font-size: 12px;
    color: var(--cm-muted);
    cursor: pointer;
    text-decoration: underline;
}

.cm-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid var(--cm-border);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.cm-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--cm-green);
}

.cm-check:has(input:checked) {
    border-color: var(--cm-green);
    background: var(--cm-green-soft);
    color: var(--cm-green);
}

.cm-hint {
    max-width: 320px;
}

.cm-form-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--cm-border);
}

.cm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 20px;
    border-radius: 8px;
    border: 1px solid var(--cm-border);
    background: var(--cm-card);
    color: var(--cm-text);
    font-family: inherit;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.cm-btn.is-primary {
    background: var(--cm-blue);
    border-color: var(--cm-blue);
    color: #fff;
}

.cm-btn.is-primary:hover {
    background: #106EBE;
    color: #fff;
}

.cm-btn[disabled] {
    opacity: 0.6;
    cursor: default;
}

.cm-login {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.cm-error {
    margin-top: 10px;
    font-size: 13px;
    color: #B3261E;
}

/* ---------- Summary ---------- */

.cm-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
    padding: 16px 20px;
    margin-bottom: 16px;
    background: var(--cm-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    box-shadow: var(--cm-shadow);
}

.cm-summary-score {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cm-summary-avg {
    font-size: 32px;
    font-weight: bold;
    line-height: 1;
}

.cm-summary-recommend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--cm-green);
}

.cm-summary-recommend svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Read-only stars: an empty row with a clipped filled row on top */
.cm-stars {
    position: relative;
    display: inline-block;
    font-size: 16px;
    line-height: 1;
    letter-spacing: 2px;
    white-space: nowrap;
}

.cm-stars-base {
    color: var(--cm-star-empty);
}

.cm-stars-fill {
    position: absolute;
    top: 0;
    right: 0;
    overflow: hidden;
    color: var(--cm-star);
}

/* ---------- List ---------- */

.cm-list-head h3 {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: bold;
}

.cm-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cm-empty {
    padding: 32px 16px;
    text-align: center;
    font-size: 14px;
    color: var(--cm-muted);
    background: var(--cm-card);
    border: 1px dashed var(--cm-border);
    border-radius: var(--cm-radius);
}

.cm-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--cm-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    box-shadow: var(--cm-shadow);
}

.cm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--cm-blue-soft);
    background-size: cover;
    background-position: center;
    color: var(--cm-blue);
    font-weight: bold;
    font-size: 16px;
}

.cm-body {
    flex: 1;
    min-width: 0;
}

.cm-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.cm-author {
    font-size: 14px;
    font-weight: bold;
}

.cm-date {
    margin-right: auto;
    font-size: 12px;
    color: var(--cm-muted);
}

.cm-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: bold;
}

.cm-badge.is-green {
    background: var(--cm-green-soft);
    color: var(--cm-green);
}

.cm-badge.is-blue {
    background: var(--cm-blue-soft);
    color: var(--cm-blue);
}

.cm-verdict {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-top: 8px;
}

.cm-recommend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--cm-green);
}

.cm-recommend svg {
    width: 15px;
    height: 15px;
}

.cm-text {
    margin: 10px 0 0;
    font-size: 14px;
    line-height: 1.9;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.cm-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}

.cm-actions-label {
    font-size: 12px;
    color: var(--cm-muted);
    margin-left: 4px;
}

.cm-react {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--cm-border);
    border-radius: 15px;
    background: #fff;
    font-family: inherit;
    font-size: 12px;
    color: var(--cm-muted);
    cursor: pointer;
}

.cm-react:hover {
    border-color: var(--cm-blue);
    color: var(--cm-blue);
}

.cm-react.is-done {
    border-color: var(--cm-blue);
    background: var(--cm-blue-soft);
    color: var(--cm-blue);
}

.cm-react svg {
    width: 14px;
    height: 14px;
}

/* Replies sit inside the parent comment */
.cm-replies {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
    padding-right: 14px;
    border-right: 2px solid var(--cm-border);
}

.cm-replies .cm-item {
    padding: 12px;
    box-shadow: none;
    background: #FAFAFA;
}

.cm-item.is-staff {
    background: #F5F9FE;
    border-color: #D5E6F7;
}

.cm-replies .cm-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

/* Recommendation counter next to the price (not clickable) */
.cm-top-rating {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    font-size: 13px;
    color: #2C2C2C;
    text-decoration: none;
}

.cm-top-rating .cm-stars {
    font-size: 14px;
}

.cm-top-rating svg {
    width: 16px;
    height: 16px;
    color: #0E7A0D;
    vertical-align: -3px;
}

@media only screen and (max-width: 992px) {
    .cm-section.section {
        width: calc(95% + 80px);
    }
}

@media only screen and (max-width: 700px) {
    .cm-section {
        margin: 24px auto;
    }

    .cm-section.section {
        width: calc(95% + 20px);
    }

    .cm-form-card {
        padding: 14px;
    }

    .cm-form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cm-form-foot .cm-btn {
        width: 100%;
    }

    .cm-item {
        padding: 12px;
        gap: 10px;
    }

    .cm-avatar {
        width: 34px;
        height: 34px;
    }

    .cm-replies {
        padding-right: 8px;
    }

    .cm-actions-label {
        display: none;
    }
}
