/**
 * Morehouse Property Listings - Gallery Stylesheet
 */

/* SVG Reset - Ensure inline SVGs are always visible */
.mh-property-single svg,
.mh-gallery svg,
.mh-sticky-header svg {
    display: inline-block !important;
    visibility: visible !important;
    /* fill: currentColor; */
}

/* =================================
   Sticky Header (Idealista-style)
================================= */
.mh-sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.mh-sticky-header.visible {
    transform: translateY(0);
}

/* Account for WP admin bar */
body.admin-bar .mh-sticky-header {
    top: 32px;
}

@media screen and (max-width: 782px) {
    body.admin-bar .mh-sticky-header {
        top: 46px;
    }
}

.mh-sticky-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mh-sticky-back {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--mh-text-muted);
    transition: color var(--mh-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mh-sticky-back:hover {
    color: var(--mh-primary);
}

.mh-sticky-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
}

.mh-sticky-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--mh-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.mh-sticky-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--mh-primary);
}

.mh-sticky-stats {
    font-size: 0.875rem;
    color: var(--mh-text-muted);
}

.mh-sticky-actions {
    display: flex;
    gap: 0.5rem;
}

.mh-btn-icon {
    background: none;
    border: 1px solid var(--mh-border);
    border-radius: var(--mh-radius-sm);
    padding: 0.5rem;
    cursor: pointer;
    color: var(--mh-text-muted);
    transition: all var(--mh-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mh-btn-icon:hover {
    border-color: var(--mh-primary);
    color: var(--mh-primary);
}

.mh-btn-icon.active {
    background: var(--mh-primary);
    border-color: var(--mh-primary);
    color: #fff;
}

/* =================================
   Single Property Styles
================================= */
.mh-property-single {
    max-width: 900px;
    margin: 0 auto;
    padding: 0;
}

.mh-property-back {
    padding: 1rem 1.5rem;
}

.mh-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--mh-text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color var(--mh-transition);
}

.mh-back-link:hover {
    color: var(--mh-primary);
}

/* Gallery Back Link (Idealista-style overlay) */
.mh-gallery-back {
    padding: 1rem 0rem;
    background: var(--mh-bg);
}

/* Property Header (Idealista-style: below gallery) */
.mh-property-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem 0rem;
    background: var(--mh-bg);
    /* border-bottom: 1px solid var(--mh-border); */
}

.mh-property-title-group {
    flex: 1;
    min-width: 280px;
}

.mh-property-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.5rem;
    color: var(--mh-text);
    line-height: 1.3;
}

.mh-property-address {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--mh-text-muted);
    margin: 0;
    font-size: 0.95rem;
}

.mh-view-map-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--mh-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color var(--mh-transition);
}

.mh-view-map-link:hover {
    color: var(--mh-primary-dark);
    text-decoration: underline;
}

.mh-property-price-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-end;
    text-align: right;
}

.mh-price {
    text-align: right;
}

.mh-price-label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--mh-text-muted);
    margin-bottom: 0.125rem;
}

.mh-price-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.mh-price-sale .mh-price-value {
    color: var(--mh-text);
}

.mh-price-rent .mh-price-value {
    color: var(--mh-secondary);
    font-size: 1.25rem;
}

/* When rent is the only price, use larger font */
.mh-property-price-group .mh-price-rent:only-child .mh-price-value {
    font-size: 1.75rem;
}

/* Reference Badge (Idealista-style) */
.mh-property-ref-badge {
    flex-basis: 100%;
    margin-top: 0.5rem;
}

.mh-property-ref {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--mh-bg-alt);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--mh-text-muted);
    letter-spacing: 0.02em;
}

/* =================================
   Gallery (Idealista-style: full-width, clean)
================================= */
.mh-gallery {
    margin-bottom: 0;
    background: var(--mh-bg);
    overflow: hidden;
}

.mh-gallery-main {
    position: relative;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mh-gallery-viewport {
    width: 100%;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-height: 500px;
}

.mh-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: zoom-in;
}

.mh-gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--mh-transition);
    z-index: 10;
    color: var(--mh-text); /* Fix invisible icon */
}

.mh-gallery-nav:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.1);
    color: var(--mh-primary);
}

.mh-gallery-nav svg {
    width: 24px !important;
    height: 24px !important;
    min-width: 24px;
    flex-shrink: 0;
}

.mh-gallery-prev {
    left: 1rem;
}

