@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700&display=swap');

:root {
  --primary:   #0A2342;
  --gold:      #C9A84C;
  --success:   #2E7D32;
  --danger:    #C62828;
  --warning:   #F57C00;
  --bg:        #F0F4F8;
  --surface:   #FFFFFF;
  --border:    #D0D9E4;
  --text:      #1A2B3C;
  --text-muted:#6B7A8D;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 2px 12px rgba(10,35,66,0.08);
  --shadow-lg: 0 8px 32px rgba(10,35,66,0.14);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Tajawal', sans-serif; direction: rtl; background: var(--bg); color: var(--text); font-size: 14px; }

/* ===== Layout ===== */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); background: var(--primary); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto; overflow-x: hidden;
}
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 56px; display: flex; align-items: center;
  justify-content: space-between; flex-shrink: 0;
}
.page-body { flex: 1; overflow-y: auto; padding: 24px; }

/* ===== Sidebar ===== */
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo .logo-title { font-size: 1rem; font-weight: 700; color: var(--gold); }
.sidebar-logo .logo-sub   { font-size: 0.72rem; color: rgba(255,255,255,0.5); margin-top: 2px; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section { padding: 8px 16px 4px; font-size: 0.68rem; color: rgba(255,255,255,0.35); text-transform: uppercase; letter-spacing: 0.05em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,0.75);
  text-decoration: none; font-size: 0.88rem; cursor: pointer;
  transition: all 0.15s; border-right: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(201,168,76,0.15); color: var(--gold); border-right-color: var(--gold); }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; color: var(--primary); flex-shrink: 0; }
.user-info .user-name { font-size: 0.83rem; font-weight: 600; color: #fff; }
.user-info .user-role { font-size: 0.72rem; color: rgba(255,255,255,0.45); }

/* ===== Topbar ===== */
.page-title { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ===== Cards ===== */
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 0.95rem; font-weight: 700; color: var(--primary); }
.card-body { padding: 20px; }

/* ===== KPI Grid ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px; display: flex; align-items: center; gap: 16px;
}
.kpi-icon { width: 48px; height: 48px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.kpi-icon.blue   { background: rgba(10,35,66,0.08); }
.kpi-icon.gold   { background: rgba(201,168,76,0.12); }
.kpi-icon.green  { background: rgba(46,125,50,0.1); }
.kpi-icon.orange { background: rgba(245,124,0,0.1); }
.kpi-icon.red    { background: rgba(198,40,40,0.1); }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); line-height: 1; }
.kpi-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Property Cards ===== */
.properties-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.prop-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; cursor: pointer;
}
.prop-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.prop-img { height: 180px; background: linear-gradient(135deg, #e8edf3, #d0d9e4); display: flex; align-items: center; justify-content: center; font-size: 3rem; position: relative; }
.prop-img img { width: 100%; height: 100%; object-fit: cover; }
.prop-badge { position: absolute; top: 10px; right: 10px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.prop-badge.sale  { background: var(--primary); color: #fff; }
.prop-badge.rent  { background: var(--gold); color: var(--primary); }
.prop-badge.sold  { background: #ccc; color: #555; }
.prop-status { position: absolute; top: 10px; left: 10px; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.prop-status.available { background: rgba(46,125,50,0.9); color: #fff; }
.prop-status.reserved  { background: rgba(245,124,0,0.9); color: #fff; }
.prop-status.sold      { background: rgba(100,100,100,0.9); color: #fff; }
.prop-body { padding: 16px; }
.prop-ref  { font-size: 0.72rem; color: var(--text-muted); font-family: monospace; margin-bottom: 6px; }
.prop-title { font-size: 0.95rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; line-height: 1.4; }
.prop-price { font-size: 1.15rem; font-weight: 700; color: var(--gold); margin-bottom: 10px; }
.prop-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
.prop-meta span { display: flex; align-items: center; gap: 4px; }
.prop-location { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }
.prop-actions { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer; font-family: inherit; font-size: 0.85rem; font-weight: 600; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #0d2d54; }
.btn-gold    { background: var(--gold); color: var(--primary); }
.btn-gold:hover { background: #b8963d; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: var(--bg); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control, .form-select {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-family: inherit; font-size: 0.88rem;
  background: var(--surface); color: var(--text); outline: none; transition: border-color 0.15s;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.required { color: var(--danger); }

/* ===== Filters Bar ===== */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.filters-bar .form-control, .filters-bar .form-select { width: auto; min-width: 140px; }
.filters-bar input[type="search"] { min-width: 200px; }

/* ===== Modal ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 90%; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-title { font-size: 1rem; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.1rem; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; flex-shrink: 0; }

/* ===== Badges ===== */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; }
.badge-primary { background: rgba(10,35,66,0.1); color: var(--primary); }
.badge-gold    { background: rgba(201,168,76,0.15); color: #8a6a1a; }
.badge-success { background: rgba(46,125,50,0.1); color: var(--success); }
.badge-danger  { background: rgba(198,40,40,0.1); color: var(--danger); }
.badge-warning { background: rgba(245,124,0,0.1); color: var(--warning); }
.badge-muted   { background: var(--bg); color: var(--text-muted); }

/* ===== Table ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead th { background: var(--bg); color: var(--primary); font-weight: 700; padding: 10px 14px; text-align: right; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: rgba(10,35,66,0.02); }
tbody tr:last-child td { border-bottom: none; }

/* ===== Toast ===== */
#toast-container { position: fixed; bottom: 24px; left: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); color: #fff; font-size: 0.85rem; font-weight: 600; box-shadow: var(--shadow-lg); animation: slideIn 0.25s ease; min-width: 220px; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info    { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(-30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Empty State ===== */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state .title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text); }

/* ===== Login ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, #1a3a6b 100%); }
.login-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 40px; width: 380px; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .title { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.login-logo .sub   { font-size: 0.82rem; color: var(--text-muted); margin-top: 4px; }
.login-logo .icon  { font-size: 2.5rem; margin-bottom: 8px; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .properties-grid { grid-template-columns: 1fr; }
}
