/*
 * XC Product Reviews Pro – Frontend Styles
 * Version: 1.0.0
 * Author:  XaniaCode (https://xaniacode.com)
 */

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
    --xc-primary:        #2563eb;
    --xc-primary-hover:  #1d4ed8;
    --xc-primary-light:  #eff6ff;
    --xc-text:           #1e293b;
    --xc-text-muted:     #64748b;
    --xc-border:         #e2e8f0;
    --xc-bg:             #f8fafc;
    --xc-white:          #ffffff;
    --xc-star:           #f59e0b;
    --xc-star-empty:     #d1d5db;
    --xc-green:          #16a34a;
    --xc-red:            #dc2626;
    --xc-seller-bg:      #fef3c7;
    --xc-seller-text:    #92400e;
    --xc-radius:         8px;
    --xc-radius-sm:      4px;
    --xc-shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --xc-shadow-md:      0 4px 12px rgba(0,0,0,.12);
    --xc-transition:     .18s ease;
    --xc-font:           inherit;
}

/* ── Base wrap ─────────────────────────────────────────────────────────────── */
.xc-reviews-wrap {
    font-family: var(--xc-font);
    color: var(--xc-text);
    max-width: 100%;
}

/* ── Stars ─────────────────────────────────────────────────────────────────── */
.xc-stars { display: inline-flex; gap: 1px; line-height: 1; }
.xc-star { font-size: 16px; color: var(--xc-star-empty); }
.xc-star--full, .xc-star--half { color: var(--xc-star); }
.xc-stars--lg .xc-star { font-size: 24px; }

/* ── Rating summary ────────────────────────────────────────────────────────── */
.xc-rating-summary {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    background: var(--xc-bg);
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius);
    padding: 24px 28px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.xc-rating-summary__avg {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    gap: 6px;
}

.xc-rating-summary__score {
    font-size: 52px;
    font-weight: 800;
    line-height: 1;
    color: var(--xc-text);
}

.xc-rating-summary__count {
    font-size: 12px;
    color: var(--xc-text-muted);
    text-align: center;
    white-space: nowrap;
}

.xc-rating-summary__breakdown {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.xc-breakdown-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.xc-breakdown-row:hover .xc-breakdown-row__fill { opacity: .85; }

.xc-breakdown-row__label {
    font-size: 13px;
    color: var(--xc-text-muted);
    white-space: nowrap;
    min-width: 32px;
    text-align: right;
}

.xc-breakdown-row__bar {
    flex: 1;
    height: 8px;
    background: var(--xc-border);
    border-radius: 999px;
    overflow: hidden;
}

.xc-breakdown-row__fill {
    height: 100%;
    background: var(--xc-primary);
    border-radius: 999px;
    transition: width .4s ease;
}

.xc-breakdown-row__count {
    font-size: 12px;
    color: var(--xc-text-muted);
    min-width: 20px;
    text-align: right;
}

/* ── Controls ──────────────────────────────────────────────────────────────── */
.xc-reviews-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.xc-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--xc-text-muted);
}

.xc-select {
    padding: 7px 10px;
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius-sm);
    background: var(--xc-white);
    font-size: 13px;
    cursor: pointer;
    color: var(--xc-text);
}

.xc-select:focus { outline: 2px solid var(--xc-primary); outline-offset: 2px; }

/* ── Filter notice ─────────────────────────────────────────────────────────── */
.xc-filter-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--xc-primary-light);
    border: 1px solid var(--xc-primary);
    border-radius: var(--xc-radius-sm);
    padding: 8px 14px;
    font-size: 13px;
    color: var(--xc-primary);
    margin-bottom: 16px;
}

.xc-filter-clear {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--xc-primary);
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.xc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--xc-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 2px solid transparent;
    transition: background var(--xc-transition), color var(--xc-transition), border-color var(--xc-transition);
    line-height: 1.3;
    text-decoration: none;
}

.xc-btn--primary {
    background: var(--xc-primary);
    color: var(--xc-white);
    border-color: var(--xc-primary);
}

.xc-btn--primary:hover, .xc-btn--primary:focus {
    background: var(--xc-primary-hover);
    border-color: var(--xc-primary-hover);
    color: var(--xc-white);
}

.xc-btn--outline {
    background: transparent;
    color: var(--xc-primary);
    border-color: var(--xc-primary);
}

.xc-btn--outline:hover, .xc-btn--outline:focus {
    background: var(--xc-primary-light);
}

.xc-btn--ghost {
    background: transparent;
    color: var(--xc-text-muted);
    border-color: var(--xc-border);
}

.xc-btn--ghost:hover { background: var(--xc-bg); }

/* ── Review list ───────────────────────────────────────────────────────────── */
.xc-reviews-list { margin-bottom: 24px; }

.xc-no-reviews {
    text-align: center;
    color: var(--xc-text-muted);
    padding: 40px 20px;
    border: 1px dashed var(--xc-border);
    border-radius: var(--xc-radius);
}

/* ── Review item ───────────────────────────────────────────────────────────── */
.xc-review-item {
    padding: 20px 0;
    border-bottom: 1px solid var(--xc-border);
}

