/* pages/facility-details/view.css */

/* Facility Details Section */
.facility-details {
    padding: 60px 0;
    background-color: #f8f9fa;
}

/* Main Image - ปรับขนาดให้เหมาะสม */
.facility-main-image {
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    max-height: 500px;
}

.facility-main-image img {
    width: 100%;
    height: 500px;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.facility-main-image:hover img {
    transform: scale(1.02);
}

/* Facility Header */
.facility-header .badge {
    font-size: 14px;
    padding: 8px 15px;
    font-weight: 500;
}

.facility-title {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    margin-bottom: 10px;
}

.facility-location {
    font-size: 16px;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
}

.facility-location i {
    font-size: 18px;
}

/* Description */
.facility-description h4,
.facility-features h4,
.facility-gallery h4,
.facility-map h4 {
    font-size: 22px;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.facility-description .content {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    line-height: 1.8;
    color: #555;
}

.facility-description .content p {
    margin-bottom: 15px;
}

.facility-description .content img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
    margin: 20px 0;
}

/* Features List */
.features-list {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    list-style: none;
    margin: 0;
}

.features-list li {
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #555;
}

.features-list li:last-child {
    border-bottom: none;
}

.features-list li i {
    color: #28a745;
    font-size: 18px;
}

/* Gallery - ปรับปรุงให้คล้าย gallery.php */
.facility-gallery .gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
    height: 200px;
}

.facility-gallery .gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.facility-gallery .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s;
}

.facility-gallery .gallery-item:hover img {
    transform: scale(1.1);
}

/* Gallery Hover Overlay */
.gallery-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(102, 126, 234, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.facility-gallery .gallery-item:hover .gallery-hover-overlay {
    opacity: 1;
}

.gallery-hover-overlay svg {
    color: white;
    animation: pulse 1.5s infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Map */
.map-container {
    position: relative;
    overflow: hidden;
    padding-bottom: 56.25%;
    height: 0;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.map-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Sidebar Cards */
.info-card,
.related-card {
    background: #fff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 100%;
}

.info-card h5,
.related-card h5 {
    font-size: 20px;
    font-weight: 700;
    color: #333;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-card h5 i,
.related-card h5 i {
    color: #667eea;
    font-size: 22px;
}

/* Info Item */
.info-item {
    display: flex;
    gap: 15px;
    padding: 15px 0;
    border-bottom: 1px solid #f0f0f0;
}

.info-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.info-item i {
    color: #667eea;
    font-size: 20px;
    margin-top: 3px;
}

.info-item strong {
    display: block;
    color: #333;
    margin-bottom: 5px;
    font-size: 14px;
}

.info-item p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.info-item a {
    color: #667eea;
    text-decoration: none;
}

.info-item a:hover {
    text-decoration: underline;
}

/* Related Item */
.related-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.related-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.related-item a {
    display: flex;
    gap: 15px;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
}

.related-item a:hover {
    transform: translateX(5px);
}

.related-img {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 8px;
}

.related-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-content h6 {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.related-content p {
    font-size: 13px;
    color: #667eea;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 3px;
}

/* ===== Gallery Modal Styles - คัดลอกมาจาก gallery.php ===== */
#facilityGalleryModal {
    z-index: 999999 !important;
    pointer-events: none !important;
}

#facilityGalleryModal.show {
    z-index: 999999 !important;
    display: flex !important;
}

.modal-backdrop {
    z-index: 999998 !important;
    pointer-events: none !important;
    opacity: 0.3 !important;
    background-color: rgba(0, 0, 0, 0.3) !important;
}

.modal-backdrop.show {
    z-index: 999998 !important;
    pointer-events: none !important;
    opacity: 0.3 !important;
}

#facilityGalleryModal .modal-dialog {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    margin: 0;
    z-index: 1000000 !important;
    pointer-events: auto !important;
    position: relative !important;
}

.gallery-modal-content {
    height: 100%;
    background: #000;
    border: none;
    border-radius: 0;
    overflow: hidden;
    z-index: 1000001 !important;
    pointer-events: auto !important;
    position: relative !important;
}

/* Close Button */
.gallery-modal-close {
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
    z-index: 999999999 !important;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.95) !important;
    border: 3px solid white !important;
    color: white;
    cursor: pointer !important;
    transition: all 0.3s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0;
    pointer-events: auto !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.gallery-modal-close svg {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.gallery-modal-close:hover {
    background: rgba(88, 108, 214, 1) !important;
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.8);
}

.gallery-modal-close:active {
    transform: scale(1.0) rotate(90deg);
}

/* Modal Body */
#facilityGalleryModal .modal-body {
    height: 100%;
    padding: 0;
    pointer-events: auto !important;
    z-index: 1000002 !important;
}

#facilityGalleryModal .carousel {
    height: 100%;
    pointer-events: auto !important;
    z-index: 1000003 !important;
}

