/* ==========================================================================
   Aqarikw — App shell styles (mobile-first)
   ========================================================================== */

:root {
    --color-primary: #8f6b1a;
    --color-primary-dark: #6b4f11;
    --color-primary-light: #f6ecd2;
    --color-accent: #020973;
    --color-bg: #f6f7f9;
    --color-surface: #ffffff;
    --color-text: #14181b;
    --color-text-muted: #6b7280;
    --color-border: #e8eaed;
    --color-danger: #dc2626;
    --color-success: #16a34a;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --shadow-soft: 0 4px 16px rgba(15, 23, 42, 0.08);
    --shadow-card: 0 2px 10px rgba(15, 23, 42, 0.06);
    --topbar-h: 56px;
    --bottomnav-h: 64px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; }

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

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom));
}

[dir="rtl"] body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { min-height: 44px; }

.app-container {
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    background: var(--color-bg);
    min-height: 100vh;
    min-height: 100dvh;
}

@media (min-width: 768px) {
    .app-container {
        max-width: 480px;
        box-shadow: var(--shadow-soft);
        border-inline: 1px solid var(--color-border);
    }
    body { background: #e5e7eb; }
}

/* ---------------- Top App Bar ---------------- */
.top-appbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 8px;
    padding-inline: 8px;
}

.top-appbar .btn-icon {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--color-text);
    flex-shrink: 0;
}

.top-appbar .btn-icon:active { background: var(--color-bg); }

.top-appbar .appbar-title {
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

body:not(.has-topbar) .top-appbar { display: none; }

/* ---------------- Bottom Navigation ---------------- */
.bottom-nav {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 1040;
    height: calc(var(--bottomnav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    max-width: 480px;
    margin: 0 auto;
}

.bottom-nav a, .bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--color-text-muted);
    font-size: 0.7rem;
    background: none;
    border: none;
    min-height: 44px;
}

.bottom-nav i { font-size: 1.35rem; }

.bottom-nav .active { color: var(--color-primary); }

body.page-property .bottom-nav,
body.hide-bottom-nav .bottom-nav {
    display: none;
}

body.page-property { padding-bottom: 0; }
body:not(.page-property):not(.hide-bottom-nav) { padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom)); }
body.has-stickybar { padding-bottom: calc(76px + var(--safe-bottom)); }

/* ---------------- Sticky bottom action bar (property detail) ---------------- */
.sticky-actionbar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 1040;
    max-width: 480px;
    margin: 0 auto;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 10px 16px calc(10px + var(--safe-bottom));
    display: flex;
    gap: 10px;
}

.sticky-actionbar .btn {
    flex: 1;
    min-height: 48px;
    border-radius: var(--radius-md);
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* ---------------- Home page ---------------- */
.home-hero {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 24px calc(24px + var(--safe-bottom));
    text-align: center;
    gap: 28px;
}

.home-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.home-brand .logo-badge {
    width: 112px;
    height: 112px;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 3rem;
    box-shadow: var(--shadow-soft);
}

.home-brand .logo-badge.logo-badge-img {
    background: var(--color-surface);
    padding: 12px;
}

.home-brand .logo-badge-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.home-brand h1 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.home-brand p { color: var(--color-text-muted); margin: 0; font-size: 0.9rem; }

.home-search-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }

.search-input-wrap { position: relative; width: 100%; }

.search-input-wrap input {
    width: 100%;
    height: 56px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    padding-inline: 20px;
    font-size: 1rem;
    outline: none;
}

.search-input-wrap input:focus { border-color: var(--color-primary); }

.location-select-row {
    display: flex;
    gap: 10px;
}

.location-select-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
}

.location-select-wrap i {
    position: absolute;
    inset-inline-start: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    font-size: 1rem;
    pointer-events: none;
}

.location-select-wrap select {
    width: 100%;
    height: 48px;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    padding-inline: 40px 14px;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--color-text);
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    text-overflow: ellipsis;
}

[dir="rtl"] .location-select-wrap select {
    background-position: left 14px center;
}

.location-select-wrap select:focus { border-color: var(--color-primary); }