.mh-gallery-next {
    right: 1rem;
}

.mh-gallery-fullscreen {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: var(--mh-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all var(--mh-transition);
    color: var(--mh-text); /* Fix invisible icon */
}

.mh-gallery-fullscreen:hover {
    background: #fff;
    color: var(--mh-primary);
}

.mh-gallery-fullscreen svg {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px;
    flex-shrink: 0;
}

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

/* Thumbnails (Idealista-style strip) */
.mh-gallery-thumbs {
    display: flex;
    gap: 0.375rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    background: var(--mh-bg);
    border-top: 1px solid var(--mh-border);
    scrollbar-width: thin;
    scrollbar-color: var(--mh-border) transparent;
}

.mh-gallery-thumbs::-webkit-scrollbar {
    height: 6px;
}

.mh-gallery-thumbs::-webkit-scrollbar-track {
    background: transparent;
}

.mh-gallery-thumbs::-webkit-scrollbar-thumb {
    background: var(--mh-border);
    border-radius: 3px;
}

.mh-thumb {
    flex-shrink: 0;
    width: 72px;
    height: 54px;
    padding: 0;
    border: 2px solid var(--mh-border);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.8;
    transition: all var(--mh-transition);
    background: none;
}

.mh-thumb:hover {
    opacity: 1;
    border-color: var(--mh-text-muted);
}

.mh-thumb.active {
    border-color: var(--mh-primary);
    opacity: 1;
    box-shadow: 0 0 0 1px var(--mh-primary);
}

.mh-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* =================================
   Lightbox
================================= */
.mh-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.mh-lightbox.open {
    display: flex;
}

.mh-lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #ffffff;
    font-size: 2rem;
    cursor: pointer;
    transition: background var(--mh-transition);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mh-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mh-lightbox-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.mh-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--mh-transition);
    color: #ffffff; /* Ensure white icon */
}

.mh-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mh-lightbox-prev {
    left: 1rem;
}

.mh-lightbox-next {
    right: 1rem;
}

.mh-lightbox-nav svg {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px;
    flex-shrink: 0;
}

/* =================================
   Property Details
================================= */
.mh-property-details {
    display: grid;
    gap: 2rem;
}

.mh-property-section {
    background: var(--mh-bg);
    margin-bottom: 0.5rem;
    /* border-radius: var(--mh-radius); */
    /* padding: 1.5rem; */
    /* box-shadow: var(--mh-shadow); */
}

.mh-property-section h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0 0 1.25rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--mh-border);
}

/* Key Features */
.mh-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
}

.mh-feature {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.mh-feature svg {
    flex-shrink: 0;
    color: var(--mh-primary);
}

.mh-feature-content {
    display: flex;
    flex-direction: column;
}

.mh-feature-label {
    font-size: 0.75rem;
    color: var(--mh-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mh-feature-value {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Location */
.mh-location p {
    margin: 0;
    font-size: 1.05rem;
}

/* =================================
   Quick Summary Bar (below gallery)
================================= */
.mh-quick-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    padding: 1rem 0;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    color: var(--mh-text);
}

.mh-summary-item {
    display: inline-flex;
    align-items: center;
}

.mh-summary-item:not(:last-child)::after {
    content: '|';
    margin-left: 1.5rem;
    color: var(--mh-border);
}

/* =================================
   Listed Badge
================================= */
.mh-listed-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--mh-bg-alt);
    border-radius: var(--mh-radius-sm);
    font-size: 0.875rem;
    color: var(--mh-text-muted);
    margin-bottom: 1.5rem;
}

.mh-listed-badge svg {
    color: var(--mh-primary);
}

/* =================================
   Description Section
================================= */
.mh-description h2 {
    margin-bottom: 1rem;
}

.mh-description-content p {
    margin: 0;
    line-height: 1.7;
    color: var(--mh-text);
    white-space: pre-wrap;
}

.mh-description-text.mh-collapsed {
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.mh-description-text.mh-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--mh-bg));
    pointer-events: none;
}

.mh-description-text.mh-expanded {
    max-height: none;
}

.mh-description-text.mh-expanded::after {
    display: none;
}

.mh-read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0;
    background: none;
    border: none;
    color: var(--mh-primary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--mh-transition);
}

