/**
 * My Reviews - Styles
 *
 * @package TUH_Account
 * @since 4.0.0
 */

/* Container */
.tuh-my-reviews {
    max-width: 900px;
    margin: 0 auto;
    --reviews-bg: var(--tuh-bg-primary, var(--tuh-account-bg));
    --reviews-card: var(--tuh-card-bg, var(--tuh-account-card-bg));
    --reviews-border: var(--tuh-card-border, var(--tuh-account-border));
    --reviews-text: var(--tuh-text-primary, var(--tuh-account-text));
    --reviews-text-secondary: var(--tuh-text-secondary, var(--tuh-text-muted, var(--tuh-account-text-muted)));
    --reviews-muted: var(--tuh-text-muted, var(--tuh-account-text-muted));
    --reviews-accent: var(--tuh-primary, var(--tuh-account-primary));
    --reviews-accent-hover: var(--tuh-primary-hover, var(--tuh-account-primary-hover));
    --reviews-warning: var(--tuh-warning, var(--tuh-account-warning));
    --reviews-success: var(--tuh-success, var(--tuh-account-success));
    --reviews-danger: var(--tuh-danger, var(--tuh-account-danger));
    --reviews-shadow-sm: var(--tuh-shadow, var(--tuh-account-shadow));
    --reviews-shadow-lg: var(--tuh-shadow-lg, var(--tuh-account-shadow-lg));
    --reviews-bg-soft: var(--reviews-card);
    --reviews-bg-soft: color-mix(in srgb, var(--reviews-card) 88%, var(--reviews-bg) 12%);
    /* Note: first declaration above serves as fallback for browsers without color-mix() */
    color: var(--reviews-text);
}

/* Integration guard: keep reviews anchored at the top of its SPA section.
   Prevents inherited flex/min-height rules from pushing the tab content down. */
#section-reviews,
.tuh-section[data-section="reviews"] {
    min-height: 0 !important;
    height: auto !important;
}

#section-reviews > .tuh-section-inner,
.tuh-section[data-section="reviews"] > .tuh-section-inner {
    display: block !important;
    min-height: 0 !important;
    height: auto !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    padding-top: 16px !important;
}

/* Header */
.tuh-reviews-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.tuh-reviews-title h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--reviews-text);
}

.tuh-reviews-title h2 svg {
    color: var(--reviews-warning);
}

.tuh-reviews-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--reviews-muted);
}

/* Stats */
.tuh-reviews-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.tuh-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    background: var(--reviews-card);
    border: 1px solid var(--reviews-border);
    border-radius: 10px;
    box-shadow: var(--reviews-shadow-sm);
    min-width: 80px;
}

.tuh-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--reviews-text);
}

.tuh-stat-label {
    font-size: 0.75rem;
    color: var(--reviews-muted);
    text-transform: uppercase;
}

.tuh-stat-stars {
    display: flex;
    gap: 2px;
    margin-top: 4px;
}

.tuh-stat-stars svg {
    width: 14px;
    height: 14px;
    color: var(--reviews-warning);
}

.tuh-stat-pending .tuh-stat-value {
    color: var(--reviews-warning);
}

/* Sections */
.tuh-reviews-section {
    margin-bottom: 32px;
}

.tuh-reviews-section:last-child {
    margin-bottom: 0;
}

.tuh-reviews-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--reviews-text);
}

.tuh-reviews-section-title svg {
    color: var(--reviews-accent);
}

.tuh-section-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    background: var(--reviews-accent);
    border-radius: 11px;
}

.tuh-section-description {
    margin: 0 0 16px 0;
    font-size: 0.875rem;
    color: var(--reviews-muted);
}

/* Pending Grid */
.tuh-pending-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

/* Pending Card */
.tuh-pending-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--reviews-card);
    border: 1px solid var(--reviews-border);
    border-radius: 12px;
    box-shadow: var(--reviews-shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tuh-pending-card:hover {
    border-color: var(--reviews-accent);
    box-shadow: var(--reviews-shadow-lg);
}

.tuh-pending-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--reviews-bg-soft);
}

.tuh-pending-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tuh-pending-info {
    flex: 1;
    min-width: 0;
}

.tuh-pending-name {
    margin: 0 0 4px 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.tuh-pending-name a {
    color: var(--reviews-text);
    text-decoration: none;
}

.tuh-pending-name a:hover {
    color: var(--reviews-accent);
}

.tuh-pending-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    font-size: 0.8rem;
    color: var(--reviews-muted);
}

