/* ─── Overlay ─── */
#usr-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    transition: opacity 0.3s, visibility 0.3s;
}

#usr-overlay.usr-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ─── Popup Card ─── */
#usr-popup {
    width: 420px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    animation: usrSlideUp 0.3s ease;
    overflow: hidden;
}

@keyframes usrSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Header ─── */
.usr-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.usr-popup-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
}

.usr-close-btn {
    background: rgba(255,255,255,0.2) !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    color: #fff !important;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0.9;
    transition: opacity 0.2s, background 0.2s;
    flex-shrink: 0;
}

.usr-close-btn:hover {
    opacity: 1;
    background: rgba(255,255,255,0.35) !important;
}

/* ─── Body ─── */
.usr-popup-body {
    padding: 20px 22px;
    overflow-y: auto;
    flex: 1;
}

/* ─── Empty State ─── */
.usr-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 0;
    gap: 14px;
}

.usr-empty-state p {
    margin: 0;
    font-size: 15px;
    color: #6b5c52;
    line-height: 1.5;
}

/* ─── Buttons ─── */
.usr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
}

.usr-btn-primary {
    color: #fff;
    width: 100%;
}

.usr-btn-primary:hover {
    filter: brightness(0.9);
    transform: translateY(-1px);
}

.usr-btn-outline {
    background: transparent;
    color: #C96D3C;
    border: 2px solid #C96D3C;
}

.usr-btn-outline:hover {
    background: rgba(201, 109, 60, 0.08);
}

/* ─── Section Subtitle ─── */
.usr-section-subtitle {
    font-size: 14px;
    color: #8a7a70;
    margin: 0 0 14px 0;
}

/* ─── Product Grid ─── */
#usr-products-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 2px;           /* prevent box-shadow clipping */
}

.usr-product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 10px;
    border: 2px solid #ede7e2;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: #faf8f6;
    box-sizing: border-box;
}

.usr-product-card:hover {
    border-color: #C96D3C;
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(201, 109, 60, 0.12);
}

.usr-product-card img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 8px;
    flex-shrink: 0;
}

.usr-product-card span {
    font-size: 12px;
    font-weight: 500;
    color: #3d3228;
    text-align: center;
    line-height: 1.4;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ─── Review Form ─── */
.usr-selected-product {
    margin-bottom: 18px;
}

.usr-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: #8a7a70;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    margin-bottom: 12px;
    font-family: inherit;
    transition: color 0.2s;
}

.usr-back-btn:hover {
    color: #C96D3C;
}

.usr-product-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #faf8f6;
    border-radius: 10px;
    border: 1px solid #ede7e2;
}

.usr-product-info img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.usr-product-info span {
    font-size: 14px;
    font-weight: 500;
    color: #3d3228;
    line-height: 1.3;
}

/* ─── Form Groups ─── */
.usr-form-group {
    margin-bottom: 16px;
}

.usr-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #6b5c52;
    margin-bottom: 6px;
}

.usr-hint {
    font-size: 12px;
    color: #b0a099;
    margin-top: 4px;
}

.usr-hint.usr-error {
    color: #e53935;
}

/* ─── Star Rating ─── */
.usr-star-rating {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.usr-star {
    font-size: 24px;
    color: #e0d5cf;
    cursor: pointer;
    transition: color 0.15s, transform 0.15s;
    line-height: 1;
    user-select: none;
}

.usr-star:hover,
.usr-star.usr-hover {
    color: #f5a623;
    transform: scale(1.1);
}

.usr-star.usr-active {
    color: #f5a623;
}

.usr-rating-value {
    font-size: 13px;
    color: #b0a099;
    margin-left: 6px;
    min-width: 28px;
}

#usr-criteria-ratings .usr-form-group {
    margin-bottom: 12px;
}

#usr-criteria-ratings label {
    font-size: 12px;
    font-weight: 500;
    color: #8a7a70;
}

.usr-required {
    color: #e53935;
    margin-left: 2px;
}

/* ─── Textarea ─── */
#usr-comment {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e0d5cf;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    box-sizing: border-box;
}

#usr-comment:focus {
    outline: none;
    border-color: #C96D3C;
    box-shadow: 0 0 0 3px rgba(201, 109, 60, 0.15);
}

/* ─── Photo Upload ─── */
.usr-upload-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    border: 2px dashed #e0d5cf;
    border-radius: 8px;
    background: #faf8f6;
    cursor: pointer;
    transition: all 0.2s;
    color: #8a7a70;
    font-size: 13px;
    font-family: inherit;
}

.usr-upload-trigger:hover {
    border-color: #C96D3C;
    color: #C96D3C;
    background: #fff;
}

.usr-upload-trigger.usr-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#usr-photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.usr-photo-preview {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #ede7e2;
}

.usr-photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.usr-photo-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.usr-photo-remove:hover {
    background: rgba(229, 57, 53, 0.9);
}

/* ─── Success State ─── */
.usr-success-state svg {
    animation: usrBounceIn 0.5s ease;
}

@keyframes usrBounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.usr-success-state p {
    font-size: 16px;
    font-weight: 500;
    color: #3d3228;
}

/* ─── Loading Spinner ─── */
#usr-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.usr-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #ede7e2;
    border-top-color: #C96D3C;
    border-radius: 50%;
    animation: usrSpin 0.7s linear infinite;
}

@keyframes usrSpin {
    to { transform: rotate(360deg); }
}

/* ─── Uploading indicator ─── */
.usr-photo-preview.usr-uploading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Mobile ─── */
@media (max-width: 480px) {
    #usr-popup {
        width: auto;
        margin: 12px;
        max-height: calc(100vh - 24px);
    }

    #usr-products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .usr-product-card img {
        width: 60px;
        height: 60px;
    }
}