.mh-read-more:hover {
    color: var(--mh-primary-dark, #6b0000);
}

.mh-read-more svg {
    transition: transform var(--mh-transition);
}

.mh-read-more.expanded svg {
    transform: rotate(180deg);
}

/* =================================
   Basic Characteristics (Idealista-style)
================================= */
.mh-basic-characteristics h2 {
    margin-bottom: 1rem;
}

.mh-characteristics-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 2rem;
}

.mh-characteristics-list li {
    position: relative;
    padding-left: 1.25rem;
    font-size: 0.95rem;
    color: var(--mh-text);
    line-height: 1.5;
}

.mh-characteristics-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--mh-text-muted);
    font-weight: bold;
}

@media (max-width: 600px) {
    .mh-characteristics-list {
        grid-template-columns: 1fr;
    }
}

/* Amenities */
.mh-amenities-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mh-amenity-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

.mh-amenity-item svg {
    color: var(--mh-success);
    flex-shrink: 0;
}

/* =================================
   Responsive (Idealista-style mobile)
================================= */
@media (max-width: 768px) {
    .mh-property-header {
        flex-direction: column;
        /* padding: 1rem; */
        gap: 0.75rem;
    }

    .mh-property-title {
        font-size: 1.25rem;
    }

    .mh-property-address {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .mh-property-price-group {
        align-items: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .mh-price {
        text-align: left;
    }

    .mh-price-value {
        font-size: 1.5rem;
    }

    .mh-price-rent .mh-price-value {
        font-size: 1.125rem;
    }

    /* When rent is the only price, use larger font on mobile */
    .mh-property-price-group .mh-price-rent:only-child .mh-price-value {
        font-size: 1.5rem;
    }

    .mh-property-ref-badge {
        margin-top: 0.25rem;
    }

    .mh-gallery-back {
        padding: 0.75rem 0rem;
    }

    .mh-gallery-viewport {
        aspect-ratio: 4/3;
        max-height: 350px;
    }

    .mh-gallery-nav {
        width: 40px;
        height: 40px;
    }

    .mh-gallery-prev {
        left: 0.5rem;
    }

    .mh-gallery-next {
        right: 0.5rem;
    }

    .mh-lightbox-nav {
        width: 48px;
        height: 48px;
    }

    .mh-lightbox-nav svg {
        width: 28px !important;
        height: 28px !important;
    }

    .mh-lightbox-close {
        width: 44px;
        height: 44px;
        font-size: 1.75rem;
    }

    .mh-gallery-thumbs {
        padding: 0.5rem;
        gap: 0.25rem;
    }

    .mh-thumb {
        width: 56px;
        height: 42px;
    }

    .mh-features-grid,
    .mh-amenities-list {
        grid-template-columns: 1fr 1fr;
    }

    /* Sticky header mobile */
    .mh-sticky-title {
        max-width: 150px;
        font-size: 0.9rem;
    }

    .mh-sticky-price {
        font-size: 1rem;
    }

    .mh-sticky-stats {
        display: none;
    }

    /* Quick summary mobile */
    .mh-quick-summary {
        font-size: 0.875rem;
    }

    .mh-summary-item:not(:last-child)::after {
        margin-left: 1rem;
    }
}

@media (max-width: 480px) {
    .mh-property-title {
        font-size: 1.125rem;
    }

    .mh-price-value {
        font-size: 1.25rem;
    }

    .mh-features-grid {
        grid-template-columns: 1fr;
    }
}

/* =================================
   Page Wrappers for Clean URLs
================================= */
.mh-property-page-wrapper,
.mh-listings-page-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.mh-listings-page-wrapper {
    padding-top: 1rem;
}

/* Touch-friendly gallery enhancements */
.mh-gallery-viewport {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.mh-gallery-image {
    pointer-events: auto;
    transition: opacity 0.15s ease;
}

.mh-gallery-image.loading {
    opacity: 0.5;
}

/* Gallery swipe indicators (mobile) */
.mh-gallery-swipe-hint {
    display: none;
    position: absolute;
    bottom: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    animation: mh-fade-out 3s forwards;
    animation-delay: 2s;
}

@keyframes mh-fade-out {
    from { opacity: 1; }
    to { opacity: 0; visibility: hidden; }
}

@media (max-width: 768px) {
    .mh-gallery-swipe-hint {
        display: block;
    }

    .mh-gallery-nav {
        opacity: 0.6;
    }
}

/* Lightbox touch support */
.mh-lightbox {
    touch-action: none;
}

.mh-lightbox-image {
    touch-action: pan-y pinch-zoom;
}
