/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    color: #484848;
    background-color: #fff;
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    padding: 20px 0;
    border-bottom: 1px solid #e4e4e4;
}

.header h1 {
    font-size: 32px;
    font-weight: 700;
    color: #ff385c;
    text-align: center;
    margin-bottom: 10px;
}

.header p {
    font-size: 16px;
    text-align: center;
    color: #767676;
}

/* Main Content */
.main-content {
    padding: 40px 0;
    display: flex;
    flex-wrap: wrap;
    max-width: 1200px;
    margin: 0 auto;
    gap: 40px;
}

/* Search Form (index.php) */
.search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 40px;
}

.form-group {
    flex: 1;
    min-width: 150px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: #484848;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    background: #fff;
}

.search-form button {
    padding: 14px 24px;
    background: #ff385c;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.search-form button:hover {
    background: #e31c5f;
}

/* Villa Container (index.php) */
.villa-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.villa-card {
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.3s;
}

.villa-card:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.villa-image {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.villa-content {
    padding: 16px;
}

.villa-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #383838;
}

.villa-info {
    font-size: 14px;
    color: #767676;
    margin-bottom: 6px;
}

.villa-price {
    font-size: 16px;
    font-weight: 600;
    color: #ff385c;
    margin: 12px 0;
}

.view-details {
    display: inline-block;
    padding: 10px 20px;
    background: #ff385c;
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
}

.view-details:hover {
    background: #e31c5f;
}

/* Search Popularity Notification (index.php) */
.search-popularity {
    text-align: center;
    font-size: 14px;
    color: #ff385c;
    margin-bottom: 20px;
    font-weight: 500;
}

/* Error and No Results Messages (index.php) */
.error-message,
.no-results {
    text-align: center;
    font-size: 16px;
    color: #767676;
    padding: 20px;
}

/* Details Page Styles */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 8px;
    padding: 0 20px;
}

.gallery-item {
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 12px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.property-details {
    flex: 2;
    min-width: 300px;
    padding: 0 20px;
}

.property-details h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
}

.description p {
    font-size: 16px;
    margin-bottom: 24px;
}

.highlights {
    margin: 24px 0;
}

.highlights h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
}

.highlights ul {
    list-style: none;
}

.highlights li {
    font-size: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
}

.highlights li::before {
    content: '\f058';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #ff385c;
    margin-right: 10px;
}

.amenities {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 24px 0;
}

.amenity {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #e4e4e4;
    border-radius: 8px;
}

.amenity i {
    color: #ff385c;
    margin-right: 12px;
    font-size: 20px;
}

.reviews {
    margin: 20px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.reviews h2 {
    color: #333;
    margin-bottom: 15px;
}

.review-list {
    list-style-type: none;
    padding: 0;
}

.review-item {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.review-text {
    margin: 0 0 10px 0;
    color: #444;
    font-size: 16px;
}

.review-meta {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.review-meta span {
    margin-right: 10px;
}

.full-gallery {
    margin: 40px 0;
    padding: 0 20px;
}

.full-gallery h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
}

.full-gallery img {
    width: calc(33.33% - 8px);
    max-height: 250px;
    object-fit: cover;
    border-radius: 8px;
    margin: 4px;
    cursor: pointer;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.booking-sidebar {
    flex: 1;
    min-width: 300px;
    padding: 0 20px;
}

.booking-card {
    position: sticky;
    top: 20px;
    padding: 24px;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.booking-card h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 20px;
}

.booking-card button {
    width: 100%;
    padding: 14px;
    background: #ff385c;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.booking-card button:hover {
    background: #e31c5f;
}

#price_info {
    margin: 16px 0;
    text-align: center;
    font-size: 16px;
}

.back-link {
    display: block;
    text-align: center;
    color: #ff385c;
    font-weight: 600;
    text-decoration: none;
    margin-top: 20px;
}

.back-link:hover {
    color: #e31c5f;
}

.map-section {
    flex: 100%;
    padding: 0 20px;
}

.map-section h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 16px;
}

#map {
    height: 400px;
    width: 100%;
    border-radius: 12px;
}

/* Modal Styles (details.php) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    overflow: auto;
}

.modal-content {
    margin: 5% auto;
    display: block;
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #bbb;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        padding: 20px 0;
        flex-direction: column;
    }

    .search-form {
        gap: 12px;
    }

    .form-group {
        min-width: 45%;
    }

    .villa-container {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }

    .image-gallery {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .full-gallery img {
        width: calc(50% - 8px);
        max-height: 200px;
    }

    .reviews {
        padding: 15px;
    }

    .review-item {
        padding: 8px;
    }
}

@media (max-width: 480px) {
    .form-group {
        min-width: 100%;
    }

    .villa-container {
        grid-template-columns: 1fr;
    }

    .image-gallery {
        grid-template-columns: 1fr;
    }

    .full-gallery img {
        width: 100%;
        max-height: 300px;
    }

    .amenities {
        grid-template-columns: 1fr;
    }

    .reviews {
        padding: 10px;
    }

    .review-item {
        padding: 6px;
    }
}

/* Safari-specific fixes */
@media not all and (min-resolution:.001dpcm) { 
    @supports (-webkit-appearance:none) and (not (overflow:-webkit-marquee)) and (not (-ms-ime-align:auto)) {
        /* Safari-specific styles */
        .form-group input[type="date"],
        .form-group input[type="text"],
        .form-group select {
            -webkit-appearance: none; /* Remove default Safari styling */
            border: 1px solid #ddd;
            padding: 10px;
            border-radius: 4px;
            font-size: 16px;
            background: #fff;
        }

        /* Ensure flex and grid layouts render correctly on iOS */
        .search-form,
        .villa-container,
        .image-gallery,
        .amenities,
        .full-gallery,
        .reviews,
        .review-list {
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }

        /* Fix input height and alignment */
        .form-group input,
        .form-group select {
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            height: 42px; /* Consistent height for inputs on iOS */
        }

        /* Ensure images render sharply on iOS */
        .villa-image,
        .gallery-item img,
        .full-gallery img {
            -webkit-font-smoothing: antialiased;
            image-rendering: -webkit-optimize-contrast;
        }
    }
}

/* General iOS viewport fix */
@media (max-width: 768px) {
    .container {
        padding: 0 10px; /* Reduce padding on smaller screens for iOS */
    }

    .main-content {
        padding: 20px 10px; /* Adjust padding for iOS */
    }
}

/* Fix low-resolution issue when only 1 or 2 villas are displayed on desktop */
@media (min-width: 1024px) {
    .villa-container:has(.villa-card:nth-child(1):nth-last-child(-n+2)) .villa-image {
        image-rendering: auto;
        max-width: 100%;
        max-height: 300px;
        object-fit: cover;
    }
}


@media (min-width: 1024px) {
    .villa-container:has(.villa-card:nth-child(1):nth-last-child(-n+2)) {
        display: flex !important;
        justify-content: center !important;
    }
    
    .villa-container:has(.villa-card:nth-child(1):nth-last-child(-n+2)) .villa-card {
        flex: 0 1 48% !important;
        max-width: 48% !important;
    }

    .villa-container:has(.villa-card:nth-child(1):nth-last-child(-n+2)) .villa-image {
        image-rendering: auto !important;
        max-width: 100% !important;
        max-height: 300px !important;
        object-fit: cover !important;
    }
}
