/* Comments CSS - Optimized & Compact Design */
.comments-section {
    margin-top: 20px;
    padding: 15px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.comments-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.comments-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comment-item {
    margin-bottom: 15px;
    padding: 12px;
    background: #fafafa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.comment-header {
    margin-bottom: 8px;
}

.comment-author {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.comment-author-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.comment-product-link {
    color: #007bff;
    text-decoration: none;
    font-size: 13px;
}

.comment-rating {
    margin: 5px 0;
}

.comment-rating img {
    height: 16px;
    width: auto;
}

.comment-content {
    color: #555;
    line-height: 1.5;
    margin: 8px 0;
    font-size: 14px;
}

/* Image Gallery Styles */
.comment-images-gallery {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    justify-content: center; /* Canh giữa các hình ảnh */
    align-content: center;
    align-items: center;
}

.comment-image-item {
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-image-item:hover {
    transform: scale(1.02);
}

.comment-image-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

/* Single image - 50% width, centered */
.comment-image-item.single-image {
    width: 33%;
}

.comment-image-item.single-image img {
    height: 150px;
}

/* Two images - 50% each, centered */
.comment-image-item.two-images {
    width: calc(50% - 2px);
}

/* Three images - 33.33% each, centered */
.comment-image-item.three-images {
    width: calc(33.33% - 3px);
}

/* Four or more images - 25% each for first 4, centered */
.comment-image-item.four-images {
    width: calc(25% - 3px);
}

.comment-image-item.four-images img {
    height: 80px;
}

/* Image overlay for extra count */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 18px;
}

/* Hide mobile overlay on desktop by default */
.mobile-image-overlay {
    display: none;
}

.image-count {
    font-size: 16px;
    font-weight: 600;
}

/* Image Modal Styles */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 90vw;
    max-height: 90vh;
    width: 800px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.image-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.image-modal-close:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.image-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.image-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.image-counter {
    color: #666;
    font-size: 14px;
}

.image-modal-body {
    position: relative;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: #f8f9fa;
}

.image-display {
    flex: 1;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-display img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: opacity 0.3s ease;
}

.image-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    z-index: 1001;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-nav-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

.image-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    max-height: 100px;
    overflow-y: auto;
}

.image-thumbnails {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center; /* Canh giữa thumbnails */
}

.image-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-thumbnail:hover,
.image-thumbnail.active {
    border-color: #007bff;
}

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

.comment-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
    gap: 8px;
}

.comment-stats {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #666;
}

.comment-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.comment-stat img {
    height: 14px;
    width: auto;
}

.comment-time {
    font-size: 11px;
    color: #999;
    font-style: italic;
}

.comment-reply-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.comment-reply-btn:hover {
    background: #0056b3;
    color: #fff;
}

.comment-reply-btn i {
    font-size: 10px;
}

/* Replies Section */
.comment-replies {
    margin-top: 12px;
    padding-left: 15px;
    border-left: 2px solid #e9ecef;
}

.comment-replies-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.comment-reply-item {
    margin-bottom: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border-left: 2px solid #28a745;
}

.comment-reply-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.comment-reply-author {
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-reply-author-name {
    font-weight: 600;
    color: #333;
    font-size: 13px;
}

.admin-badge {
    background: #28a745;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
}

.customer-badge {
    background: #007bff;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
}

.comment-reply-content {
    color: #555;
    line-height: 1.4;
    margin: 6px 0;
    font-size: 13px;
}

.comment-reply-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #f0f0f0;
    flex-wrap: wrap;
    gap: 6px;
}

/* Reply Form */
.reply-form {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
    display: none;
}

.reply-form-body textarea {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    resize: vertical;
    min-height: 60px;
    box-sizing: border-box;
}

.reply-form-actions {
    margin-top: 8px;
    text-align: right;
}

