/* --------------------------------------------------------------------------
 * HTN Reviews & Ratings Stylesheet (TGDD Design-inspired)
 * -------------------------------------------------------------------------- */

:root {
    --review-gold: #ffb800;
    --review-blue: #2f80ed;
    --review-blue-hover: #1565c0;
    --review-blue-bg: #f3f8fe;
    --review-green: #2ba832;
    --review-green-bg: #e8f7ec;
    --review-text-dark: #2d3748;
    --review-text-gray: #718096;
    --review-text-muted: #a0aec0;
    --review-border: #edf2f7;
    --review-bg-card: #ffffff;
    --review-font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --review-font-title: 'Plus Jakarta Sans', sans-serif;
}

.htn-reviews-section {
    font-family: var(--review-font-sans);
    margin-top: 30px;
    padding: 24px;
    background: var(--review-bg-card);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--review-border);
}

.htn-reviews-title {
    font-family: var(--review-font-title);
    font-size: 20px;
    font-weight: 800;
    color: var(--review-text-dark);
    margin-bottom: 20px;
    text-transform: none;
    border-left: 4px solid var(--review-blue);
    padding-left: 12px;
    line-height: 1.2;
}

/* KHUNG TỔNG QUAN ĐÁNH GIÁ */
.htn-reviews-summary-card {
    display: grid;
    grid-template-columns: 1fr 1.5fr 1fr;
    gap: 24px;
    border: 1px solid var(--review-border);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    background: #fafafa;
    align-items: center;
}

@media (max-width: 768px) {
    .htn-reviews-summary-card {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 16px;
    }
}

/* Cột trái: Điểm trung bình */
.summary-score-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-right: 1px solid var(--review-border);
    padding-right: 16px;
}

@media (max-width: 768px) {
    .summary-score-column {
        border-right: none;
        border-bottom: 1px solid var(--review-border);
        padding-right: 0;
        padding-bottom: 16px;
    }
}

.score-number-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    margin-bottom: 4px;
}

.score-large {
    font-family: var(--review-font-title);
    font-size: 44px;
    font-weight: 800;
    color: var(--review-text-dark);
    line-height: 1;
}

.score-max {
    font-size: 18px;
    color: var(--review-text-gray);
    font-weight: 600;
    margin-left: 2px;
}

.score-stars {
    display: flex;
    gap: 2px;
    margin-bottom: 8px;
}

.star-item {
    font-size: 18px;
    line-height: 1;
}

.star-filled {
    color: var(--review-gold);
}

.star-half {
    position: relative;
    color: var(--review-border);
}

.star-half::before {
    content: "★";
    position: absolute;
    left: 0;
    top: 0;
    width: 50%;
    overflow: hidden;
    color: var(--review-gold);
}

.star-empty {
    color: #e2e8f0;
}

.satisfied-text {
    font-size: 13px;
    color: var(--review-text-dark);
}

.total-reviews-count {
    font-size: 12px;
    color: var(--review-text-gray);
    margin-top: 4px;
}

/* Cột giữa: Biểu đồ thanh ngang */
.summary-bars-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: 1px solid var(--review-border);
    padding-right: 16px;
}

@media (max-width: 768px) {
    .summary-bars-column {
        border-right: none;
        border-bottom: 1px solid var(--review-border);
        padding-right: 0;
        padding-bottom: 16px;
    }
}

.star-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.star-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--review-text-dark);
    min-width: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.star-char {
    color: var(--review-gold);
    font-size: 11px;
}

.bar-container {
    flex-grow: 1;
    height: 6px;
    background: #edf2f7;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.bar-fill {
    height: 100%;
    background: var(--review-blue);
    border-radius: 10px;
    transition: width 0.6s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.star-percent {
    font-size: 12px;
    font-weight: 600;
    color: var(--review-text-gray);
    min-width: 42px;
    text-align: right;
}

/* Cột phải: Gallery ảnh */
.summary-gallery-column {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 220px;
}

.gallery-thumb-wrapper {
    aspect-ratio: 1 / 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--review-border);
    background: #f7fafc;
}

.gallery-thumb-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-thumb-wrapper:hover img {
    transform: scale(1.08);
}

.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    padding: 4px;
    box-sizing: border-box;
    line-height: 1.3;
}

.gallery-empty-state {
    text-align: center;
    color: var(--review-text-gray);
    padding: 10px;
}

.empty-gallery-icon {
    font-size: 24px;
    margin-bottom: 6px;
}