.xc-review-item:first-child { border-top: 1px solid var(--xc-border); }

.xc-review-item__header {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.xc-avatar { border-radius: 50%; flex-shrink: 0; }

.xc-review-item__meta { display: flex; flex-direction: column; gap: 4px; }

.xc-review-item__author-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.xc-review-item__author { font-size: 15px; font-weight: 600; }

.xc-verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #dcfce7;
    color: var(--xc-green);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.xc-review-item__date { font-size: 12px; color: var(--xc-text-muted); }

.xc-review-item__body { font-size: 14px; line-height: 1.7; margin-bottom: 12px; }

/* ── Media thumbnails ──────────────────────────────────────────────────────── */
.xc-review-item__media {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.xc-media-thumb {
    width: 72px;
    height: 72px;
    border-radius: var(--xc-radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--xc-border);
    background: var(--xc-bg);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    transition: border-color var(--xc-transition), transform var(--xc-transition);
    position: relative;
}

.xc-media-thumb:hover {
    border-color: var(--xc-primary);
    transform: scale(1.04);
}

.xc-media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.xc-media-thumb--video {
    background: #1e293b;
    color: var(--xc-white);
    font-size: 10px;
}

.xc-media-play-icon {
    font-size: 22px;
    color: var(--xc-white);
    opacity: .9;
}

.xc-media-thumb__label { font-size: 10px; color: #94a3b8; }

/* ── Helpful votes ─────────────────────────────────────────────────────────── */
.xc-review-item__votes {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.xc-votes-label { font-size: 12px; color: var(--xc-text-muted); }

.xc-vote-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--xc-bg);
    border: 1px solid var(--xc-border);
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 12px;
    cursor: pointer;
    color: var(--xc-text-muted);
    transition: background var(--xc-transition), color var(--xc-transition), border-color var(--xc-transition);
}

.xc-vote-btn:hover, .xc-vote-btn--voted {
    background: var(--xc-primary-light);
    color: var(--xc-primary);
    border-color: var(--xc-primary);
}

/* ── Load more ─────────────────────────────────────────────────────────────── */
.xc-load-more-wrap { text-align: center; padding: 16px 0 24px; }

/* ── Review form ───────────────────────────────────────────────────────────── */
.xc-review-form-wrap {
    background: var(--xc-bg);
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius);
    padding: 24px 28px;
    margin-top: 24px;
}

.xc-review-form-wrap h3 { margin-top: 0; font-size: 18px; }

/* ── Media upload ──────────────────────────────────────────────────────────── */
.xc-media-upload {
    margin-top: 16px;
    padding: 16px;
    border: 2px dashed var(--xc-border);
    border-radius: var(--xc-radius);
    background: var(--xc-white);
    transition: border-color var(--xc-transition);
}

.xc-media-upload.xc-drag-over { border-color: var(--xc-primary); background: var(--xc-primary-light); }

.xc-media-upload__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--xc-text);
    margin: 0 0 10px;
}

.xc-media-upload__hint { font-weight: 400; color: var(--xc-text-muted); margin-left: 8px; font-size: 12px; }

.xc-media-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.xc-preview-item {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: var(--xc-radius-sm);
    overflow: hidden;
    border: 2px solid var(--xc-border);
}

.xc-preview-item img, .xc-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.xc-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,.65);
    color: var(--xc-white);
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.xc-media-upload__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--xc-white);
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--xc-text);
    cursor: pointer;
    transition: background var(--xc-transition), border-color var(--xc-transition);
}

.xc-media-upload__btn:hover { background: var(--xc-bg); border-color: var(--xc-primary); color: var(--xc-primary); }

.xc-media-upload__status { font-size: 12px; color: var(--xc-text-muted); margin-top: 8px; }

/* ── Q&A section ───────────────────────────────────────────────────────────── */
.xc-qa-section {
    margin-top: 40px;
    padding-top: 28px;
    border-top: 2px solid var(--xc-border);
}

.xc-qa-section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.xc-qa-section__title { font-size: 18px; font-weight: 700; margin: 0; }

.xc-no-qa { text-align: center; color: var(--xc-text-muted); padding: 24px; }

/* ── Ask-question form ─────────────────────────────────────────────────────── */
.xc-ask-form-wrap {
    background: var(--xc-bg);
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}

.xc-ask-form-wrap h4 { margin-top: 0; font-size: 15px; }

.xc-form-row { margin-bottom: 14px; }

.xc-form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }

.xc-input, .xc-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius-sm);
    font-size: 14px;
    color: var(--xc-text);
    background: var(--xc-white);
    box-sizing: border-box;
    transition: border-color var(--xc-transition);
    font-family: inherit;
    resize: vertical;
}

