/**
 * Room Grid Styles
 * 
 * Responsive grid layout for room selection with lazy loading support
 * Compatible with CodeCanyon standards
 *
 * @package HRMRM_Booking_Manager
 * @since 1.1.0
 */

/* ============================================
   Grid Container
   ============================================ */

.hrmrm-room-grid-wrapper {
    position: relative;
    width: 100%;
    margin: 2rem 0;
}

.hrmrm-room-grid {
    display: grid;
    gap: 2rem;
    width: 100%;
    opacity: 1; /* Changed from 0 to 1 - visible by default */
    transition: opacity 0.3s ease-in-out;
}

.hrmrm-room-grid.hrmrm-loading {
    opacity: 0; /* Only hide when explicitly loading */
}

.hrmrm-room-grid.hrmrm-loaded {
    opacity: 1;
}

/* Grid Columns */
.hrmrm-room-grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.hrmrm-room-grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.hrmrm-room-grid-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ============================================
   Room Card
   ============================================ */

.hrmrm-room-card {
    position: relative;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.hrmrm-room-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

.hrmrm-room-card:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.hrmrm-room-card.hrmrm-selected {
    border: 3px solid #0073aa;
    box-shadow: 0 4px 20px rgba(0, 115, 170, 0.3);
}

/* ============================================
   Card Image
   ============================================ */

.hrmrm-room-card-image {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* 3:2 aspect ratio */
    background: #f5f5f5;
    overflow: hidden;
}

.hrmrm-room-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    opacity: 1; /* Ensure images are visible */
}

.hrmrm-room-card:hover .hrmrm-room-card-image img {
    transform: scale(1.05);
}

/* Legacy Lazy Loading States - for backwards compatibility */
.hrmrm-lazy-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hrmrm-lazy-image.hrmrm-loaded {
    opacity: 1;
}

.hrmrm-lazy-image.hrmrm-error {
    opacity: 0;
}

/* Image Loading Spinner */
.hrmrm-image-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hrmrm-lazy-image.hrmrm-loaded ~ .hrmrm-image-loading,
.hrmrm-lazy-image.hrmrm-error ~ .hrmrm-image-loading {
    display: none;
}