#facilityGalleryModal .carousel-inner {
    height: 100%;
}

#facilityGalleryModal .carousel-item {
    height: 100%;
}

/* Image Container */
.gallery-modal-image-container {
    width: 100%;
    height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #000;
    pointer-events: none;
}

.gallery-modal-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
    animation: imageZoomIn 0.4s ease;
    pointer-events: none;
    user-select: none;
}

@keyframes imageZoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Navigation Arrows */
.carousel-control-prev,
.carousel-control-next {
    width: 80px;
    opacity: 1;
    z-index: 1000010 !important;
    top: 50%;
    transform: translateY(-50%);
    height: 100px;
    pointer-events: auto !important;
    cursor: pointer !important;
}

.carousel-control-prev {
    left: 0;
    background: linear-gradient(to right, rgba(0,0,0,0.3), transparent);
}

.carousel-control-next {
    right: 0;
    background: linear-gradient(to left, rgba(0,0,0,0.3), transparent);
}

.carousel-control-prev:hover,
.carousel-control-next:hover {
    opacity: 1;
    background: rgba(0,0,0,0.5);
}

.gallery-nav-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s ease;
    pointer-events: auto !important;
}

.carousel-control-prev:hover .gallery-nav-icon,
.carousel-control-next:hover .gallery-nav-icon {
    background: rgba(102, 126, 234, 0.9);
    border-color: rgba(102, 126, 234, 1);
    transform: scale(1.15);
}

.carousel-control-prev:active .gallery-nav-icon,
.carousel-control-next:active .gallery-nav-icon {
    transform: scale(1.0);
}

/* Thumbnails */
.gallery-thumbnails {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000020 !important;
    overflow-x: auto;
    overflow-y: hidden;
    pointer-events: auto !important;
}

.gallery-thumbnails-track {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-width: min-content;
    padding: 0 10px;
    pointer-events: auto !important;
}

.gallery-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer !important;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.5;
    flex-shrink: 0;
    background: #333;
    pointer-events: auto !important;
}

.gallery-thumbnail:hover {
    opacity: 0.8;
    transform: translateY(-3px);
}

.gallery-thumbnail.active {
    border-color: #667eea;
    opacity: 1;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.6);
    transform: scale(1.05);
}

.gallery-thumbnail:active {
    transform: translateY(-1px) scale(1.0);
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

/* Custom Scrollbar */
.gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.6);
    border-radius: 3px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.8);
}

/* Body modal open */
body.modal-open {
    overflow: hidden !important;
    padding-right: 0 !important;
}

body.modal-open #header,
body.modal-open .header,
body.modal-open .mobile-nav-toggle,
body.modal-open .navmenu,
body.modal-open nav {
    z-index: 998 !important;
    pointer-events: none !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease;
}

body.gallery-modal-open {
    overflow: hidden !important;
}

body.gallery-modal-open #header,
body.gallery-modal-open .header,
body.gallery-modal-open .mobile-nav-toggle,
body.gallery-modal-open .navmenu,
body.gallery-modal-open nav {
    z-index: 998 !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* Force Modal Priority */
.modal.show {
    display: flex !important;
    z-index: 999999 !important;
}

.modal-open .modal {
    z-index: 999999 !important;
}

/* Force all clickable elements */
#facilityGalleryModal .gallery-modal-close,
#facilityGalleryModal .carousel-control-prev,
#facilityGalleryModal .carousel-control-next,
#facilityGalleryModal .gallery-thumbnail,
#facilityGalleryModal .gallery-nav-icon,
#facilityGalleryModal .modal-content,
#facilityGalleryModal .modal-dialog,
#facilityGalleryModal .carousel,
#facilityGalleryModal .modal-body,
#facilityGalleryModal .gallery-thumbnails,
#facilityGalleryModal button {
    pointer-events: auto !important;
}

.gallery-modal-close {
    isolation: isolate !important;
}

#facilityGalleryModal * {
    -webkit-tap-highlight-color: transparent;
}