.location-select-wrap::after {
    content: "";
    position: absolute;
    inset-inline-end: 16px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-inline-end: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.type-toggle {
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 4px;
    box-shadow: var(--shadow-card);
}

.type-toggle input { display: none; }

.type-toggle label {
    flex: 1;
    text-align: center;
    padding: 10px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    cursor: pointer;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.type-toggle input:checked + label {
    background: var(--color-primary);
    color: #fff;
}

.home-search-submit {
    height: 50px;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: 1rem;
}

.lang-switch-corner {
    position: fixed;
    top: calc(14px + var(--safe-top));
    inset-inline-end: 14px;
    z-index: 1050;
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    font-size: 0.78rem;
    font-weight: 700;
}

.lang-switch-corner a {
    padding: 7px 12px;
    color: var(--color-text-muted);
}

.lang-switch-corner a.active { background: var(--color-primary); color: #fff; }

/* ---------------- Filter chips ---------------- */
.filter-bar {
    position: sticky;
    top: calc(var(--topbar-h) + var(--safe-top));
    z-index: 1020;
    background: var(--color-bg);
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
    border-bottom: 1px solid var(--color-border);
}

.filter-bar::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

/* ---------------- Property cards ---------------- */
.property-list { padding: 12px; display: flex; flex-direction: column; gap: 14px; }

.property-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
    display: block;
}

.property-card .thumb-wrap {
    position: relative;
    aspect-ratio: 16 / 10;
    background: var(--color-bg);
    overflow: hidden;
}

.property-card .thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }

.badge-type {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-primary);
}

.badge-type.type-sale { background: var(--color-accent); }

.fav-btn {
    position: absolute;
    bottom: 10px;
    inset-inline-end: 10px;
    background: none;
    border: none;
    padding: 0;
    font-size: 1.3rem;
    line-height: 1;
    color: #fff;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
}
.fav-btn .bi-heart-fill { color: #e63950; }

.badge-featured {
    position: absolute;
    top: 10px;
    inset-inline-end: 10px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: #fff;
    color: var(--color-accent);
    display: flex;
    align-items: center;
    gap: 4px;
}

.property-card .card-body { padding: 14px 16px 16px; }

.property-card .price { font-size: 1.15rem; font-weight: 800; color: var(--color-primary); margin: 0 0 4px; }
.property-card .title { font-weight: 700; font-size: 0.95rem; margin: 0 0 6px; color: var(--color-text); }

.property-card .location {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin-bottom: 4px;
}

.property-card .card-views {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    margin-bottom: 10px;
}
.property-card .card-views .bi-eye-fill { color: var(--color-primary); }

.property-meta { display: flex; gap: 14px; flex-wrap: wrap; }

.property-meta span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    font-weight: 600;
}

/* ---------------- Skeleton loaders ---------------- */
.skeleton {
    background: linear-gradient(90deg, #eceff1 25%, #f6f7f9 37%, #eceff1 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

.skeleton-card { height: 260px; border-radius: var(--radius-lg); margin: 0 12px 14px; }

/* ---------------- Property detail ---------------- */
.gallery { position: relative; }
.gallery .carousel-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; }

.detail-section { padding: 16px; }
.detail-price { font-size: 1.6rem; font-weight: 800; color: var(--color-primary); }
.detail-title { font-size: 1.15rem; font-weight: 700; margin: 4px 0 8px; }
.detail-location { color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }
.detail-location-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.detail-views { color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; font-size: 0.85rem; white-space: nowrap; }
.detail-views .bi-eye-fill { color: var(--color-primary); }

.amenities-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 18px;
}

.amenity-box {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 8px;
    text-align: center;
}

.amenity-box i { font-size: 1.3rem; color: var(--color-primary); }
.amenity-box .val { font-weight: 700; font-size: 1rem; margin-top: 4px; }
.amenity-box .lbl { font-size: 0.72rem; color: var(--color-text-muted); }

.detail-description { line-height: 1.7; color: var(--color-text); font-size: 0.92rem; }

/* ---------------- Install banner ---------------- */
.install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 10px);
    max-width: 456px;
    margin: 0 auto;
    background: var(--color-text);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: none;
    align-items: center;
    gap: 10px;
    z-index: 1060;
    box-shadow: var(--shadow-soft);
}

