/**
 * HRM Room Manager - Frontend Styles
 * @package HRM_Room_Manager
 * @since 1.0.0
 */

/* === Featured Image === */
.hrm-room-featured-image {
   width: 100%;
   max-width: 100%;
   overflow: hidden;
   margin-bottom: 30px;
}

.hrm-room-featured-image img {
   display: block;
   margin: 0 auto;
   width: 100%;
   height: auto;
}

/* ✅ FIX v1.7: Gallery after featured image (above the price) */
.hrm-room-gallery-section {
   width: 100%;
   box-sizing: border-box;
}

.hrm-room-gallery-section.hrm-gallery-after-featured {
   margin: 20px auto 30px auto;
   padding: 0 15px;
   max-width: 100%;
}

.hrm-room-gallery-section.hrm-gallery-after-content {
   margin: 30px 0;
}

/* Responsive for tablet */
@media (max-width: 1024px) {
   .hrm-room-featured-image {
      margin-bottom: 25px;
   }
   
   .hrm-room-gallery-section.hrm-gallery-after-featured {
      margin: 15px auto 25px auto;
      padding: 0 10px;
   }
}

/* Responsive for mobile */
@media (max-width: 768px) {
   .hrm-room-featured-image {
      margin-bottom: 20px;
   }
   
   .hrm-room-gallery-section.hrm-gallery-after-featured {
      margin: 10px auto 20px auto;
      padding: 0 5px;
   }
}

/* Old thumbnail style - to be removed or overwritten */
 .attachment-full.size-full.wp-post-image {
   /* Border and style */
   border: 7px solid #ddd;
   border-radius: 8px;
   box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);

   /* Correct centering */
   display: block;
   margin: 0 auto 30px auto;

   /* Responsive dimensions */
   width: 80%;
   max-width: 30%;
   height: auto;

   /* Performance */
   object-fit: cover;
}

/* Responsive for tablet */
@media (max-width: 1024px) {
   .attachment-full.size-full.wp-post-image {
      max-width: 700px;
      border-width: 5px;
   }
}

/* Responsive for mobile */
@media (max-width: 768px) {
   .attachment-full.size-full.wp-post-image {
      max-width: 100%;
      border-width: 4px;
      margin-bottom: 20px;
   }
}

/* Responsive for small smartphones */
@media (max-width: 480px) {
   .attachment-full.size-full.wp-post-image {
      border-width: 3px;
      border-radius: 6px;
   }
}
/* === Reset & Base === */
.hrm-rooms-grid,
.hrm-room-card,
.hrm-room-layout {
    box-sizing: border-box;
}

.hrm-rooms-grid *,
.hrm-room-card *,
.hrm-room-layout * {
    box-sizing: border-box;
}

/* === Price Banner === */
.hrm-room-price-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    margin: 0 0 30px 0;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.hrm-room-price-label {
    font-weight: 600;
    opacity: 0.9;
}

.hrm-room-price-value {
    font-size: 24px;
    font-weight: 700;
}

/* === Rooms Grid === */
.hrm-rooms-grid {
    display: grid;
    gap: 30px;
    margin: 30px 0;
}

.hrm-rooms-grid.hrm-columns-1 {
    grid-template-columns: 1fr;
}

.hrm-rooms-grid.hrm-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.hrm-rooms-grid.hrm-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.hrm-rooms-grid.hrm-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* === Room Card === */
.hrm-room-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.hrm-room-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.hrm-room-card-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.hrm-room-thumbnail {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* Aspect ratio 3:2 */
    overflow: hidden;
}

.hrm-room-thumbnail a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.hrm-room-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.hrm-room-card:hover .hrm-room-thumbnail img {
    transform: scale(1.05);
}

.hrm-room-content {
    padding: 25px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hrm-room-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 15px 0;
    line-height: 1.3;
}

.hrm-room-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
}

.hrm-room-title a:hover {
    color: #667eea;
}

.hrm-room-price {
    color: #667eea;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 15px;
}

.hrm-room-excerpt {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    flex: 1;
}

.hrm-room-actions {
    margin-top: auto;
}

/* === Buttons === */
.hrm-button {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
    cursor: pointer;
    border: none;
    font-size: 16px;
}

.hrm-button-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.hrm-button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* === Room Layout (Single Page) === */
.hrm-room-layout {
    display: grid;
    gap: 30px;
    margin: 30px 0;
}

.hrm-room-layout.hrm-layout-columns-1 {
    grid-template-columns: 1fr;
}

.hrm-room-layout.hrm-layout-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.hrm-room-layout.hrm-layout-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.hrm-room-layout.hrm-layout-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.hrm-layout-column {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* === Room Gallery === */
.hrm-room-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 20px auto;  /* ← CAMBIATO: aggiunto auto */
    justify-content: center;
}

