/* Arabic-friendly font stack */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

/* Header */
header {
    background-color: #2c3e50;
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
}

header h1 a {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
}

header h1 a:hover {
    opacity: 0.9;
}

header nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    order: 1;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: background-color 0.3s;
    font-weight: 500;
}

header nav a:hover {
    background-color: rgba(255,255,255,0.15);
}

header nav span {
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

/* Main content */
main {
    padding: 2rem 0;
}

/* Filters */
.filters {
    background-color: white;
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-row label {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
}

.filter-row label input,
.filter-row label select {
    padding: 0.75rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.filter-row label input:focus,
.filter-row label select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.filter-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.filter-actions button {
    padding: 0.75rem 2rem;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.3s, transform 0.2s;
}

.filter-actions button:hover {
    background-color: #34495e;
    transform: translateY(-2px);
}

.filter-actions .reset-filters {
    padding: 0.75rem 2rem;
    background-color: #95a5a6;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    display: inline-block;
    font-weight: 600;
    transition: background-color 0.3s;
}

.filter-actions .reset-filters:hover {
    background-color: #7f8c8d;
}

/* Filter item (non-label container inside a filter row) */
.filter-item {
    flex: 1;
    min-width: 150px;
    display: flex;
    flex-direction: column;
}

.filter-item .field-label {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

/* Areas multi-select (dropdown with checkboxes) */
.areas-select {
    position: relative;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.areas-select[open] {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.areas-select summary {
    padding: 0.75rem;
    cursor: pointer;
    user-select: none;
    font-size: 1rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.areas-select summary::after {
    content: "▾";
    color: #7f8c8d;
    font-size: 0.9rem;
}

.areas-select summary::-webkit-details-marker {
    display: none;
}

.areas-toolbar {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid #eee;
}

.areas-btn {
    background: none;
    border: 1px solid #3498db;
    color: #3498db;
    border-radius: 6px;
    padding: 0.3rem 0.7rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.areas-btn:hover {
    background-color: #3498db;
    color: white;
}

.areas-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.25rem;
    border-top: 1px solid #eee;
}

.area-option {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    padding: 0.25rem;
    border-radius: 4px;
    cursor: pointer;
    min-width: 0 !important;
}

.area-option:hover {
    background-color: #f0f7fc;
}

.area-option input {
    width: auto;
    padding: 0 !important;
    border: none !important;
    accent-color: #3498db;
}

.areas-apply {
    width: calc(100% - 1.5rem);
    margin: 0.5rem 0.75rem 0.75rem;
    padding: 0.6rem;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s;
}

.areas-apply:hover {
    background-color: #2980b9;
}

.areas-empty {
    padding: 0.75rem;
    color: #7f8c8d;
    font-size: 0.9rem;
    border-top: 1px solid #eee;
    margin: 0;
}

/* Filter summary (selected areas) */
.filter-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.5rem;
    font-weight: normal;
    font-size: 0.9rem;
}

.filter-summary-label {
    color: #555;
}

.chip {
    background-color: #eaf4fc;
    color: #2471a3;
    border: 1px solid #c3dff2;
    border-radius: 999px;
    padding: 0.15rem 0.7rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Results count */
.results-count {
    margin-bottom: 1rem;
    font-weight: bold;
}

/* Listings grid */
.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.listing-card {
    background-color: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

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

.listing-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.listing-image {
    height: 220px;
    background-color: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.listing-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

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

.listing-image .placeholder {
    color: #7f8c8d;
    font-size: 1.2rem;
    font-weight: 500;
}

.listing-info {
    padding: 1.5rem;
}

.listing-info h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
}

.listing-info .price {
    font-size: 1.4rem;
    font-weight: 700;
    color: #27ae60;
    margin: 0.75rem 0;
}

.listing-info .area,
.listing-info .rooms {
    color: #7f8c8d;
    margin: 0.5rem 0;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: #7f8c8d;
    grid-column: 1 / -1;
    background-color: white;
    border-radius: 12px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    padding: 0.75rem 1.25rem;
    background-color: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    color: #2c3e50;
    font-weight: 600;
    transition: all 0.3s;
}

.pagination a:hover {
    background-color: #2c3e50;
    color: white;
    border-color: #2c3e50;
    transform: translateY(-2px);
}

.pagination .current {
    background-color: #2c3e50;
    color: white;
    border-color: #2c3e50;
}

/* Detail page */
.listing-detail {
    background-color: white;
    border-radius: 12px;
    padding: 2.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.detail-header h1 {
    margin: 0 0 0.75rem 0;
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 700;
}

.added-date {
    color: #7f8c8d;
    margin: 0 0 2rem 0;
    font-weight: 500;
}

.detail-gallery {
    margin-bottom: 2.5rem;
}

.gallery-main {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.gallery-main-image {
    max-width: 600px;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    margin: 0 auto;
    display: block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.gallery-main-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gallery-thumbnails {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.gallery-thumbnail {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.gallery-thumbnail:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.gallery-main-image:hover {
    transform: scale(1.02);
}

.no-images {
    background-color: #ecf0f1;
    padding: 3rem;
    text-align: center;
    color: #7f8c8d;
    border-radius: 12px;
    font-weight: 500;
}

.info-section {
    margin-bottom: 2.5rem;
}

.info-section h2 {
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 0.75rem;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 600;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.info-item .label {
    font-weight: 600;
    color: #2c3e50;
}

.info-item .value {
    color: #34495e;
    font-weight: 500;
}

.phone-display,
.phone-masked {
    background-color: #f8f9fa;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    border: 2px solid #e0e0e0;
}

.phone-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 1.5rem 0;
}

.phone-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-block;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-call {
    background-color: #3498db;
    color: white;
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.btn-whatsapp {
    background-color: #25d366;
    color: white;
    box-shadow: 0 2px 4px rgba(37, 211, 102, 0.3);
}

.btn-primary {
    background-color: #2c3e50;
    color: white;
    box-shadow: 0 2px 4px rgba(44, 62, 80, 0.3);
}

.phone-message {
    color: #7f8c8d;
    margin: 1rem 0 0 0;
    font-weight: 500;
}

.phone-message a {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
}

.phone-message a:hover {
    text-decoration: underline;
}

.source-link {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
}

.source-link:hover {
    text-decoration: underline;
}

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

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
}

/* Footer */
footer {
    background-color: #2c3e50;
    color: white;
    padding: 1.5rem 0;
    margin-top: 3rem;
    text-align: center;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .filter-row {
        flex-direction: column;
    }
    
    .filter-row label {
        min-width: 100%;
    }
    
    .listings-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .phone-actions {
        flex-direction: column;
    }
    
    .gallery-main {
        grid-template-columns: 1fr;
    }
    
    header .container {
        flex-direction: column;
        gap: 1rem;
    }
    
    header nav {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .listing-detail {
        padding: 1.5rem;
    }
    
    .detail-header h1 {
        font-size: 1.5rem;
    }
}
