/* تصميم مشترك */
:root {
  --primary: #1d4ed8;
  --primary-dark: #1e3a8a;
  --primary-soft: #dbeafe;
  --gold: #b45309;
  --gold-soft: #fef3c7;
  --pin: #6d28d9;
  --pin-soft: #ede9fe;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
  --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: inherit; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; }
p { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* أزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 10px; padding: 10px 16px; font-weight: 700; cursor: pointer; background: #fff; border-color: var(--line); transition: .15s; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-gold { background: var(--gold-soft); border-color: #fcd34d; color: var(--gold); }
.btn-pin { background: var(--pin-soft); border-color: #c4b5fd; color: var(--pin); }
.btn-ok { background: var(--ok-soft); border-color: #86efac; color: var(--ok); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 18px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: rgba(0, 0, 0, .06); }

/* نماذج */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > span { font-size: 14px; font-weight: 700; }
.field small { color: var(--muted); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { min-height: 100px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; cursor: pointer; border-bottom: 1px dashed var(--line); }
.check:last-child { border-bottom: 0; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); margin-top: 3px; flex: none; }
.check b { display: block; font-size: 14px; }
.check small { color: var(--muted); font-size: 12.5px; }

/* شارات */
.badge { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #334155; white-space: nowrap; }
.badge-gold { background: var(--gold-soft); color: var(--gold); }
.badge-pin { background: var(--pin-soft); color: var(--pin); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.status { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.st-pending { background: #fef9c3; color: #a16207; }
.st-active { background: var(--ok-soft); color: var(--ok); }
.st-rejected { background: var(--danger-soft); color: var(--danger); }
.st-hidden { background: #e2e8f0; color: #475569; }
.st-closed { background: #dbeafe; color: #1d4ed8; }

/* صورة بديلة */
.ph { display: grid; place-items: center; background: linear-gradient(135deg, #99f6e4, #0f766e); }
.ph span { font-size: 44px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .2)); }
.ph-land { background: linear-gradient(135deg, #fde68a, #a16207); }
.ph-commercial { background: linear-gradient(135deg, #bfdbfe, #1d4ed8); }
.ph-office { background: linear-gradient(135deg, #ddd6fe, #6d28d9); }

/* نوافذ */
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: grid; place-items: center; padding: 16px; z-index: 100; animation: fade .2s; }
.modal-wrap.out { opacity: 0; transition: .2s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .btn { flex: 1; }
.modal-wrap.sheet { place-items: end center; padding: 0; }
.modal-wrap.sheet .modal { border-radius: 18px 18px 0 0; max-width: 520px; animation: up .25s; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* تنبيهات */
#toasts { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; box-shadow: var(--shadow); animation: up .25s; text-align: center; }
.toast-success { background: var(--ok); }
.toast-error { background: var(--danger); }
.toast.out { opacity: 0; transition: .3s; }

.loading { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 16px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255, 255, 255, .4); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }
.offline { text-align: center; padding: 60px 20px; }
.offline .big { font-size: 48px; display: block; }

.dev-credit { text-align: center; font-size: 11.5px; color: var(--muted); line-height: 1.7; margin: 22px 0 8px; font-family: 'Segoe UI', Tahoma, sans-serif; }
.dev-credit b { color: var(--text); font-weight: 700; }
.dev-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 48px; display: block; margin-bottom: 8px; }
.muted { color: var(--muted); }
.hr { height: 1px; background: var(--line); margin: 14px 0; }

/* نموذج بيانات العقار (العميل + الإدارة) */
.form-card { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.form-card h3 { font-size: 16px; margin-bottom: 12px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { border: 2px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; font-weight: 800; cursor: pointer; }
.seg input { display: none; }
.seg label:has(input:checked) { border-color: var(--primary); background: #f0fdfa; color: var(--primary); }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-grid label { border: 2px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; cursor: pointer; font-size: 12.5px; font-weight: 700; }
.type-grid label span { display: block; font-size: 24px; }
.type-grid input { display: none; }
.type-grid label:has(input:checked) { border-color: var(--primary); background: #f0fdfa; }
.img-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.img-grid .im { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); }
.img-grid .im img { width: 100%; height: 100%; object-fit: cover; }
.img-grid .im button { position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .65); color: #fff; cursor: pointer; font-size: 12px; }
.img-grid .im .main { position: absolute; bottom: 0; right: 0; left: 0; background: rgba(15, 118, 110, .9); color: #fff; font-size: 11px; text-align: center; }
.img-add { aspect-ratio: 1; border: 2px dashed #94a3b8; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--muted); font-size: 12px; text-align: center; }
.img-add span { font-size: 26px; display: block; }

.warn { background: var(--danger-soft); color: #991b1b; border-radius: 12px; padding: 10px 12px; font-weight: 700; font-size: 14px; margin-top: 12px; }
.info-box { background: #f0fdfa; color: #115e59; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-top: 12px; }