.hrm-room-gallery.hrm-gallery-columns-1 {
    max-width: 220px;
}

.hrm-room-gallery.hrm-gallery-columns-2 {
    max-width: 450px;
}

.hrm-room-gallery.hrm-gallery-columns-3 {
    max-width: 680px;
}

.hrm-room-gallery.hrm-gallery-columns-4 {
    max-width: 910px;
}

.hrm-gallery-item {
    position: relative;
    width: 200px;
    height: 200px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background: transparent;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
}

.hrm-gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.hrm-gallery-item a {
    display: block;
    width: 100%;
    position: relative;
}

/* Container for responsive images */
.hrm-gallery-image-container {
    position: relative;
    width: 200px;
    height: 200px;
    overflow: hidden;
    background: transparent;
    margin: 0;
    padding: 0;
    line-height: 0;
}

/* Picture element for responsive images */
.hrm-gallery-picture {
    display: block;
    width: 100%;
    height: auto;
}

.hrm-gallery-picture img {
    width: 100%;
    height: auto;
    display: block;
}

/* Responsive images with srcset */
.hrm-responsive-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* Aspect Ratio Container (for backward compatibility) */
.hrm-gallery-placeholder {
    position: relative;
    width: 100%;
    height: 0;
    /* padding-bottom is set inline for dynamic aspect ratio */
}

.hrm-gallery-placeholder .hrm-gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hrm-gallery-image {
    width: 200px;
    height: 200px;
    display: block;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    padding: 0;
}

.hrm-gallery-link:hover .hrm-gallery-image {
    transform: scale(1.08);
}

/* Caption for images */
.hrm-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 15px;
    font-size: 14px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.hrm-gallery-item:hover .hrm-gallery-caption {
    transform: translateY(0);
}

/* Hover overlay for lightbox */
.hrm-gallery-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.hrm-gallery-link:hover::before {
    opacity: 1;
}

/* Icona zoom */
.hrm-gallery-link::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 32px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.hrm-gallery-link:hover::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Lazy Loading States */
.hrm-gallery-image[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.hrm-gallery-image.loaded {
    animation: none;
    background: none;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Performance optimizations */
.hrm-gallery-image {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    -moz-transform: translateZ(0);
}

/* === Lightbox Styles === */
.hrm-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.hrm-lightbox-overlay.active {
    display: flex;
}

.hrm-lightbox-image {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    animation: lightboxZoom 0.3s ease;
}

@keyframes lightboxZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.hrm-lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 1000000;
    line-height: 1;
}

.hrm-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hrm-lightbox-prev,
.hrm-lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.3s ease;
    z-index: 1000000;
    line-height: 1;
}

.hrm-lightbox-prev {
    left: 20px;
}

.hrm-lightbox-next {
    right: 20px;
}

.hrm-lightbox-prev:hover,
.hrm-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.3);
}

.hrm-lightbox-caption {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    max-width: 80%;
    text-align: center;
    z-index: 1000000;
}

.hrm-lightbox-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 1000001;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === Responsive Design === */
@media (max-width: 1024px) {
    .hrm-rooms-grid.hrm-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .hrm-room-layout.hrm-layout-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .hrm-rooms-grid.hrm-columns-3,
    .hrm-rooms-grid.hrm-columns-4 {
        grid-template-columns: 1fr;
    }

    .hrm-rooms-grid.hrm-columns-2 {
        grid-template-columns: 1fr;
    }

    .hrm-room-layout.hrm-layout-columns-2,
    .hrm-room-layout.hrm-layout-columns-3,
    .hrm-room-layout.hrm-layout-columns-4 {
        grid-template-columns: 1fr;
    }

    .hrm-room-gallery.hrm-gallery-columns-3,
    .hrm-room-gallery.hrm-gallery-columns-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .hrm-room-price-banner {
        padding: 15px 20px;
        font-size: 16px;
    }

    .hrm-room-price-value {
        font-size: 20px;
    }

    .hrm-room-title {
        font-size: 20px;
    }

    .hrm-layout-column {
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .hrm-rooms-grid {
        gap: 20px;
    }

    .hrm-room-layout {
        gap: 20px;
    }

    .hrm-room-gallery.hrm-gallery-columns-2 {
        grid-template-columns: 1fr;
    }

    .hrm-room-content {
        padding: 20px;
    }

    .hrm-button {
        width: 100%;
    }
}

/* === Accessibility === */
.hrm-room-card:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.hrm-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* === Print Styles === */
@media print {
    .hrm-room-actions,
    .hrm-button {
        display: none;
    }

    .hrm-room-card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}