#facilityGalleryModal button,
#facilityGalleryModal .carousel-control-prev,
#facilityGalleryModal .carousel-control-next,
#facilityGalleryModal .gallery-thumbnail,
#facilityGalleryModal .gallery-modal-close {
    cursor: pointer !important;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .facility-gallery .gallery-item {
        height: 180px;
    }
    
    .gallery-modal-image-container {
        height: calc(100vh - 110px);
    }
}

@media (max-width: 991px) {
    .facility-title {
        font-size: 28px;
    }
    
    .facility-description h4,
    .facility-features h4,
    .facility-gallery h4,
    .facility-map h4 {
        font-size: 20px;
    }
    
    .facility-main-image {
        max-height: 400px;
    }
    
    .facility-main-image img {
        height: 400px;
    }
    
    .facility-gallery .gallery-item {
        height: 160px;
    }
    
    .gallery-nav-icon {
        width: 50px;
        height: 50px;
    }
    
    .gallery-nav-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 60px;
    }
    
    .gallery-modal-image-container {
        height: calc(100vh - 100px);
        padding: 8px;
    }
}

@media (max-width: 767px) {
    .facility-details {
        padding: 40px 0;
    }
    
    .facility-title {
        font-size: 24px;
    }
    
    .facility-location {
        font-size: 14px;
    }
    
    .facility-description .content,
    .features-list {
        padding: 20px;
    }
    
    .facility-main-image {
        max-height: 300px;
    }
    
    .facility-main-image img {
        height: 300px;
    }
    
    .facility-gallery .gallery-item {
        height: 150px;
    }
    
    /* Gallery Modal - Mobile */
    .gallery-modal-close {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
        border-width: 2px;
    }
    
    .gallery-modal-close svg {
        width: 20px;
        height: 20px;
    }
    
    .gallery-modal-image-container {
        height: calc(100vh - 90px);
        padding: 5px;
    }
    
    .gallery-thumbnails {
        padding: 8px 15px;
    }
    
    .gallery-thumbnail {
        width: 70px;
        height: 52px;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 50px;
    }
    
    .gallery-nav-icon {
        width: 45px;
        height: 45px;
    }
    
    .gallery-nav-icon svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 576px) {
    .facility-main-image {
        max-height: 250px;
    }
    
    .facility-main-image img {
        height: 250px;
    }
    
    .facility-gallery .gallery-item {
        height: 140px;
    }
    
    .gallery-modal-close {
        width: 42px;
        height: 42px;
        top: 12px;
        right: 12px;
        border-width: 2px;
    }
    
    .gallery-modal-close svg {
        width: 18px;
        height: 18px;
    }
    
    .gallery-modal-image-container {
        height: calc(100vh - 80px);
        padding: 5px;
    }
    
    .gallery-thumbnails {
        padding: 6px 10px;
    }
    
    .gallery-thumbnails-track {
        gap: 8px;
    }
    
    .gallery-thumbnail {
        width: 60px;
        height: 45px;
    }
    
    .carousel-control-prev,
    .carousel-control-next {
        width: 40px;
        height: 80px;
    }
    
    .gallery-nav-icon {
        width: 40px;
        height: 40px;
    }
    
    .gallery-nav-icon svg {
        width: 18px;
        height: 18px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .gallery-modal-image-container {
        height: calc(100vh - 70px);
    }
    
    .gallery-thumbnails {
        padding: 4px 10px;
    }
    
    .gallery-thumbnail {
        width: 50px;
        height: 38px;
    }
    
    .gallery-modal-close {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
    }
    
    .gallery-modal-close svg {
        width: 16px;
        height: 16px;
    }
}

/* Mobile touch improvements */
@media (hover: none) and (pointer: coarse) {
    #facilityGalleryModal button,
    #facilityGalleryModal .carousel-control-prev,
    #facilityGalleryModal .carousel-control-next,
    #facilityGalleryModal .gallery-thumbnail,
    #facilityGalleryModal .gallery-modal-close {
        touch-action: manipulation;
    }
    
    .gallery-modal-close {
        min-width: 44px;
        min-height: 44px;
    }
    
    .gallery-thumbnail {
        min-width: 60px;
        min-height: 45px;
    }
}

/* Animation */
.facility-main-image,
.facility-description,
.facility-features,
.facility-gallery,
.facility-map {
    animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { transform: scale(0.8); }
    to { transform: scale(1); }
}

/* Print Styles */
@media print {
    .breadcrumbs,
    .related-card {
        display: none;
    }
    
    .facility-main-image {
        box-shadow: none;
    }
    
    .facility-description .content {
        font-size: 12pt;
    }
}