.tuh-review-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* Reviews List */
.tuh-reviews-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Review Card */
.tuh-review-card {
    padding: 16px;
    background: var(--reviews-card);
    border: 1px solid var(--reviews-border);
    border-radius: 12px;
    box-shadow: var(--reviews-shadow-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.tuh-review-card.pending {
    border-color: rgba(245, 158, 11, 0.6);
    border-color: color-mix(in srgb, var(--reviews-warning) 60%, var(--reviews-border));
    background: rgba(245, 158, 11, 0.08);
    background: color-mix(in srgb, var(--reviews-card) 88%, var(--reviews-warning) 12%);
}

.tuh-review-product {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.tuh-review-product-info {
    min-width: 0;
}

.tuh-review-product img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--reviews-bg-soft);
}

.tuh-review-product-info h4 {
    margin: 0 0 4px 0;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.tuh-review-product-info h4 a {
    color: var(--reviews-text);
    text-decoration: none;
}

.tuh-review-product-info h4 a:hover {
    color: var(--reviews-accent);
}

.tuh-review-rating {
    display: flex;
    gap: 2px;
}

.tuh-review-rating svg {
    color: #d1d5db;
}

.tuh-review-rating svg.filled {
    color: var(--tuh-warning, #f59e0b);
}

.tuh-review-content {
    padding: 12px 0;
    border-top: 1px solid var(--reviews-border);
    border-bottom: 1px solid var(--reviews-border);
}

.tuh-review-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--reviews-text-secondary);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.tuh-review-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
}

.tuh-review-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tuh-review-date,
.tuh-review-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--reviews-muted);
}

.tuh-review-status.status-approved {
    color: var(--reviews-success);
}

.tuh-review-status.status-pending {
    color: var(--reviews-warning);
}

.tuh-review-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--reviews-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tuh-review-delete:hover {
    background: rgba(239, 68, 68, 0.12);
    background: color-mix(in srgb, var(--reviews-danger) 12%, transparent);
    border-color: rgba(239, 68, 68, 0.35);
    border-color: color-mix(in srgb, var(--reviews-danger) 35%, var(--reviews-border));
    color: var(--reviews-danger);
}

/* Empty State */
.tuh-reviews-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    background: var(--reviews-card);
    border: 2px dashed var(--reviews-border);
    border-radius: 12px;
}

.tuh-reviews-empty svg {
    color: var(--reviews-muted);
    opacity: 0.5;
    margin-bottom: 16px;
}

.tuh-reviews-empty p {
    margin: 0;
    font-size: 1rem;
    color: var(--reviews-text-secondary);
}

.tuh-reviews-empty-hint {
    margin-top: 8px !important;
    font-size: 0.875rem !important;
    color: var(--reviews-muted) !important;
}

/* Modal */
.tuh-review-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--tuh-account-z-modal, 1050);
    align-items: center;
    justify-content: center;
}

.tuh-review-modal[aria-hidden="false"] {
    display: flex;
}

.tuh-my-reviews .tuh-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.tuh-my-reviews .tuh-modal-container {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 20px;
    background: var(--reviews-card);
    border: 1px solid var(--reviews-border);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: tuh-modal-in 0.3s ease;
}

@keyframes tuh-modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.tuh-my-reviews .tuh-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--reviews-border);
}

.tuh-my-reviews .tuh-modal-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.tuh-my-reviews .tuh-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--reviews-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tuh-my-reviews .tuh-modal-close:hover {
    background: var(--reviews-bg-soft);
    color: var(--reviews-text);
}

.tuh-my-reviews .tuh-modal-body {
    padding: 20px;
}

.tuh-my-reviews .tuh-modal-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 20px;
    background: var(--reviews-bg-soft);
    border-radius: 8px;
}

.tuh-my-reviews .tuh-modal-product img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
}

.tuh-my-reviews .tuh-modal-product span {
    font-weight: 500;
    color: var(--reviews-text);
    min-width: 0;
    overflow-wrap: anywhere;
}

.tuh-my-reviews .tuh-form-group {
    margin-bottom: 16px;
}

.tuh-my-reviews .tuh-form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--reviews-text);
}