.gallery-empty-state p {
    font-size: 12px;
    margin: 0;
    line-height: 1.4;
}

/* NÚT TƯƠNG TÁC */
.htn-reviews-actions-row {
    display: flex;
    justify-content: flex-end;
    margin: 20px 0;
}

@media (max-width: 768px) {
    .htn-reviews-actions-row {
        justify-content: center;
    }
}

.btn-write-review {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--review-blue);
    color: var(--review-blue);
    font-family: var(--review-font-sans);
    font-size: 14px;
    font-weight: 700;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-write-review:hover {
    background: var(--review-blue);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(47, 128, 237, 0.2);
}

/* DANH SÁCH BÌNH LUẬN */
.htn-reviews-list-container {
    display: flex;
    flex-direction: column;
    margin-top: 10px;
}

.review-item-card {
    border-bottom: 1px solid var(--review-border);
    padding: 20px 0;
}

.review-item-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.review-meta-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 6px;
}

.reviewer-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--review-text-dark);
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--review-green-bg);
    color: var(--review-green);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.verified-badge svg {
    flex-shrink: 0;
}

.review-rating-stars {
    display: flex;
    gap: 1px;
    margin-bottom: 10px;
}

.review-rating-stars .star-item {
    font-size: 14px;
}

.review-content-body {
    font-size: 14px;
    color: var(--review-text-dark);
    line-height: 1.6;
    margin-bottom: 12px;
}

.review-content-body p {
    margin: 0;
}

/* Ảnh đính kèm trong review */
.review-attached-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.review-attached-thumb {
    width: 68px;
    height: 68px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--review-border);
    background: #f7fafc;
}

.review-attached-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}

.review-attached-thumb:hover img {
    opacity: 0.85;
}

/* PHẢN HỒI CỦA BẢN QUẢN TRỊ (BQT) */
.admin-reply-box {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 14px 16px;
    margin: 12px 0 12px 12px;
    border-left: 3px solid var(--review-text-gray);
    position: relative;
}

.admin-reply-box.official-reply {
    background: var(--review-blue-bg);
    border-left: 3px solid var(--review-blue);
}

.reply-header {
    margin-bottom: 6px;
}

.reply-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: #1a4a8c;
}

.reply-icon {
    font-size: 14px;
}

.reply-user {
    font-size: 12px;
    font-weight: 700;
    color: var(--review-text-dark);
}

.reply-date {
    font-size: 12px;
    color: var(--review-text-gray);
    margin-left: 4px;
}

.reply-content {
    font-size: 13.5px;
    color: #333333;
    line-height: 1.5;
}

.reply-content p {
    margin: 0;
}

/* Footer của đánh giá */
.review-item-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--review-text-gray);
    margin-top: 12px;
}

.btn-helpful-vote {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--review-text-gray);
    cursor: pointer;
    font-family: var(--review-font-sans);
    font-size: 13px;
    padding: 4px 8px 4px 0;
    transition: color 0.2s;
}

.btn-helpful-vote:hover {
    color: var(--review-blue);
}

.btn-helpful-vote.voted {
    color: var(--review-blue);
    font-weight: 700;
}

.btn-helpful-vote svg {
    stroke-width: 2.2;
}

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

/* EMPTY STATE */
.reviews-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--review-text-gray);
}

.empty-reviews-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.reviews-empty-state p {
    font-size: 14px;
    margin: 0;
}

/* --------------------------------------------------------------------------
 * MODAL DRAWER FORM (Thiết kế hiện đại)
 * -------------------------------------------------------------------------- */
.htn-review-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.htn-review-modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.modal-wrapper {
    position: relative;
    width: 100%;
    max-width: 620px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 10001;
    overflow: hidden;
    animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

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

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

.modal-header h3 {
    margin: 0;
    font-family: var(--review-font-title);
    font-size: 18px;
    font-weight: 800;
    color: var(--review-text-dark);
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--review-text-gray);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.btn-close-modal:hover {
    color: var(--review-text-dark);
}

/* Body Form */
.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

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

.form-group label {
    display: block;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--review-text-dark);
    margin-bottom: 6px;
}

.form-group label .required {
    color: #ef4444;
}

.form-group textarea,
.form-group input[type="text"],
.form-group select {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--review-font-sans);
    font-size: 14px;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group textarea:focus,
.form-group input[type="text"]:focus,
.form-group select:focus {
    border-color: var(--review-blue);
    box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.15);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

