/*********************************************************************************************
 * Rating components
 * Shared across: blog posts, events, counsellors (public + dashboard detail views)
 * Rule: all lengths in rem — no px except 0 and 1px border hairlines.
 *********************************************************************************************/

/* ── Display (read-only stars + score + count) ──────────────────────────────────────────── */

.rating-display {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.rating-stars {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.rating-star-filled { color: #7c3aed; }
.rating-star-empty  { color: #ddd6fe; }

.rating-sep {
    color: #d1d5db;
    font-size: 0.85rem;
}

.rating-score {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--default-color, #672162);
}

.rating-count {
    font-size: 0.82rem;
    color: #888;
}

/* ── Trigger area (inline, outside the dialog) ──────────────────────────────────────────── */

.rating-trigger-rated {
    padding: 0.875rem 1rem;
    background: #faf5ff;
    border: 1px solid #e9d5ff;
    border-radius: 0.75rem;
}

.rating-existing-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #888;
    white-space: nowrap;
}

.rating-existing-stars {
    font-size: 1rem;
    color: #7c3aed;
    line-height: 1;
}

.rating-existing-meta {
    font-size: 0.82rem;
    color: #aaa;
    white-space: nowrap;
}

.rating-existing-review {
    font-size: 0.88rem;
    color: #555;
    font-style: italic;
    margin-bottom: 0.5rem;
}

/* ── View-rating dialog ─────────────────────────────────────────────────────────────────── */

.rating-view-stars {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 2rem;
    color: #7c3aed;
    margin-bottom: 0.5rem;
}

.rating-view-score {
    font-size: 1rem;
    font-weight: 700;
    color: var(--default-color, #672162);
    margin-bottom: 0;
}

/* Trigger buttons — "Rate this X" and "Your rating / Update your rating" */
.rating-trigger-rate-btn,
.rating-trigger-rated-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--default-color, #672162);
    transition: font-weight 0s;
}

.rating-trigger-rate-btn:hover,
.rating-trigger-rated-btn:hover { font-weight: 700; }

.rating-trigger-rated-btn .rating-trigger-label-hover { display: none; }

.rating-trigger-rated-btn:hover .rating-trigger-label { display: none; }
.rating-trigger-rated-btn:hover .rating-trigger-label-hover { display: inline; }

/* Trigger button — stars + score inline */
.rating-existing-stars-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.1rem;
    font-size: 0.9rem;
    color: inherit;
    line-height: 1;
}

.rating-existing-meta-inline {
    font-size: 0.8rem;
    opacity: 0.85;
}

/* ── Interactive star input (shared by inline + dialog) ─────────────────────────────────── */

/*
 * Stars render in DOM order 5→1, flex row-reverse shows them 1→2→3→4→5 visually.
 * `input:checked ~ label` highlights all lower-value (visually left) stars — correct.
 * Default color is explicitly set here to override any inherited page colour.
 * The `.iconify` reset below overrides any broad `.iconify` rules in page-level CSS
 * (e.g. event-details.css) that would shrink or recolour the stars.
 */
.rating-input label .iconify {
    font-size: inherit;
    color: inherit;
}

.rating-input {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 0.15rem;
    font-size: 1.75rem;
}

.rating-input input[type="radio"] {
    display: none;
}

.rating-input label {
    cursor: pointer;
    color: #ddd6fe;             /* unselected star — always explicitly set */
    transition: color 0.12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.75rem;         /* WCAG 2.5.5 touch target ≥ 44px at 16px base */
    min-height: 2.75rem;
}

.rating-input input[type="radio"]:checked ~ label,
.rating-input label:hover,
.rating-input label:hover ~ label {
    color: #7c3aed;
}

/* Large variant for inside the dialog */
.rating-input-lg {
    font-size: 2.5rem;
    justify-content: center;
    gap: 0.35rem;
    margin: 0.75rem 0 1.5rem;
}

.rating-input-lg label {
    min-width: 3.5rem;
    min-height: 3.5rem;
}

/* ── Review textarea + character counter ────────────────────────────────────────────────── */

.rating-review-wrap textarea {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #374151;
    font-family: inherit;
    resize: vertical;
    min-height: 5rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.rating-review-wrap textarea:focus {
    border-color: var(--default-color, #672162);
}

.rating-char-count {
    font-size: 0.75rem;
    color: #aaa;
    text-align: right;
    margin-top: 0.25rem;
}

/* ── Native <dialog> ────────────────────────────────────────────────────────────────────── */

.rating-dialog {
    border: none;
    border-radius: 1rem;
    padding: 0;
    max-width: 26rem;
    width: calc(100% - 2rem);
    margin: auto;               /* centers with showModal() — same as .central-dialog */
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.2);
    background: #fff;
}

.rating-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.rating-dialog-inner {
    display: flex;
    flex-direction: column;
}

.rating-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--default-border-color, #e5e5f8);
}

.rating-dialog-title {
    flex: 1;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--default-color, #672162);
    text-transform: capitalize;
    margin: 0;
}

.rating-dialog-header-spacer {
    width: 1.75rem;
    flex-shrink: 0;
}

.rating-dialog-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #9ca3af;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.rating-dialog-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.rating-dialog-body {
    padding: 1.5rem 1.5rem 0.5rem;
    text-align: center;
}

.rating-dialog-prompt {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0;
}

.rating-dialog-body .rating-review-wrap,
.rating-dialog-body .rating-form-label-wrap {
    text-align: left;
}

.rating-form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.375rem;
}

.rating-form-label-muted {
    color: #9ca3af;
    font-weight: 400;
}

.rating-dialog-footer {
    border-top: 1px solid var(--default-border-color, #e5e5f8);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.rating-dialog-footer--centered {
    justify-content: center;
}

/* ── Dialog action buttons (self-contained — no Bootstrap dependency) ───────────────────── */

.rating-btn-cancel {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    font-size: 0.88rem;
    padding: 0.25rem 0;
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

.rating-btn-cancel:hover { color: #555; }

.rating-btn-submit {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    background: var(--default-color, #672162);
    color: #fff;
    border: none;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}

.rating-btn-submit:hover { opacity: 0.88; }

.rating-btn-danger {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 1rem;
    background: #dc2626;
    color: #fff;
    border: none;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}

.rating-btn-danger:hover { opacity: 0.88; }

/* ── Login prompt ───────────────────────────────────────────────────────────────────────── */

.rating-login-prompt {
    font-size: 0.9rem;
    color: #888;
}

.rating-login-prompt a {
    color: var(--default-color, #672162);
    font-weight: 600;
}

/* ── Mobile (36rem = 576px at 16px base) ────────────────────────────────────────────────── */

@media (max-width: 36rem) {
    .rating-stars {
        font-size: 0.95rem;
    }

    .rating-input {
        font-size: 1.5rem;
    }

    .rating-input label {
        min-width: 2.5rem;
        min-height: 2.5rem;
    }

    .rating-input-lg {
        font-size: 2rem;
    }

    .rating-input-lg label {
        min-width: 3rem;
        min-height: 3rem;
    }

    .rating-dialog {
        width: calc(100% - 1rem);
    }
}
