/* Blog Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 0;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    
  
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.blog-modal {
    max-width: 90vw;
    max-height: 90vh;
    width: 900px;
    margin: 0;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    background: white;
    position: relative;
    z-index: 100000;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal.active .blog-modal {
    transform: scale(1);
}

.blog-modal .modal-header {
    background: #c4c4c4;
    color: white;
    padding: 1.5rem 2rem;
    border-bottom: none;
    flex-shrink: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.blog-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    max-height: calc(90vh - 100px);
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Cải thiện hiển thị ảnh trong nội dung blog */
.blog-detail-content img:not(.gallery-thumbnail) {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1.5rem 0;
    display: block;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Ẩn toàn bộ gallery thumbnails và các phần tử con */
.gallery-thumbnails,
.gallery-thumbnails *,
.gallery-thumbnail,
.thumbnail-wrapper {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

.blog-detail-content img:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* Đảm bảo ảnh gallery hiển thị đẹp */
.blog-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.blog-gallery img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.blog-gallery img:hover {
    transform: scale(1.03);
}

/* Đảm bảo ảnh nội dung không bị tràn */
.blog-detail-content {
    max-width: 100%;
    overflow: hidden;
}

.blog-detail-content p,
.blog-detail-content div,
.blog-detail-content section {
    max-width: 100%;
    overflow: hidden;
}

.modal-header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.modal-header-content h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    flex: 1;
    line-height: 1.3;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 4px;
    color: white;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.modal-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.blog-modal .modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.blog-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Blog Detail Container */
.blog-detail-container {
    display: block;
    width: 100%;
    min-height: 100%;
}

.blog-hero-image {
    width: 100%;
    margin-bottom: 2rem;
}

.blog-detail-content {
    padding: 0 2rem 2rem;
}

/* Blog Header */
.blog-header {
    margin-bottom: 2rem;
}

.blog-meta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.blog-category-tag,
.blog-date-tag,
.blog-author-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #f3f4f6;
    color: #6b7280;
    padding: 0.5rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.blog-category-tag {
    background: #eff6ff;
    color: #2563eb;
}

.blog-date-tag {
    background: #f0fdf4;
    color: #16a34a;
}

.blog-author-tag {
    background: #fef3c7;
    color: #d97706;
}

.blog-title {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.2;
    margin-bottom: 1rem;
}

.blog-excerpt {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.blog-excerpt p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.6;
    font-weight: 500;
}

/* Blog Content */
.blog-content {
    margin-bottom: 2rem;
}

.blog-body {
    line-height: 1.8;
    color: #374151;
    font-size: 1rem;
}

.blog-body p {
    margin-bottom: 1.5rem;
}

.blog-body img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 1.5rem 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Image Gallery */
.blog-single-image,
.blog-image-gallery {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.blog-single-image img,
.gallery-main-container img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.blog-single-image:hover img,
.gallery-main-container:hover img {
    transform: scale(1.02);
}

.image-overlay,
.gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.blog-single-image:hover .image-overlay,
.gallery-main-container:hover .gallery-overlay {
    opacity: 1;
}

.zoom-btn,
.gallery-zoom {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
    color: #374151;
}

.zoom-btn:hover,
.gallery-zoom:hover {
    background: white;
    transform: scale(1.1);
}

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    color: #374151;
}

.gallery-prev {
    left: 1rem;
}

.gallery-next {
    right: 1rem;
}

.gallery-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.gallery-counter {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.gallery-thumbnails {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    background: #f9fafb;
}

.thumbnail-wrapper {
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.thumbnail-wrapper.active {
    border-color: #667eea;
    transform: scale(1.05);
}

.gallery-thumbnail {
    width: 80px;
    height: 60px;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.thumbnail-wrapper:hover .gallery-thumbnail {
    opacity: 0.8;
}

/* Location Section */
.blog-location-section {
    background: #f9fafb;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.location-header h4 {
    margin: 0 0 1rem 0;
    color: #374151;
    font-size: 1.1rem;
    font-weight: 600;
}

.location-coordinates {
    color: #6b7280;
    margin-bottom: 1rem;
    font-family: monospace;
}

.btn-location {
    background: #667eea;
    color: white;
    border: none;
}

.btn-location:hover {
    background: #5a67d8;
}

/* Blog Footer */
.blog-footer {
    border-top: 1px solid #e5e7eb;
    padding-top: 2rem;
    margin-top: 2rem;
}

.blog-engagement {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.engagement-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6b7280;
    font-weight: 500;
}

.engagement-btn:hover {
    background: #e5e7eb;
    color: #374151;
    transform: translateY(-1px);
}

.blog-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.tag-label {
    font-weight: 600;
    color: #6b7280;
    margin-right: 0.5rem;
}

.tag {
    background: #e5e7eb;
    color: #374151;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal {
        padding: 80px 10px 20px 10px; /* Top padding để tránh menu */
        align-items: flex-start;
        justify-content: center;
    }

    .blog-modal {
        max-width: calc(100vw - 20px); /* Giảm chiều ngang */
        max-height: calc(100vh - 120px); /* Giảm chiều cao để tránh menu */
        width: 100%;
        margin: 0;
        border-radius: 12px; /* Giữ border radius nhỏ */
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }

    .blog-modal .modal-body {
        max-height: calc(100vh - 200px); /* Điều chỉnh chiều cao body */
        padding: 0;
    }

    .blog-modal .modal-header {
        padding: 1rem 1.5rem;
        flex-shrink: 0;
    }

    .modal-header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .modal-header-content h3 {
        font-size: 1.25rem;
        line-height: 1.3;
        margin: 0;
        width: 100%;
        padding-right: 2rem; /* Space for close button */
    }

    .modal-header-actions {
        position: absolute;
        top: 1rem;
        right: 1rem;
        gap: 0.25rem;
    }

    .modal-action-btn,
    .blog-modal .modal-close {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .blog-detail-content {
        padding: 0 1rem 1rem;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Ensure all content fits within mobile viewport */
    .blog-detail-container {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .blog-hero-image,
    .blog-single-image,
    .blog-image-gallery {
        width: 100%;
        max-width: 100%;
        margin-bottom: 1rem;
    }

    .blog-title {
        font-size: 1.5rem;
    }

    .blog-meta-tags {
        gap: 0.5rem;
    }

    .blog-category-tag,
    .blog-date-tag,
    .blog-author-tag {
        font-size: 0.75rem;
        padding: 0.375rem 0.625rem;
    }

    /* Mobile image gallery - single column layout */
    .blog-hero-image {
        margin-bottom: 1rem;
        border-radius: 0;
        overflow: hidden;
    }

    .blog-single-image,
    .blog-image-gallery {
        border-radius: 8px;
        overflow: hidden;
        margin-bottom: 1rem;
    }

    .blog-single-image img,
    .gallery-main-container img {
        height: 220px;
        width: 100%;
        object-fit: cover;
        border-radius: 0;
    }

    /* Gallery thumbnails for mobile */
    .gallery-thumbnails {
        padding: 0.75rem;
        gap: 0.5rem;
        background: #f8f9fa;
        border-radius: 0 0 8px 8px;
    }

    .gallery-thumbnail {
        width: 60px;
        height: 45px;
        border-radius: 4px;
    }

    /* Gallery navigation buttons for mobile */
    .gallery-nav {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .gallery-prev {
        left: 0.5rem;
    }

    .gallery-next {
        right: 0.5rem;
    }

    .gallery-zoom {
        top: 0.5rem;
        right: 0.5rem;
        width: 36px;
        height: 36px;
    }

    /* Ensure images don't overflow */
    .blog-body img {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 1rem 0;
        border-radius: 8px;
    }

    .gallery-nav {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .gallery-thumbnails {
        padding: 0.75rem;
    }

    .gallery-thumbnail {
        width: 60px;
        height: 45px;
    }

    .blog-engagement {
        flex-wrap: wrap;
        gap: 0.75rem;
    }

    .engagement-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.875rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .modal {
        padding: 70px 5px 15px 5px; /* Giảm padding hơn nữa */
    }

    .blog-modal {
        max-width: calc(100vw - 10px);
        max-height: calc(100vh - 100px);
        border-radius: 8px;
    }

    .blog-modal .modal-header {
        padding: 0.75rem 1rem;
    }

    .modal-header-content h3 {
        font-size: 1.1rem;
        padding-right: 3rem;
    }

    .blog-detail-content {
        padding: 0 0.75rem 0.75rem;
    }

    .blog-title {
        font-size: 1.3rem;
    }

    .blog-single-image img,
    .gallery-main-container img {
        height: 180px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .modal {
        padding: 60px 10px 10px 10px;
    }

    .blog-modal {
        max-height: calc(100vh - 80px);
    }

    .blog-modal .modal-body {
        max-height: calc(100vh - 140px);
    }

    .blog-single-image img,
    .gallery-main-container img {
        height: 150px;
    }
}

/* Ensure modal doesn't split into parts */
.modal * {
    box-sizing: border-box;
}

.blog-modal,
.blog-detail-container,
.blog-detail-content {
    contain: layout style;
}

/* Prevent any unwanted breaks or splits */
.blog-detail-container > * {
    break-inside: avoid;
    page-break-inside: avoid;
}

/* Smooth scrolling for all modal content */
.modal-body,
.blog-detail-container {
    scroll-behavior: smooth;
}

/* Fix any potential layout issues */
.blog-modal .modal-body {
    position: relative;
    overflow-x: hidden;
    overflow-y: auto;
}

.blog-detail-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile-specific overflow prevention */
@media (max-width: 768px) {
    /* Prevent horizontal overflow on all modal content */
    .modal,
    .blog-modal,
    .modal-body,
    .blog-detail-container,
    .blog-detail-content,
    .blog-hero-image,
    .blog-content,
    .blog-body {
        overflow-x: hidden !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Ensure text doesn't overflow */
    .blog-title,
    .blog-excerpt p,
    .blog-body p,
    .blog-body {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }

    /* Prevent tables or wide elements from overflowing */
    .blog-body table {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        display: block !important;
        white-space: nowrap !important;
    }

    /* Ensure all images are responsive */
    .blog-body img,
    .blog-hero-image img,
    .blog-single-image img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        object-fit: cover !important;
    }
}

/* Force single column layout */
#blogModal .modal-content {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 900px !important;
}

#blogModal .modal-body {
    display: block !important;
    width: 100% !important;
    flex: 1 !important;
}

/* Prevent any grid or flex layouts that might split content */
.blog-detail-container,
.blog-detail-content,
.blog-hero-image {
    display: block !important;
    width: 100% !important;
    float: none !important;
    clear: both !important;
}

/* Ensure images don't cause layout issues */
.blog-hero-image img,
.blog-single-image img,
.gallery-main-container img {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}