@media (max-width: 580px) {
    .form-grid-2 {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Chọn Rating Sao */
.form-rating-selector {
    text-align: center;
    background: var(--review-blue-bg);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 18px;
    border: 1px solid rgba(47, 128, 237, 0.1);
}

.form-rating-selector label {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--review-text-dark);
    margin-bottom: 8px;
}

.stars-selector-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.form-star-item {
    font-size: 32px;
    color: #cbd5e0;
    cursor: pointer;
    transition: color 0.15s, transform 0.1s;
    user-select: none;
}

.form-star-item:hover {
    transform: scale(1.15);
}

.form-star-item.active {
    color: var(--review-gold);
}

.rating-label-text {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--review-text-gray);
}

/* File Upload Area */
.upload-dropzone {
    border: 2px dashed #cbd5e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s, background-color 0.2s;
    background: #fafafa;
}

.upload-dropzone:hover {
    border-color: var(--review-blue);
    background: var(--review-blue-bg);
}

.upload-dropzone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--review-text-gray);
    pointer-events: none;
}

.upload-icon {
    font-size: 28px;
    margin-bottom: 6px;
}

.dropzone-prompt span:last-child {
    font-size: 13px;
    font-weight: 600;
}

.upload-preview-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.preview-item {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--review-border);
}

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

.btn-remove-preview {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    line-height: 18px;
    cursor: pointer;
    text-align: center;
    padding: 0;
}

.btn-remove-preview:hover {
    background: #ef4444;
}

/* Checkbox */
.flex-checkbox {
    display: flex;
    align-items: center;
    height: 100%;
    padding-top: 16px;
}

@media (max-width: 580px) {
    .flex-checkbox {
        padding-top: 0;
        margin-bottom: 16px;
    }
}

.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    height: 20px;
    width: 20px;
    background-color: #eee;
    border-radius: 4px;
    margin-right: 10px;
    display: inline-block;
    position: relative;
    transition: background-color 0.2s;
    border: 1px solid #cbd5e0;
    box-sizing: border-box;
}

.checkbox-container:hover input ~ .checkmark {
    background-color: #ccc;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--review-green);
    border-color: var(--review-green);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--review-text-dark);
}

/* Footer Modal */
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--review-border);
    display: flex;
    justify-content: flex-end;
    background: #ffffff;
}

.btn-submit-review {
    background: var(--review-blue);
    color: #ffffff;
    border: none;
    font-family: var(--review-font-sans);
    font-size: 14px;
    font-weight: 700;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-submit-review:hover {
    background: var(--review-blue-hover);
    box-shadow: 0 4px 12px rgba(47, 128, 237, 0.3);
}

.btn-submit-review.loading {
    background: var(--review-text-gray);
    cursor: not-allowed;
    position: relative;
}

.btn-submit-review.loading span {
    visibility: hidden;
}

.btn-submit-review.loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: button-spinner 0.6s linear infinite;
}

@keyframes button-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* --------------------------------------------------------------------------
 * LIGHTBOX MODAL (Gallery Xem Ảnh Phóng To)
 * -------------------------------------------------------------------------- */
.htn-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10005;
    display: none;
    align-items: center;
    justify-content: center;
}

.htn-lightbox-modal.active {
    display: flex;
}

.lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.lightbox-wrapper {
    position: relative;
    z-index: 10006;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: #ffffff;
    font-size: 36px;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: #cbd5e0;
}

.lightbox-content-box {
    background: #000000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#lightbox-img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}

.lightbox-info-row {
    width: 100%;
    background: #111111;
    padding: 12px 16px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    color: #ffffff;
    font-size: 13.5px;
}

.lightbox-author {
    color: #e2e8f0;
}

.lightbox-author strong {
    color: #ffffff;
}

.lightbox-counter {
    color: var(--review-text-muted);
    font-weight: 600;
}

/* Các nút điều hướng */
.lightbox-prev-btn,
.lightbox-next-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: none;
    font-size: 32px;
    width: 44px;
    height: 44px;
    line-height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.lightbox-prev-btn:hover,
.lightbox-next-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lightbox-prev-btn:active,
.lightbox-next-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-prev-btn {
    left: -60px;
}

.lightbox-next-btn {
    right: -60px;
}

@media (max-width: 768px) {
    .lightbox-prev-btn {
        left: 10px;
    }
    .lightbox-next-btn {
        right: 10px;
    }
    .lightbox-close {
        right: 10px;
        top: -45px;
    }
}
