/**
 * Drip Product Reviews — Frontend Styles
 *
 * Minimal, performant CSS using CSS custom properties for theming.
 * Mobile-first responsive design.
 *
 * @package CheckoutLocalReviews
 * @since   2.0.0
 */

/* ── Section ─────────────────────────────────────────── */

.dpr-section {
    --dpr-card-bg: #ffffff;
    --dpr-card-text: #374151;
    --dpr-card-border: #e5e7eb;
    --dpr-card-radius: 12px;
    --dpr-stars: #f59e0b;
    --dpr-author: #111827;
    --dpr-meta: #9ca3af;

    width: 100%;
    max-width: 100%;
    margin: 32px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────── */

.dpr-header {
    margin-bottom: 24px;
    text-align: center;
}

.dpr-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--dpr-author);
    margin: 0 0 4px;
    line-height: 1.2;
}

.dpr-subtitle {
    font-size: 14px;
    color: var(--dpr-meta, #6b7280);
    margin: 0 0 16px;
    line-height: 1.4;
    font-weight: 400;
}

/* ── Rating Summary ──────────────────────────────────── */

.dpr-summary {
    display: flex;
    align-items: flex-start;
    gap: 32px;
    padding: 20px 24px;
    background: #f9fafb;
    border: 1px solid var(--dpr-card-border);
    border-radius: var(--dpr-card-radius);
}

.dpr-summary-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    flex-shrink: 0;
}

.dpr-avg-number {
    font-size: 48px;
    font-weight: 800;
    color: var(--dpr-author);
    line-height: 1;
}

.dpr-avg-stars {
    display: flex;
    gap: 2px;
    margin: 8px 0;
}

.dpr-total-text {
    font-size: 13px;
    color: var(--dpr-meta);
    text-align: center;
}

.dpr-total-text strong {
    color: var(--dpr-author);
}

/* Rating Bars */
.dpr-summary-bars {
    min-width: 120px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dpr-bar-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dpr-bar-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dpr-meta);
    width: 12px;
    text-align: right;
}

.dpr-bar-star {
    flex-shrink: 0;
}

.dpr-bar-track {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.dpr-bar-fill {
    height: 100%;
    background: var(--dpr-stars);
    border-radius: 4px;
    transition: width 0.6s ease;
}

.dpr-bar-count {
    font-size: 12px;
    color: var(--dpr-meta);
    width: 32px;
    text-align: right;
}

/* ── Reviews Grid ────────────────────────────────────── */

.dpr-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 640px) {
    .dpr-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Anti-FOUC: limit visible cards before JS takes over */
.dpr-grid:not(.dpr-grid--managed) .dpr-card:nth-child(n+5) {
    display: none;
}

@media (max-width: 639px) {
    .dpr-grid:not(.dpr-grid--managed) .dpr-card:nth-child(n+3) {
        display: none;
    }
}

/* ── Review Card ─────────────────────────────────────── */

.dpr-card {
    background: var(--dpr-card-bg);
    border: 1px solid var(--dpr-card-border);
    border-radius: var(--dpr-card-radius);
    padding: 20px;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.dpr-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transform: translateY(-1px);
}

/* Card Header */
.dpr-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.dpr-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.dpr-card-meta {
    flex: 1;
    min-width: 0;
}

.dpr-author {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--dpr-author);
    line-height: 1.3;
}

.dpr-card-submeta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.dpr-verified {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #10b981;
    font-weight: 500;
}

.dpr-date {
    font-size: 12px;
    color: var(--dpr-meta);
}

.dpr-card-stars {
    display: flex;
    gap: 1px;
    flex-shrink: 0;
}

/* Card Content */
.dpr-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--dpr-author);
    margin: 0 0 6px;
    line-height: 1.3;
}

.dpr-card-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--dpr-card-text);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.dpr-card-text.dpr-expanded {
    -webkit-line-clamp: unset;
    overflow: visible;
}

/* Card Footer */
.dpr-card-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--dpr-card-border);
}

.dpr-location {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--dpr-meta);
}

.dpr-recommended {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #10b981;
    margin-top: 10px;
}

/* ── Loading / View More ─────────────────────────────── */

.dpr-view-more-wrap {
    padding: 24px 0;
    text-align: center;
}

.dpr-view-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 32px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dpr-author, #111827);
    background: transparent;
    border: 2px solid var(--dpr-card-border, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
}

.dpr-view-more:hover {
    border-color: var(--dpr-author, #111827);
    background: #f9fafb;
}

.dpr-view-more:active {
    transform: scale(0.98);
}

.dpr-view-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dpr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 14px;
    color: var(--dpr-meta);
}

.dpr-loading.dpr-hidden {
    display: none;
}

.dpr-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: var(--dpr-stars);
    border-radius: 50%;
    animation: dpr-spin 0.6s linear infinite;
}

/* ── Flag Image ──────────────────────────────────────── */

.dpr-flag {
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
    border-radius: 2px;
    width: 16px;
    height: 12px;
}

@keyframes dpr-spin {
    to { transform: rotate(360deg); }
}

/* ── Card Enter Animation ────────────────────────────── */

