/* ============================================================
   PropTech Design System
   ============================================================ */

:root {
    /* Brand */
    --color-primary: #1d6e5c;
    --color-primary-dark: #145244;
    --color-primary-light: #e6f2ef;
    --color-accent: #e8a23d;

    /* Neutrals */
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;

    /* Status */
    --color-success: #1d8a4e;
    --color-warning: #b7791f;
    --color-danger: #c0392b;

    /* Layout */
    --container-width: 1200px;
    --radius: 8px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

    /* Type */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-bg);
    font-size: 16px;
    line-height: 1.5;
}

img { max-width: 100%; display: block; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 700; line-height: 1.25; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }

/* ============================================================
   Layout
   ============================================================ */

.container {
    width: 100%;
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.page-section { padding: 2.5rem 0; }

.grid {
    display: grid;
    gap: 1.5rem;
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; } .mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; } .mb-4 { margin-bottom: 2rem; }

.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }

/* ============================================================
   Top Navigation
   ============================================================ */

.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.navbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.navbar-brand {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}
.navbar-links {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.navbar-links a {
    color: var(--color-text);
    font-weight: 500;
    font-size: 0.95rem;
}
.navbar-links a:hover { color: var(--color-primary); text-decoration: none; }
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 800px) {
    .navbar-toggle { display: block; }
    .navbar-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--color-surface);
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid var(--color-border);
        gap: 1rem;
    }
    .navbar-links.is-open { display: flex; }
}

/* ============================================================
   Sidebar (Portal / Admin)
   ============================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 240px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1.5rem 1rem;
    flex-shrink: 0;
}
.sidebar-brand {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 1.5rem;
    display: block;
}
.sidebar-section {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 1.25rem 0 0.5rem;
    padding: 0 0.75rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.92rem;
    font-weight: 500;
}
.sidebar-link:hover { background: var(--color-primary-light); text-decoration: none; }
.sidebar-link.is-active { background: var(--color-primary-light); color: var(--color-primary-dark); }
.sidebar-link .badge { margin-left: auto; }

.main-content { flex: 1; min-width: 0; }
.main-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.5rem;
}
.main-body { padding: 1.5rem; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
}

/* ============================================================
   Cards
   ============================================================ */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.card-header h2, .card-header h3 { margin: 0; }

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--color-primary-dark); }
.stat-card .stat-label { color: var(--color-text-muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ============================================================
   Listing Card
   ============================================================ */

.listing-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.listing-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.listing-card-image {
    aspect-ratio: 4 / 3;
    background: var(--color-border);
    position: relative;
    overflow: hidden;
}
.listing-card-image img { width: 100%; height: 100%; object-fit: cover; }
.listing-card-badge {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
}
.listing-card-body { padding: 1rem; flex: 1; display: flex; flex-direction: column; }
.listing-card-price { font-size: 1.2rem; font-weight: 800; color: var(--color-primary-dark); margin-bottom: 0.25rem; }
.listing-card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; }
.listing-card-location { color: var(--color-text-muted); font-size: 0.85rem; margin-bottom: 0.6rem; }
.listing-card-meta {
    display: flex;
    gap: 0.9rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-top: auto;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-border);
}

/* ============================================================
   Forms
   ============================================================ */

.field { margin-bottom: 1.1rem; }
.field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}
.field .hint { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.25rem; }
.field .error { font-size: 0.8rem; color: var(--color-danger); margin-top: 0.25rem; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="search"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    font-size: 0.95rem;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; min-height: 100px; }

.field-row { display: flex; gap: 1rem; }
.field-row > .field { flex: 1; }

.checkbox-field { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-field input { width: auto; }
.checkbox-field label { margin: 0; font-weight: 500; }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: var(--color-bg); text-decoration: none; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #a93226; text-decoration: none; }
.btn-outline { background: transparent; color: var(--color-primary); border-color: var(--color-primary); }
.btn-outline:hover { background: var(--color-primary-light); text-decoration: none; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--color-border); }
th { font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.04em; }
tbody tr:hover { background: var(--color-bg); }

/* ============================================================
   Badges / Status Pills
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 999px;
}
.badge-gray    { background: #f1f2f4; color: #4b5563; }
.badge-green   { background: #e6f4ea; color: var(--color-success); }
.badge-amber   { background: #fdf3e0; color: var(--color-warning); }
.badge-red     { background: #fbe9e7; color: var(--color-danger); }
.badge-blue    { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* ============================================================
   Alerts / Flash Messages
   ============================================================ */