/* Placeholder for rooms without image */
.hrmrm-room-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.hrmrm-room-placeholder svg {
    width: 64px;
    height: 64px;
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   Selected Overlay
   ============================================ */

.hrmrm-room-selected-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 115, 170, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.hrmrm-room-card.hrmrm-selected .hrmrm-room-selected-overlay {
    opacity: 1;
}

.hrmrm-room-selected-overlay svg {
    width: 64px;
    height: 64px;
    color: #ffffff;
    animation: hrmrm-check-in 0.3s ease;
}

@keyframes hrmrm-check-in {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================
   Card Content
   ============================================ */

.hrmrm-room-card-content {
    padding: 1.5rem;
    display: block !important;
    text-align: center !important;
    width: 100% !important;
}

.hrmrm-room-card-title {
    margin: 0 0 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.4;
    text-align: center !important;
}

.hrmrm-room-card-excerpt {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
    text-align: center !important;
}

/* ============================================
   Price Display
   ============================================ */

.hrmrm-room-card-price {
    display: block !important;
    text-align: center !important;
    margin: 1rem auto 1.25rem auto !important;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #0073aa;
    width: 100% !important;
}

.hrmrm-price-label {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 0.5rem;
}

.hrmrm-price-amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0073aa;
    line-height: 1;
    margin-right: 0.5rem;
}

.hrmrm-price-period {
    font-size: 0.85rem;
    color: #666;
}

/* ============================================
   Select Button
   ============================================ */

.hrmrm-select-room-btn {
    display: block !important;
    width: 100% !important;
    padding: 0.875rem 1.5rem !important;
    margin: 0 auto !important;
    background: #0073aa !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

.hrmrm-select-room-btn:hover {
    background: #005a87 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.hrmrm-select-room-btn:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.hrmrm-select-room-btn:active {
    transform: translateY(0);
}

.hrmrm-room-card.hrmrm-selected .hrmrm-select-room-btn {
    background: #00a32a !important;
}

.hrmrm-room-card.hrmrm-selected .hrmrm-select-room-btn:hover {
    background: #008a20 !important;
}

/* View Room Button */
.hrmrm-view-room-btn {
    display: block !important;
    width: 100% !important;
    margin: 10px auto 0 auto !important;
    padding: 0.875rem 1.5rem !important;
    background: #28a745 !important;
    color: #ffffff !important;
    text-align: center !important;
    text-decoration: none !important;
    border: none !important;
    border-radius: 4px !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-sizing: border-box !important;
}

.hrmrm-view-room-btn:hover {
    background: #218838 !important;
    color: #ffffff !important;
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.hrmrm-view-room-btn:focus {
    outline: 3px solid #28a745;
    outline-offset: 2px;
    color: #ffffff !important;
}

.hrmrm-view-room-btn:visited {
    color: #ffffff !important;
}

/* ============================================
   Loading & Error States
   ============================================ */

.hrmrm-grid-loading {
    text-align: center;
    padding: 3rem 1rem;
}

.hrmrm-grid-loading p {
    margin-top: 1rem;
    color: #666;
    font-size: 1rem;
}

.hrmrm-grid-error {
    text-align: center;
    padding: 2rem;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
}

.hrmrm-no-rooms {
    text-align: center;
    padding: 3rem 1rem;
    color: #666;
    font-size: 1.1rem;
}

/* ============================================
   Spinners
   ============================================ */

.hrmrm-spinner,
.hrmrm-spinner-small {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 115, 170, 0.2);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: hrmrm-spin 0.8s linear infinite;
}

.hrmrm-spinner-small {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

@keyframes hrmrm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablets (landscape) */
@media (max-width: 1024px) {
    .hrmrm-room-grid-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Tablets (portrait) */
@media (max-width: 768px) {
    .hrmrm-room-grid-cols-3,
    .hrmrm-room-grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .hrmrm-room-grid {
        gap: 1.5rem;
    }

    .hrmrm-room-card-content {
        padding: 1.25rem;
    }

    .hrmrm-room-card-title {
        font-size: 1.1rem;
    }

    .hrmrm-price-amount {
        font-size: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .hrmrm-room-grid-cols-2,
    .hrmrm-room-grid-cols-3,
    .hrmrm-room-grid-cols-4 {
        grid-template-columns: 1fr;
    }

    .hrmrm-room-grid {
        gap: 1.25rem;
    }

    .hrmrm-room-card-content {
        padding: 1rem;
    }

    .hrmrm-room-card-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .hrmrm-room-card-excerpt {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .hrmrm-room-card-price {
        margin: 0.75rem 0 1rem;
        padding: 0.75rem;
    }

    .hrmrm-price-amount {
        font-size: 1.35rem;
    }

    .hrmrm-select-room-btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
}

/* ============================================
   Accessibility
   ============================================ */

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .hrmrm-room-card {
        border: 2px solid #000;
    }

    .hrmrm-room-card.hrmrm-selected {
        border-width: 4px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .hrmrm-room-card,
    .hrmrm-room-card-image img,
    .hrmrm-lazy-image,
    .hrmrm-room-selected-overlay,
    .hrmrm-select-room-btn {
        transition: none;
    }

    .hrmrm-room-card:hover {
        transform: none;
    }

    .hrmrm-room-card:hover .hrmrm-room-card-image img {
        transform: none;
    }

    @keyframes hrmrm-check-in {
        0%, 100% {
            transform: scale(1);
            opacity: 1;
        }
    }
}

/* Focus Visible (keyboard navigation) */
.hrmrm-room-card:focus-visible {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.hrmrm-select-room-btn:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .hrmrm-room-grid {
        display: block;
    }

    .hrmrm-room-card {
        page-break-inside: avoid;
        margin-bottom: 1rem;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .hrmrm-select-room-btn,
    .hrmrm-room-selected-overlay {
        display: none;
    }
}

/* ============================================
   Theme Compatibility Overrides
   Twenty Twenty, Twenty Twenty-One, Twenty Twenty-Two, etc.
   ============================================ */

/* Reset any theme float/alignment on our elements */
.entry-content .hrmrm-room-grid-wrapper,
.post-content .hrmrm-room-grid-wrapper,
.page-content .hrmrm-room-grid-wrapper,
article .hrmrm-room-grid-wrapper,
.site-content .hrmrm-room-grid-wrapper,
.content-area .hrmrm-room-grid-wrapper {
    float: none !important;
    clear: both !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Card content container - force center alignment */
.entry-content .hrmrm-room-card-content,
.post-content .hrmrm-room-card-content,
.page-content .hrmrm-room-card-content,
article .hrmrm-room-card-content,
body .hrmrm-room-card-content {
    display: block !important;
    text-align: center !important;
    float: none !important;
    width: 100% !important;
}

/* Select Button - Twenty Twenty override */
.entry-content .hrmrm-select-room-btn,
.entry-content button.hrmrm-select-room-btn,
.post-content .hrmrm-select-room-btn,
.page-content .hrmrm-select-room-btn,
article .hrmrm-select-room-btn,
body .hrmrm-select-room-btn,
.hrmrm-room-card .hrmrm-select-room-btn {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    float: none !important;
    text-align: center !important;
    background: #0073aa !important;
    color: #ffffff !important;
    padding: 0.875rem 1.5rem !important;
    border: none !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    box-sizing: border-box !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
    transform: none !important;
}

/* View Room Button - Twenty Twenty override */
.entry-content .hrmrm-view-room-btn,
.entry-content a.hrmrm-view-room-btn,
.post-content .hrmrm-view-room-btn,
.page-content .hrmrm-view-room-btn,
article .hrmrm-view-room-btn,
body .hrmrm-view-room-btn,
body a.hrmrm-view-room-btn,
.hrmrm-room-card .hrmrm-view-room-btn,
.hrmrm-room-card a.hrmrm-view-room-btn {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 10px auto 0 auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
    float: none !important;
    text-align: center !important;
    background: #28a745 !important;
    color: #ffffff !important;
    padding: 0.875rem 1.5rem !important;
    border: none !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    box-sizing: border-box !important;
    position: relative !important;
    left: auto !important;
    right: auto !important;
}

/* Hover states with theme override */
.entry-content .hrmrm-select-room-btn:hover,
.entry-content button.hrmrm-select-room-btn:hover,
body .hrmrm-select-room-btn:hover {
    background: #005a87 !important;
    color: #ffffff !important;
}

.entry-content .hrmrm-view-room-btn:hover,
.entry-content a.hrmrm-view-room-btn:hover,
body .hrmrm-view-room-btn:hover,
body a.hrmrm-view-room-btn:hover {
    background: #218838 !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

/* Visited state for links */
.entry-content a.hrmrm-view-room-btn:visited,
body a.hrmrm-view-room-btn:visited {
    color: #ffffff !important;
}

/* Focus states */
.entry-content .hrmrm-select-room-btn:focus,
.entry-content .hrmrm-view-room-btn:focus,
body .hrmrm-select-room-btn:focus,
body .hrmrm-view-room-btn:focus {
    outline: 3px solid #0073aa !important;
    outline-offset: 2px !important;
}

/* Twenty Twenty specific - reset button container alignment */
.singular .entry-content .hrmrm-room-card-content,
.singular .post-inner .hrmrm-room-card-content,
.post-inner .hrmrm-room-card-content {
    text-align: center !important;
}

/* Twenty Twenty specific - override link styles in content */
.singular .entry-content a.hrmrm-view-room-btn,
.post-inner a.hrmrm-view-room-btn {
    color: #ffffff !important;
    text-decoration: none !important;
    background: #28a745 !important;
}

.singular .entry-content a.hrmrm-view-room-btn:hover,
.post-inner a.hrmrm-view-room-btn:hover {
    color: #ffffff !important;
    text-decoration: none !important;
    background: #218838 !important;
}