.reply-form-actions button {
    margin-left: 6px;
    padding: 4px 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-reply-cancel {
    background: #6c757d;
    color: white;
}

.btn-reply-submit {
    background: #007bff;
    color: white;
}

.btn-reply-submit:hover {
    background: #0056b3;
}

.btn-reply-cancel:hover {
    background: #545b62;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .comments-section {
        margin-top: 15px;
        padding: 12px;
    }
    
    /* Mobile Comment Images Gallery - Only show 2 images max */
    .comment-images-gallery {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px;
        max-width: 100%;
    }
    
    .comment-images-gallery .comment-image-item:nth-child(n+3) {
        display: none;
    }
    
    .comment-images-gallery .comment-image-item:nth-child(2) {
        position: relative;
    }
    
    /* For single image on mobile, use full width */
    .comment-images-gallery[data-total-images="1"] {
        grid-template-columns: 1fr !important;
    }
    
    /* For exactly 2 images on mobile, no overlay needed */
    .comment-images-gallery[data-total-images="2"] .mobile-image-overlay {
        display: none !important;
    }
    
    /* Hide desktop overlay on mobile */
    .comment-images-gallery .image-overlay {
        display: none;
    }
    
    /* Mobile image overlay for remaining count - Show only on mobile */
    .mobile-image-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        color: white;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        font-size: 18px;
        border-radius: 8px;
        z-index: 1;
    }
    
    /* Mobile Image Modal */
    .image-modal-content {
        max-width: 95vw;
        max-height: 95vh;
        width: 95vw;
    }
    
    .image-modal-header {
        padding: 10px 15px;
    }
    
    .image-modal-header h3 {
        font-size: 16px;
    }
    
    .image-modal-body {
        min-height: 250px;
        padding: 10px;
    }
    
    .image-display img {
        max-height: 250px;
    }
    
    .image-nav-btn {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .prev-btn {
        left: 10px;
    }
    
    .next-btn {
        right: 10px;
    }
    
    .image-modal-close {
        top: 10px;
        right: 15px;
        font-size: 28px;
        width: 35px;
        height: 35px;
    }
    
    .image-thumbnails {
        gap: 6px;
        padding: 10px 15px;
    }
    
    .image-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .comments-title {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .comment-item {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    .comment-author {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .comment-author-name {
        font-size: 13px;
    }
    
    .comment-content {
        font-size: 13px;
    }
    
    .comment-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
    
    .comment-stats {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .comment-replies {
        padding-left: 10px;
        margin-top: 10px;
    }
    
    .comment-reply-item {
        padding: 8px;
    }
    
    .comment-reply-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .comment-reply-content {
        font-size: 12px;
    }
    
    /* Mobile Image Gallery */
    .comment-images-gallery {
        justify-content: center;
    }
    
    .comment-image-item.single-image {
        width: 80%;
        margin: 0 auto;
    }
    
    .comment-image-item.two-images {
        width: calc(50% - 2px);
    }
    
    .comment-image-item.three-images {
        width: calc(50% - 2px);
    }
    
    .comment-image-item.four-images {
        width: calc(50% - 2px);
    }
    
    .image-modal-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .image-modal-body {
        min-height: 300px;
    }
    
    .image-display img {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .comments-section {
        padding: 10px;
        margin-top: 12px;
    }
    
    .comments-title {
        font-size: 15px;
    }
    
    .comment-item {
        padding: 8px;
        border-left-width: 2px;
    }
    
    .comment-author-name {
        font-size: 12px;
    }
    
    .comment-content {
        font-size: 12px;
    }
    
    .comment-reply-btn {
        padding: 3px 6px;
        font-size: 10px;
    }
    
    .comment-replies {
        padding-left: 8px;
    }
    
    .comment-reply-item {
        padding: 6px;
    }
    
    /* Mobile Image Gallery - Stack vertically */
    .comment-images-gallery {
        justify-content: center;
    }
    
    .comment-image-item.single-image {
        width: 90%;
        margin: 0 auto;
    }
    
    .comment-image-item.three-images,
    .comment-image-item.four-images {
        width: 100%;
    }
    
    .comment-image-item img {
        height: 120px;
    }
}

/* Loading Animation */
.comments-loading {
    text-align: center;
    padding: 15px;
    color: #666;
    font-size: 13px;
}

.comments-loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Empty State */
.comments-empty {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 13px;
}

.comments-empty i {
    font-size: 32px;
    color: #ddd;
    margin-bottom: 10px;
}

.comments-empty h3 {
    color: #999;
    margin-bottom: 8px;
    font-size: 16px;
}

.comments-empty p {
    color: #bbb;
    font-size: 12px;
}

/* Load More Button */
.read-more-comments {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

.read-more-comments a {
    display: inline-block;
    padding: 8px 16px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    transition: background-color 0.2s;
}

.read-more-comments a:hover {
    background: #0056b3;
}

.read-more-comments a i {
    margin-right: 5px;
}

/* Modern Review Form Styles */
.modern-review-form {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 24px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modern-review-form.show {
    display: block !important;
}

.review-form-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.review-form-header h4 {
    color: #333;
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.review-form-header p {
    color: #666;
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

/* Rating Section */
.rating-section {
    margin-bottom: 24px;
}

.rating-label {
    display: block;
    color: #333;
    font-weight: 500;
    margin-bottom: 12px;
    font-size: 15px;
}

.star-rating-container {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.star-rating {
    display: flex;
    gap: 4px;
}

.star-rating .star {
    font-size: 28px;
    cursor: pointer;
    transition: all 0.2s ease;
    filter: grayscale(100%);
    opacity: 0.4;
    user-select: none;
}

.star-rating .star:hover,
.star-rating .star.active {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.1);
}

.star-rating .star.active {
    animation: starGlow 0.3s ease-out;
}

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

.rating-feedback {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.rating-text {
    color: #333;
    font-weight: 500;
    font-size: 16px;
}

.rating-count {
    color: #666;
    font-size: 13px;
    margin-top: 2px;
}

/* Review Content Section */
.review-content-section {
    margin-bottom: 24px;
}

.content-label {
    display: block;
    color: #333;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 15px;
}

.review-content-section textarea {
    width: 100%;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.review-content-section textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.char-counter {
    text-align: right;
    margin-top: 6px;
    font-size: 12px;
    color: #666;
}

.char-counter .current-chars {
    font-weight: 500;
}

/* Image Upload Section */
.image-upload-section {
    margin-bottom: 24px;
}

.upload-label {
    display: block;
    color: #333;
    font-weight: 500;
    margin-bottom: 12px;
    font-size: 15px;
}

.image-upload-container {
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #fafafa;
    transition: all 0.2s ease;
}

.image-upload-container:hover {
    border-color: #007bff;
    background: #f8f9ff;
}

.upload-area {
    padding: 24px;
    text-align: center;
    cursor: pointer;
    position: relative;
}

.upload-content {
    pointer-events: none;
}

.upload-content i {
    font-size: 32px;
    color: #007bff;
    margin-bottom: 8px;
}

.upload-content p {
    color: #333;
    font-size: 16px;
    font-weight: 500;
    margin: 0 0 4px 0;
}

.upload-hint {
    color: #666;
    font-size: 12px;
}

/* Image Preview */
.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    padding: 16px;
    border-top: 1px solid #eee;
    background: #fff;
    min-height: 0;
}

.image-preview-container:empty {
    display: none;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #e9ecef;
    background: #f8f9fa;
}

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

.image-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(220, 53, 69, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.image-remove-btn:hover {
    background: rgba(220, 53, 69, 1);
}

/* Form Actions */
.review-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f0;
}

.review-actions .btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #545b62;
}

.btn-submit {
    background: #007bff;
    color: white;
}

.btn-submit:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsive for Review Form */
@media (max-width: 768px) {
    .modern-review-form {
        padding: 20px;
        margin: 16px 0;
        border-radius: 8px;
    }
    
    .review-form-header h4 {
        font-size: 18px;
    }
    
    .star-rating .star {
        font-size: 24px;
    }
    
    .star-rating-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .upload-area {
        padding: 20px 16px;
    }
    
    .upload-content i {
        font-size: 28px;
    }
    
    .upload-content p {
        font-size: 14px;
    }
    
    .image-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
        padding: 12px;
    }
    
    .review-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .review-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .modern-review-form {
        padding: 16px;
        margin: 12px 0;
    }
    
    .star-rating .star {
        font-size: 22px;
    }
    
    .upload-area {
        padding: 16px 12px;
    }
    
    .upload-content i {
        font-size: 24px;
    }
    
    .image-preview-container {
        grid-template-columns: repeat(3, 1fr);
    }
}