.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-success { background: #e6f4ea; border-color: #b9e2c5; color: #14532d; }
.alert-error   { background: #fbe9e7; border-color: #f3c4be; color: #7f1d1d; }
.alert-info    { background: var(--color-primary-light); border-color: #bfe0d8; color: var(--color-primary-dark); }
.alert ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--color-text);
}
.pagination a:hover { background: var(--color-primary-light); text-decoration: none; }
.pagination .active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination .disabled { color: var(--color-text-muted); }

/* ============================================================
   Hero (Public Home)
   ============================================================ */

.hero {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 4rem 0;
}
.hero h1 { font-size: 2.5rem; margin-bottom: 0.5rem; }
.hero p { font-size: 1.1rem; opacity: 0.9; }
.search-bar {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-lg);
    margin-top: 1.5rem;
}
.search-bar .field { margin-bottom: 0; }

/* ============================================================
   Empty States
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-text-muted);
}
.empty-state h3 { color: var(--color-text); }

/* ============================================================
   Photo Upload / Gallery
   ============================================================ */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}
.media-item {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--color-border);
    aspect-ratio: 4/3;
    cursor: grab;
}
.media-item img { width: 100%; height: 100%; object-fit: cover; }
.media-item .media-actions {
    position: absolute;
    top: 0.35rem;
    right: 0.35rem;
    display: flex;
    gap: 0.25rem;
}
.media-item .media-actions button {
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    font-size: 0.7rem;
    cursor: pointer;
}
.media-item.is-cover::after {
    content: "Cover";
    position: absolute;
    bottom: 0.35rem;
    left: 0.35rem;
    background: var(--color-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}
.media-item.dragging { opacity: 0.4; }

.upload-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.upload-dropzone:hover, .upload-dropzone.is-dragover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
}
.upload-dropzone input[type="file"] { display: none; }

/* ============================================================
   Tabs
   ============================================================ */

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.tab {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab.is-active { color: var(--color-primary-dark); border-color: var(--color-primary); }

/* ============================================================
   Map
   ============================================================ */

#search-map, #listing-map {
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 320px;
}

/* ============================================================
   Footer
   ============================================================ */

.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 2.5rem 0;
    margin-top: 3rem;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}
.site-footer a { color: var(--color-text-muted); }
.site-footer .footer-cols {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
}
@media (max-width: 700px) {
    .site-footer .footer-cols { grid-template-columns: 1fr; gap: 1.25rem; }
}

/* ============================================================
   Responsive: Form Rows
   ============================================================ */

@media (max-width: 600px) {
    .field-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ============================================================
   Responsive: Two-Column Page Layouts (search, listing detail)
   ============================================================ */

.search-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.5rem;
}

.listing-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .search-layout,
    .listing-layout {
        grid-template-columns: 1fr;
    }

    .search-layout > div:last-child {
        order: -1;
    }

    #search-map {
        min-height: 280px;
    }
}

@media (max-width: 768px) {
    .listing-layout .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .listing-layout .flex-between .text-right {
        text-align: left;
    }

    .listing-layout .card[data-sticky] {
        position: static;
    }
}

/* ============================================================
   Responsive: Gallery Grid
   ============================================================ */

@media (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(5, 160px);
        height: auto;
    }

    .gallery-grid > div:first-child {
        grid-row: auto;
    }
}

/* ============================================================
   Responsive: Property Detail Mini-Cards (show page)
   ============================================================ */

.property-meta-item {
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius);
    min-width: 80px;
}

@media (max-width: 600px) {
    .property-meta-item {
        flex: 1 1 calc(50% - 0.75rem);
    }
}


/* ============================================================
   Responsive: Prevent horizontal overflow / edge-bleed
   ============================================================ */

html, body {
    overflow-x: hidden;
    width: 100%;
}

.container {
    box-sizing: border-box;
}

@media (max-width: 420px) {
    .container {
        padding: 0 1rem;
    }
}
.listing-layout,
.search-layout,
table {
    max-width: 100%;
}


/* ============================================================
   Listing Gallery — unified hero + thumbnail strip
   ============================================================ */

.gallery {
    display: grid;
    grid-template-columns: 1fr 110px;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.gallery-main {
    aspect-ratio: 16 / 10;
    max-height: 420px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--color-border);
}

.gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.gallery-thumbs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 420px;
    overflow-y: auto;
}

.gallery-thumb {
    flex: 0 0 auto;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

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

.gallery-thumb.is-active {
    opacity: 1;
    border-color: var(--color-primary);
}

.gallery--single .gallery-thumbs {
    display: none;
}

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

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: 1fr;
    }

    .gallery-main {
        aspect-ratio: 16 / 10;
        max-height: 240px;
    }

    .gallery-thumbs {
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: visible;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.25rem;
    }

    .gallery-thumb {
        width: 64px;
        aspect-ratio: 1;
        scroll-snap-align: start;
    }
}

@media (max-width: 400px) {
    .gallery-main {
        max-height: 200px;
    }
}