.install-banner.show { display: flex; }
.install-banner .txt { flex: 1; font-size: 0.82rem; }
.install-banner .txt strong { display: block; font-size: 0.86rem; }
.install-banner button { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: none; font-weight: 700; font-size: 0.78rem; }
.install-banner .btn-install { background: var(--color-primary); color: #fff; }
.install-banner .btn-dismiss { background: transparent; color: #d1d5db; }

/* ---------------- Generic ---------------- */
.section-title { font-weight: 800; font-size: 1.05rem; padding: 16px 16px 6px; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 10px; display: block; }

.load-more-btn {
    display: block;
    width: calc(100% - 24px);
    margin: 6px 12px 20px;
    height: 48px;
    border-radius: var(--radius-md);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    font-weight: 700;
    color: var(--color-primary);
}

.results-count { padding: 10px 16px 0; color: var(--color-text-muted); font-size: 0.85rem; }

/* ---------------- Public forms (Post Ad, etc.) ---------------- */
.public-form { padding: 16px; }

.public-form .form-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 6px;
}

.public-form .form-control,
.public-form .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--color-border);
    padding: 11px 14px;
    font-size: 0.95rem;
    min-height: 44px;
}

.public-form textarea.form-control { min-height: 100px; }

.public-form .form-control:focus,
.public-form .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.public-form .form-text { font-size: 0.78rem; }

.public-form .field-group {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 14px;
}

.public-form .field-group h2 {
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--color-text-muted);
    margin: 0 0 12px;
}

.public-form .submit-btn {
    width: 100%;
    min-height: 52px;
    border-radius: 999px;
    background: var(--color-primary);
    color: #fff;
    border: none;
    font-weight: 700;
    font-size: 1rem;
}

.form-errors {
    background: #fef2f2;
    border-inline-start: 4px solid var(--color-danger);
    color: #7f1d1d;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin: 0 16px 14px;
    font-size: 0.85rem;
}

.form-errors ul { margin: 4px 0 0; padding-inline-start: 18px; }

.thank-you-wrap {
    min-height: calc(100vh - var(--topbar-h) - var(--safe-top));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 24px;
    gap: 12px;
}

.thank-you-wrap .icon-badge {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #dcfce7;
    color: #15803d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 8px;
}

/* ---------------- Contact page ---------------- */
.contact-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 28px 24px 20px;
}

.contact-hero h1 { font-size: 1.2rem; font-weight: 800; margin: 6px 0 0; }
.contact-hero p { color: var(--color-text-muted); margin: 0; font-size: 0.88rem; }

.contact-info-list {
    padding: 0 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 8px;
}

.contact-info-item {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-card);
    min-height: 44px;
}

.contact-info-item .icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.contact-info-item .icon.icon-whatsapp { background: #dcfce7; color: #16a34a; }

.contact-info-item .text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.contact-info-item .lbl { font-size: 0.72rem; color: var(--color-text-muted); font-weight: 600; }
.contact-info-item .val { font-size: 0.92rem; font-weight: 700; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-info-item .chevron { color: var(--color-text-muted); font-size: 0.9rem; flex-shrink: 0; }
.contact-info-item.contact-info-static { box-shadow: none; }

.contact-section { padding: 8px 16px 20px; }

.social-row { display: flex; gap: 12px; flex-wrap: wrap; }

.social-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    color: #fff;
    box-shadow: var(--shadow-card);
}

.social-facebook { background: #1877f2; }
.social-instagram { background: radial-gradient(circle at 30% 110%, #fdf497 0%, #fdf497 5%, #fd5949 45%, #d6249f 60%, #285AEB 90%); }
.social-twitter { background: #000; }
.social-snapchat { background: #FFFC00; color: #000; }

.contact-map-wrap {
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-card);
    aspect-ratio: 16/11;
}

.contact-map-wrap iframe { width: 100%; height: 100%; border: 0; }

/* Admin tweaks reuse Bootstrap; small additions */
.admin-shell { padding-bottom: 24px; }
.admin-shell .table { background: var(--color-surface); }
.thumb-sm { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; }

@media (max-width: 360px) {
    .amenities-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .home-brand h1 { font-size: 1.2rem; }
}