.xc-input:focus, .xc-textarea:focus {
    outline: none;
    border-color: var(--xc-primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

.xc-char-count { font-size: 11px; color: var(--xc-text-muted); display: block; text-align: right; margin-top: 3px; }

.xc-form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.xc-qa-message {
    padding: 10px 14px;
    border-radius: var(--xc-radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
}

.xc-qa-message--success { background: #dcfce7; color: var(--xc-green); border: 1px solid #bbf7d0; }
.xc-qa-message--error   { background: #fee2e2; color: var(--xc-red);   border: 1px solid #fecaca; }

/* ── Q&A list ──────────────────────────────────────────────────────────────── */
.xc-qa-item {
    padding: 18px 0;
    border-bottom: 1px solid var(--xc-border);
}

.xc-qa-item:first-child { border-top: 1px solid var(--xc-border); }

.xc-qa-item__question, .xc-qa-answer {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.xc-qa-item__q-label, .xc-qa-item__a-label {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.xc-qa-item__q-label { background: var(--xc-primary-light); color: var(--xc-primary); }
.xc-qa-item__a-label { background: #f0fdf4; color: var(--xc-green); }

.xc-qa-item__q-body, .xc-qa-answer__body { flex: 1; }

.xc-qa-item__text, .xc-qa-answer__text { font-size: 14px; line-height: 1.6; margin: 0 0 6px; }

.xc-qa-item__q-meta, .xc-qa-answer__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
    color: var(--xc-text-muted);
}

.xc-qa-item__author { font-weight: 600; }

.xc-qa-helpful-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--xc-border);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    cursor: pointer;
    color: var(--xc-text-muted);
    transition: color var(--xc-transition), border-color var(--xc-transition);
}

.xc-qa-helpful-btn:hover { color: var(--xc-primary); border-color: var(--xc-primary); }

.xc-qa-item__answers {
    margin: 12px 0 0 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.xc-qa-answer--seller .xc-qa-answer__body {
    background: var(--xc-seller-bg);
    padding: 10px 14px;
    border-radius: var(--xc-radius-sm);
}

.xc-seller-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fef9c3;
    color: var(--xc-seller-text);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 6px;
}

.xc-reply-btn {
    background: none;
    border: none;
    color: var(--xc-primary);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 0;
    text-decoration: underline;
    margin-left: 40px;
}

.xc-answer-form {
    margin: 10px 0 0 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Lightbox ──────────────────────────────────────────────────────────────── */
.xc-lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.82);
    z-index: 99998;
}

.xc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xc-lightbox__content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xc-lightbox__content img {
    max-width: 88vw;
    max-height: 88vh;
    border-radius: var(--xc-radius);
    box-shadow: var(--xc-shadow-md);
    display: block;
}

.xc-lightbox__content video {
    max-width: 88vw;
    max-height: 80vh;
    border-radius: var(--xc-radius);
}

.xc-lightbox__close,
.xc-lightbox__prev,
.xc-lightbox__next {
    position: fixed;
    background: rgba(255,255,255,.15);
    color: var(--xc-white);
    border: none;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background var(--xc-transition);
    backdrop-filter: blur(4px);
}

.xc-lightbox__close { top: 16px; right: 16px; }
.xc-lightbox__prev  { left: 16px; top: 50%; transform: translateY(-50%); }
.xc-lightbox__next  { right: 16px; top: 50%; transform: translateY(-50%); }

.xc-lightbox__close:hover, .xc-lightbox__prev:hover, .xc-lightbox__next:hover {
    background: rgba(255,255,255,.3);
}

/* ── Loading spinner ───────────────────────────────────────────────────────── */
.xc-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--xc-border);
    border-top-color: var(--xc-primary);
    border-radius: 50%;
    animation: xc-spin .7s linear infinite;
    vertical-align: middle;
}

@keyframes xc-spin { to { transform: rotate(360deg); } }

.xc-loading-overlay {
    text-align: center;
    padding: 24px;
    color: var(--xc-text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .xc-rating-summary { flex-direction: column; gap: 20px; }
    .xc-rating-summary__avg { flex-direction: row; gap: 12px; align-items: center; }
    .xc-rating-summary__score { font-size: 40px; }
    .xc-reviews-controls { flex-direction: column; align-items: stretch; }
    .xc-write-review-btn { width: 100%; justify-content: center; }
    .xc-review-form-wrap, .xc-ask-form-wrap { padding: 16px; }
    .xc-lightbox__prev { left: 8px; }
    .xc-lightbox__next { right: 8px; }
}

/* ── Widget: XC Top Reviews ────────────────────────────────────────────────── */
.xc-widget-reviews { display: flex; flex-direction: column; gap: 16px; }

.xc-widget-review {
    padding: 14px;
    background: var(--xc-bg);
    border: 1px solid var(--xc-border);
    border-radius: var(--xc-radius);
}

.xc-widget-review .xc-stars { margin-bottom: 8px; }
.xc-widget-review .xc-star  { font-size: 13px; }

.xc-widget-review__author {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--xc-text);
}

.xc-widget-avatar { border-radius: 50%; flex-shrink: 0; }

.xc-widget-review__excerpt {
    font-size: 13px;
    color: var(--xc-text-muted);
    line-height: 1.5;
    margin: 0 0 8px;
    font-style: italic;
}

.xc-widget-review__product {
    display: inline-block;
    font-size: 11px;
    color: var(--xc-primary);
    text-decoration: none;
    font-weight: 600;
}

.xc-widget-review__product:hover { text-decoration: underline; }
