:root {
    --brand: #ff6b00;
    --brand-dark: #e55f00;
    --brand-light: #fff4eb;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f5f6f8;
    --white: #ffffff;
    --success: #059669;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

body[dir="rtl"] { font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", Arial, sans-serif; }

a { color: inherit; text-decoration: none; }

.container { width: min(1200px, 92%); margin: 0 auto; }

.site-header {
    background: var(--brand);
    color: var(--white);
    padding: 14px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.header-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.logo span { opacity: 0.9; font-weight: 600; font-size: 0.85rem; display: block; }

.search-bar {
    flex: 1;
    min-width: 220px;
    display: flex;
    background: var(--white);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.05);
}

.search-bar input {
    flex: 1;
    border: 0;
    padding: 12px 18px;
    font-size: 0.95rem;
    outline: none;
}

.search-bar button {
    border: 0;
    background: var(--text);
    color: var(--white);
    padding: 0 22px;
    font-weight: 600;
    cursor: pointer;
}

.header-actions { display: flex; gap: 10px; align-items: center; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 0;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s ease;
    font-size: 0.92rem;
}

.btn-white { background: var(--white); color: var(--brand); }
.btn-white:hover { background: var(--brand-light); }
.btn-dark { background: var(--text); color: var(--white); }
.btn-outline { background: transparent; color: var(--white); border: 1px solid rgba(255,255,255,0.45); }
.btn-brand { background: var(--brand); color: var(--white); }
.btn-brand:hover { background: var(--brand-dark); }

.hero {
    background: linear-gradient(135deg, #ff6b00 0%, #ff9248 100%);
    color: var(--white);
    padding: 36px 0 48px;
}

.hero h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4vw, 2.4rem); }
.hero p { margin: 0; opacity: 0.95; max-width: 620px; }

.section { padding: 28px 0; }
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 12px;
}

.section-title h2 { margin: 0; font-size: 1.25rem; }
.section-title a { color: var(--brand); font-weight: 600; font-size: 0.92rem; }

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}

.category-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 18px 14px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.category-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12); }
.category-icon { font-size: 2rem; margin-bottom: 8px; display: block; }
.category-card strong { display: block; font-size: 0.92rem; }

.listings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.listings-grid > * {
    min-width: 0;
}

.listing-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    height: 100%;
}

.listing-image {
    position: relative;
    width: 100%;
    height: 180px;
    max-height: 180px;
    flex: 0 0 180px;
    background: #111827;
    overflow: hidden;
}

.listing-image .listing-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.listing-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    background: linear-gradient(135deg, #dbeafe, #fef3c7);
}

.listing-badge {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    z-index: 2;
    background: rgba(0,0,0,0.65);
    color: white;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 999px;
}

.listing-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; overflow: hidden; }
.listing-price { color: var(--brand); font-weight: 800; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.listing-title {
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.listing-spec {
    color: var(--muted);
    font-size: 0.84rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.listing-meta {
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: auto;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.filters {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.filters label { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 6px; }
.filters input, .filters select, .form-control {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
}

.detail-gallery {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.gallery-main {
    position: relative;
    width: 100%;
    height: 420px;
    max-height: 420px;
    flex: 0 0 420px;
    overflow: hidden;
    background: #111827;
}

.gallery-main img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.gallery-thumbs {
    display: flex;
    gap: 8px;
    padding: 10px;
    overflow-x: auto;
    background: #f8fafc;
    flex-shrink: 0;
}

.gallery-thumb {
    position: relative;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    padding: 0;
    width: 84px;
    height: 64px;
    flex: 0 0 84px;
    cursor: pointer;
    background: #e5e7eb;
}

.gallery-thumb.active { border-color: var(--brand); }

.gallery-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-fallback {
    min-height: 360px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 5rem;
}

.detail-panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    height: fit-content;
}

.detail-price { font-size: 2rem; font-weight: 800; color: var(--brand); margin: 0 0 8px; }
.detail-title { margin: 0 0 12px; font-size: 1.5rem; }
.detail-meta { color: var(--muted); font-size: 0.92rem; margin-bottom: 18px; }
.detail-address { margin: 0 0 14px; }
.detail-description { white-space: pre-wrap; line-height: 1.7; }

.specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin: 0 0 16px;
    padding: 14px;
    background: var(--bg);
    border-radius: 10px;
}

.spec-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.84rem;
}

.spec-item span { color: var(--muted); }
.spec-item strong { font-size: 0.95rem; }

.detail-sections {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.detail-sections .form-card {
    max-width: none;
    margin: 0;
}

.map-frame {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.map-frame iframe {
    width: 100%;
    height: 360px;
    border: 0;
    display: block;
}

.form-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    max-width: 720px;
    margin: 0 auto;
}

.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.92rem;
}

.alert-success { background: #ecfdf5; color: #065f46; }
.alert-error { background: #fef2f2; color: #991b1b; }

.auth-page {
    min-height: calc(100vh - 180px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
}

.site-footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 24px 0;
    margin-top: 40px;
    color: var(--muted);
    font-size: 0.88rem;
}

.footer-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lang-switch { display: flex; gap: 8px; }
.lang-switch a { padding: 6px 10px; border-radius: 8px; background: var(--bg); font-weight: 600; }
.lang-switch a.active { background: var(--brand-light); color: var(--brand); }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.pagination { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.pagination a, .pagination span {
    padding: 8px 14px;
    border-radius: 8px;
    background: var(--white);
    box-shadow: var(--shadow);
}
.pagination .active { background: var(--brand); color: white; }

@media (max-width: 768px) {
    .detail-layout { grid-template-columns: 1fr; }
    .header-row { justify-content: center; }
    .search-bar { order: 3; width: 100%; }
}