.dpr-card--entering {
    opacity: 0;
    transform: translateY(12px);
    animation: dpr-card-enter 0.3s ease forwards;
}

@keyframes dpr-card-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Responsive ──────────────────────────────────────── */

@media (min-width: 640px) {
    .dpr-summary-left {
        width: 15%;
    }

    .dpr-summary-bars {
        width: 20%;
    }

    .dpr-cta-heading {
        font-size: 20px;
    }
}

@media (max-width: 639px) {
    .dpr-summary {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }

    .dpr-summary-left {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        min-width: 0;
    }

    .dpr-avg-number {
        font-size: 36px;
    }

    .dpr-card {
        padding: 16px;
    }

    .dpr-section {
        margin: 20px 0;
    }
}

/* ── Summary CTA ─────────────────────────────────────── */

.dpr-summary-cta {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-width: 0;
    padding-left: 24px;
    border-left: 1px solid var(--dpr-card-border);
}

.dpr-cta-heading {
    font-size: 14px;
    font-weight: 600;
    color: var(--dpr-author);
    text-align: center;
    line-height: 1.3;
}

.dpr-write-review-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dpr-author, #111827);
    background: transparent;
    border: 2px solid var(--dpr-card-border, #e5e7eb);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    white-space: nowrap;
}

.dpr-write-review-btn:hover {
    border-color: var(--dpr-author, #111827);
    background-color: var(--btn-bgcolor, #F9FAFB);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.dpr-write-review-btn:active {
    transform: scale(0.98);
}

@media (max-width: 639px) {
    .dpr-summary-cta {
        flex-direction: row;
        padding-left: 0;
        border-left: none;
        padding-top: 12px;
        border-top: 1px solid var(--dpr-card-border);
        min-width: 0;
    }
}

/* ── Card Images ─────────────────────────────────────── */

.dpr-card-images {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.dpr-card-image-link {
    display: block;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--dpr-card-border);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: zoom-in;
}

.dpr-card-image-link:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.dpr-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Modal Overlay ───────────────────────────────────── */

.dpr-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: dpr-fade-in 0.2s ease;
}

.dpr-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: dpr-slide-up 0.3s ease;
}

.dpr-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.dpr-modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--dpr-author, #111827);
    margin: 0;
}

.dpr-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--dpr-meta, #9ca3af);
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.15s;
}

.dpr-modal-close:hover {
    color: var(--dpr-author, #111827);
}

.dpr-modal-body {
    padding: 20px 24px;
}

.dpr-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 0 24px 20px;
}

/* ── Form Elements ───────────────────────────────────── */

.dpr-form-group {
    margin-bottom: 16px;
}

.dpr-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dpr-author, #111827);
    margin-bottom: 6px;
}

.dpr-required {
    color: #ef4444;
}

.dpr-optional {
    font-weight: 400;
    color: var(--dpr-meta, #9ca3af);
    font-size: 12px;
}

.dpr-form-input,
.dpr-form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: var(--dpr-author, #111827);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.dpr-form-input:focus,
.dpr-form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dpr-form-textarea {
    resize: vertical;
    min-height: 80px;
}

/* Star Selector */
.dpr-star-selector {
    display: flex;
    gap: 4px;
}

.dpr-star-select {
    cursor: pointer;
    transition: transform 0.1s ease;
}

.dpr-star-select:hover {
    transform: scale(1.15);
}

.dpr-star-select.dpr-star-active path {
    fill: var(--dpr-stars, #f59e0b);
}

.dpr-star-select.dpr-star-hover path {
    fill: var(--dpr-stars, #f59e0b);
    opacity: 0.7;
}

/* Upload Area */
.dpr-upload-area {
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    transition: border-color 0.15s, background 0.15s;
    min-height: 80px;
}

.dpr-upload-area:hover,
.dpr-upload-area.dpr-drag-over {
    border-color: #3b82f6;
    background: #eff6ff;
}

.dpr-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.dpr-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--dpr-meta, #9ca3af);
    font-size: 13px;
    pointer-events: none;
}

.dpr-upload-previews {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    z-index: 3;
}

.dpr-upload-previews:empty {
    display: none;
}

.dpr-preview-item {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #d1d5db;
}

.dpr-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dpr-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.dpr-preview-remove:hover {
    background: #ef4444;
}

/* Submit Message */
.dpr-submit-message {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-top: 4px;
}

.dpr-submit-message.dpr-msg-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.dpr-submit-message.dpr-msg-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Buttons */
.dpr-btn-cancel {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--dpr-author, #111827);
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.dpr-btn-cancel:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.dpr-btn-submit {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: #111827;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.dpr-btn-submit:hover {
    background: #374151;
}

.dpr-btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Lightbox ────────────────────────────────────────── */

.dpr-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: dpr-fade-in 0.2s ease;
    cursor: zoom-out;
}

.dpr-lightbox-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    z-index: 1;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.dpr-lightbox-close:hover {
    opacity: 1;
}

.dpr-lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
    object-fit: contain;
    cursor: default;
}

/* ── Modal Animations ────────────────────────────────── */

@keyframes dpr-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dpr-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