.tuh-my-reviews .tuh-form-group textarea {
    width: 100%;
    padding: 12px;
    font-size: 0.9rem;
    border: 1px solid var(--reviews-border);
    border-radius: 8px;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.tuh-my-reviews .tuh-form-group textarea:focus {
    outline: none;
    border-color: var(--reviews-accent);
}

/* Rating Input */
.tuh-my-reviews .tuh-rating-input {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tuh-my-reviews .tuh-rating-input .tuh-star {
    padding: 4px;
    background: transparent;
    border: none;
    color: var(--reviews-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tuh-my-reviews .tuh-rating-input .tuh-star:hover,
.tuh-my-reviews .tuh-rating-input .tuh-star.active {
    color: var(--reviews-warning);
    transform: scale(1.1);
}

.tuh-my-reviews .tuh-rating-input .tuh-star.active svg {
    fill: currentColor;
}

/* Modal Footer */
.tuh-my-reviews .tuh-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--tuh-border, #e5e7eb);
}

/* Buttons — SPA selector (.tuh-section prefix) beats spa-classic reset:
   html body .tuh-spa-wrapper .tuh-async-dashboard button (0,2,3)
   .tuh-section .tuh-my-reviews .tuh-btn → 0,3,0
   Classic selector (.tuh-my-reviews only) works because SPA reset doesn't apply */
.tuh-my-reviews .tuh-btn,
.tuh-section .tuh-my-reviews .tuh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tuh-my-reviews .tuh-btn-primary,
.tuh-section .tuh-my-reviews .tuh-btn-primary {
    color: #fff;
    background: var(--reviews-accent);
    background-color: var(--reviews-accent);
}

.tuh-my-reviews .tuh-btn-primary:hover,
.tuh-section .tuh-my-reviews .tuh-btn-primary:hover {
    background: var(--reviews-accent-hover);
    background-color: var(--reviews-accent-hover);
}

.tuh-my-reviews .tuh-btn-secondary,
.tuh-section .tuh-my-reviews .tuh-btn-secondary {
    color: var(--reviews-text-secondary);
    background: var(--reviews-bg-soft);
    background-color: var(--reviews-bg-soft);
}

.tuh-my-reviews .tuh-btn-secondary:hover,
.tuh-section .tuh-my-reviews .tuh-btn-secondary:hover {
    background: var(--reviews-border);
    background-color: var(--reviews-border);
}

.tuh-my-reviews .tuh-btn:disabled,
.tuh-section .tuh-my-reviews .tuh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Toast */
.tuh-reviews-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 1100;
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    background: #1f2937;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tuh-reviews-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    visibility: visible;
}

.tuh-reviews-toast.success {
    background: var(--tuh-success, #10b981);
}

.tuh-reviews-toast.error {
    background: var(--tuh-error, #ef4444);
}

/* Responsive */
@media (max-width: 768px) {
    .tuh-my-reviews {
        max-width: 100%;
    }

    .tuh-reviews-header {
        gap: 14px;
    }

    .tuh-pending-grid {
        grid-template-columns: 1fr;
    }

    .tuh-review-footer {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

    .tuh-review-delete {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 640px) {
    .tuh-reviews-header {
        flex-direction: column;
    }

    .tuh-reviews-stats {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 10px;
    }

    .tuh-stat {
        min-width: 0;
        width: 100%;
        padding: 12px;
    }

    .tuh-reviews-title h2 {
        font-size: 1.25rem;
    }

    .tuh-pending-card {
        flex-wrap: wrap;
    }

    .tuh-pending-info {
        flex: 1 1 calc(100% - 72px);
    }

    .tuh-review-btn {
        width: 100%;
        justify-content: center;
        margin-top: 12px;
    }

    .tuh-my-reviews .tuh-modal-container {
        margin: 10px;
    }

    .tuh-review-meta {
        width: 100%;
        gap: 8px;
    }

    .tuh-review-delete {
        width: 40px;
        height: 40px;
        margin-left: auto;
    }

    .tuh-my-reviews .tuh-modal-footer {
        flex-direction: column;
    }

    .tuh-my-reviews .tuh-modal-footer .tuh-btn,
    .tuh-section .tuh-my-reviews .tuh-modal-footer .tuh-btn {
        width: 100%;
    }

    .tuh-my-reviews .tuh-rating-input .tuh-star {
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
}

@media (max-width: 420px) {
    .tuh-reviews-stats {
        grid-template-columns: 1fr;
    }

    .tuh-review-product {
        align-items: flex-start;
    }
}
