/* ============================================
   Book Rating & Reactions Widget
   Phase 1: Community Features
   ============================================ */

.bd-rating-section {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-secondary, #1a1a2e);
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 14px;
}

.bd-rating-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

/* ── Aggregate Rating Display ── */
.bd-rating-aggregate {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.bd-rating-score {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #fff);
    line-height: 1;
}

.bd-rating-stars-display {
    display: flex;
    align-items: center;
    gap: 2px;
}

.bd-rating-stars-display .star {
    width: 20px;
    height: 20px;
    color: #fbbf24;
}

.bd-rating-stars-display .star.empty {
    color: var(--text-muted, #4a5568);
}

.bd-rating-stars-display .star.half {
    position: relative;
}

.bd-rating-count {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
}

/* ── Reaction Badges (Aggregate) ── */
.bd-reactions-display {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.bd-reaction-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
    border: 1px solid var(--border-color, rgba(255,255,255,0.08));
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
    transition: all 0.2s;
}

.bd-reaction-badge .reaction-emoji {
    font-size: 1rem;
}

.bd-reaction-badge .reaction-count {
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

/* ── User Rating Input ── */
.bd-rating-input {
    padding-top: 16px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.bd-rating-input-label {
    font-size: 0.82rem;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 10px;
    font-weight: 500;
}

.bd-rating-login-prompt {
    font-size: 0.82rem;
    color: var(--text-muted, #64748b);
    padding: 10px 0;
}

.bd-rating-login-prompt a {
    color: var(--color-primary, #6366f1);
    text-decoration: none;
    font-weight: 500;
}

.bd-rating-login-prompt a:hover {
    text-decoration: underline;
}

/* Star Input */
.bd-star-input {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    margin-bottom: 12px;
}

.bd-star-input .star-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-muted, #4a5568);
    transition: color 0.15s, transform 0.15s;
    line-height: 0;
}

.bd-star-input .star-btn:hover {
    transform: scale(1.2);
}

.bd-star-input .star-btn.active {
    color: #fbbf24;
}

.bd-star-input .star-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    stroke: none;
}

/* Reaction Toggle Buttons */
.bd-reaction-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.bd-reaction-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: var(--bg-tertiary, rgba(255,255,255,0.04));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.bd-reaction-toggle:hover {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
}

.bd-reaction-toggle.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
}

.bd-reaction-toggle .reaction-emoji {
    font-size: 1.1rem;
}

/* Mini Review Input */
.bd-review-input {
    margin-top: 12px;
}

.bd-review-textarea {
    width: 100%;
    min-height: 60px;
    max-height: 120px;
    padding: 10px 12px;
    background: var(--bg-tertiary, rgba(255,255,255,0.03));
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    color: var(--text-primary, #e2e8f0);
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

.bd-review-textarea:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
}

.bd-review-textarea::placeholder {
    color: var(--text-muted, #64748b);
}

.bd-review-charcount {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    text-align: right;
    margin-top: 4px;
}

/* Submit Button */
.bd-rating-submit {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bd-rating-submit-btn {
    padding: 8px 20px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.bd-rating-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.bd-rating-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.bd-rating-submit-status {
    font-size: 0.8rem;
    color: #10b981;
    opacity: 0;
    transition: opacity 0.3s;
}

.bd-rating-submit-status.visible {
    opacity: 1;
}

/* Delete rating link */
.bd-rating-delete {
    margin-top: 8px;
}

.bd-rating-delete-btn {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.bd-rating-delete-btn:hover {
    color: #ef4444;
}

/* ── Recent Reviews ── */
.bd-recent-reviews {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.06));
}

.bd-recent-reviews-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    margin-bottom: 10px;
}

.bd-review-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.04));
}

.bd-review-item:last-child {
    border-bottom: none;
}

.bd-review-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.bd-review-author {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.bd-review-stars {
    display: flex;
    gap: 1px;
}

.bd-review-stars .star {
    width: 12px;
    height: 12px;
    color: #fbbf24;
}

.bd-review-stars .star.empty {
    color: var(--text-muted, #4a5568);
}

.bd-review-date {
    font-size: 0.72rem;
    color: var(--text-muted, #64748b);
    margin-left: auto;
}

.bd-review-text {
    font-size: 0.82rem;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.5;
    margin-top: 4px;
}

/* ── RTL Support ── */
[dir="rtl"] .bd-rating-aggregate {
    flex-direction: row-reverse;
}

[dir="rtl"] .bd-star-input {
    direction: ltr; /* Stars always LTR */
}

[dir="rtl"] .bd-review-date {
    margin-left: 0;
    margin-right: auto;
}

[dir="rtl"] .bd-review-charcount {
    text-align: left;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .bd-rating-section {
        padding: 16px;
        margin-top: 20px;
    }

    .bd-rating-score {
        font-size: 1.6rem;
    }

    .bd-star-input .star-btn svg {
        width: 32px;
        height: 32px;
    }

    .bd-reaction-toggles {
        gap: 6px;
    }

    .bd-reaction-toggle {
        padding: 5px 10px;
        font-size: 0.75rem;
    }
}
