/* PropCRM Egypt — Main Stylesheet */
/* RTL-first design with dark mode support */

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

:root {
  --primary:       #1f2f84;
  --primary-dark:  #16245f;
  --primary-light: #e9edfa;
  --success:       #057a55;
  --success-light: #def7ec;
  --warning:       #c19a57;
  --warning-light: #f6ebd8;
  --danger:        #c81e1e;
  --danger-light:  #fde8e8;
  --info:          #0694a2;
  --info-light:    #d5f5f6;
  --purple:        #7e3af2;
  --purple-light:  #edebfe;
  --orange:        #d03801;
  --orange-light:  #fde8d8;

  --bg:            #f3f4f6;
  --surface:       #ffffff;
  --surface2:      #f9fafb;
  --border:        #e5e7eb;
  --text:          #111827;
  --text-secondary:#6b7280;
  --text-muted:    #9ca3af;

  --sidebar-bg:    #1a286f;
  --sidebar-text:  #cbd5e1;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active:rgba(193,154,87,0.16);
  --sidebar-w:     260px;
  --header-h:      60px;

  --radius:        0.5rem;
  --radius-lg:     0.75rem;
  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  --transition:    .18s ease;
}

/* Dark mode */
[data-theme="dark"] {
  --bg:            #0f172a;
  --surface:       #1e293b;
  --surface2:      #273044;
  --border:        #334155;
  --text:          #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --sidebar-bg:    #0f172a;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  direction: rtl;
  font-size: 14px;
}

body {
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

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

/* ==============================
   APP LAYOUT
============================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ==============================
   SIDEBAR
============================== */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.sidebar-logo {
  padding: 1.35rem 1rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-align: center;
}

.sidebar-logo::before {
  content: '';
  display: block;
  width: 100%;
  max-width: 190px;
  aspect-ratio: 10 / 3;
  margin: 0 auto;
  background: url('../img/property-stone-logo.svg') center / contain no-repeat;
}

.sidebar-logo::after {
  content: 'Real Estate CRM';
  display: block;
  margin-top: .55rem;
  color: rgba(255,255,255,.7);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.sidebar-logo .logo-icon,
.sidebar-logo .logo-text {
  display: none;
}

.sidebar-nav { padding: .5rem 0; flex: 1; }

.nav-section-label {
  padding: .6rem 1rem .3rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem 1rem;
  color: var(--sidebar-text);
  border-radius: var(--radius);
  margin: 2px .5rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  font-size: .88rem;
  font-weight: 500;
  line-height: 1;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: var(--sidebar-active);
  color: #fff;
  border: 1px solid rgba(193,154,87,.28);
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}

.nav-item .nav-badge {
  margin-right: auto;
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}

/* ==============================
   MAIN CONTENT
============================== */
.main-content {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex: 1;
  transition: margin var(--transition);
}

/* ==============================
   HEADER
============================== */
.header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header .sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text);
  padding: .3rem;
}

.header .global-search {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.header .global-search input {
  width: 100%;
  padding: .45rem .9rem .45rem 2.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit;
  font-size: .85rem;
  outline: none;
  transition: border var(--transition);
}

html[dir="rtl"] .header .global-search input {
  padding: .45rem 2.2rem .45rem .9rem;
}

.header .global-search input:focus { border-color: var(--primary); }
.header .global-search .search-icon {
  position: absolute;
  left: .7rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .85rem; pointer-events: none;
}
html[dir="rtl"] .header .global-search .search-icon { left: auto; right: .7rem; }

.global-search-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0; left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  z-index: 300;
  display: none;
}
.global-search-results.show { display: block; }
.search-result-item {
  padding: .6rem .9rem;
  cursor: pointer;
  display: flex; align-items: center; gap: .5rem;
  border-bottom: 1px solid var(--border);
  font-size: .84rem;
}
.search-result-item:hover { background: var(--surface2); }
.search-result-item .sr-type {
  font-size: .7rem; padding: 1px 6px;
  background: var(--primary-light); color: var(--primary);
  border-radius: 999px; font-weight: 600;
}

.header-actions {
  display: flex; align-items: center; gap: .5rem;
  margin-right: auto;
}
html[dir="rtl"] .header-actions { margin-right: 0; margin-left: auto; }

.header-btn {
  width: 36px; height: 36px;
  background: none; border: none;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.header-btn:hover { background: var(--surface2); color: var(--text); }

.notif-badge {
  position: absolute;
  top: 3px; left: 3px;
  background: #ef4444; color: #fff;
  font-size: .6rem; font-weight: 700;
  min-width: 15px; height: 15px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.user-menu {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.user-menu:hover { background: var(--surface2); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--warning));
  color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
}
.user-menu-text .name { font-weight: 600; font-size: .84rem; }
.user-menu-text .role { font-size: .7rem; color: var(--text-muted); }

/* ==============================
   PAGE CONTENT
============================== */
.page-body {
  padding: 1.5rem 1.25rem;
  flex: 1;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}

.page-title { font-size: 1.3rem; font-weight: 700; }
.page-subtitle { font-size: .83rem; color: var(--text-secondary); margin-top: 2px; }

.breadcrumb {
  display: flex; align-items: center; gap: .4rem;
  font-size: .78rem; color: var(--text-muted); margin-bottom: .75rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: var(--border); }

/* ==============================
   CARDS
============================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: .95rem;
}

.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface2);
}

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 1rem; }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.kpi-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.kpi-icon.blue   { background: var(--primary-light); color: var(--primary); }
.kpi-icon.green  { background: var(--success-light); color: var(--success); }
.kpi-icon.yellow { background: var(--warning-light); color: var(--warning); }
.kpi-icon.red    { background: var(--danger-light);  color: var(--danger); }
.kpi-icon.purple { background: var(--purple-light);  color: var(--purple); }
.kpi-icon.orange { background: var(--orange-light);  color: var(--orange); }
.kpi-icon.teal   { background: var(--info-light);    color: var(--info); }

.kpi-data .kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.kpi-data .kpi-label { font-size: .8rem; color: var(--text-secondary); margin-top: 2px; }
.kpi-data .kpi-change {
  font-size: .75rem; font-weight: 600; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 2px;
}
.kpi-change.up   { color: var(--success); }
.kpi-change.down { color: var(--danger);  }

/* ==============================
   BUTTONS
============================== */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border: none; border-radius: var(--radius);
  cursor: pointer; font-family: inherit; font-size: .85rem; font-weight: 600;
  transition: all var(--transition); white-space: nowrap; line-height: 1;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info    { background: var(--info);    color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost   { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-sm { padding: .3rem .7rem; font-size: .78rem; }
.btn-lg { padding: .7rem 1.4rem; font-size: .95rem; }
.btn-icon { padding: .4rem; width: 34px; height: 34px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* ==============================
   FORMS
============================== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 600; font-size: .83rem; margin-bottom: .35rem; color: var(--text); }
.form-label .required { color: var(--danger); margin-right: 2px; }

.form-control {
  display: block; width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit; font-size: .87rem;
  transition: border var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: .78rem; margin-top: .25rem; }

textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 1rem; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ==============================
   TABLES
============================== */
.table-wrapper { overflow-x: auto; }

.table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.table th, .table td {
  padding: .65rem .85rem;
  border-bottom: 1px solid var(--border);
  text-align: right;
}
.table th {
  background: var(--surface2);
  font-weight: 700; font-size: .78rem;
  color: var(--text-secondary); white-space: nowrap;
}
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--surface2); }
.table tbody tr:last-child td { border-bottom: none; }

.table-actions { display: flex; gap: .3rem; }

/* ==============================
   BADGES
============================== */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: var(--success-light); color: var(--success); }
.badge-warning   { background: var(--warning-light); color: var(--warning); }
.badge-danger    { background: var(--danger-light);  color: var(--danger); }
.badge-info      { background: var(--info-light);    color: var(--info); }
.badge-secondary { background: var(--surface2);      color: var(--text-secondary); border: 1px solid var(--border); }
.badge-purple    { background: var(--purple-light);  color: var(--purple); }
.badge-orange    { background: var(--orange-light);  color: var(--orange); }

/* ==============================
   MODALS
============================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(.96) translateY(10px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 1rem;
}

.modal-close {
  background: none; border: none;
  cursor: pointer; font-size: 1.2rem; color: var(--text-muted);
  padding: .2rem .4rem; border-radius: var(--radius);
  transition: background var(--transition);
}
.modal-close:hover { background: var(--surface2); color: var(--text); }

.modal-body   { padding: 1.25rem; }
.modal-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: .5rem;
}

/* ==============================
   FLASH MESSAGES
============================== */
.flash-container {
  position: fixed; top: calc(var(--header-h) + .75rem);
  right: 1rem;
  z-index: 1000;
  display: flex; flex-direction: column; gap: .5rem;
  max-width: 360px;
}
html[dir="rtl"] .flash-container { right: auto; left: 1rem; }

.flash {
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  font-size: .85rem; font-weight: 500;
  display: flex; align-items: center; gap: .6rem;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.flash-success { background: var(--success-light); color: var(--success); border: 1px solid #84e1bc; }
.flash-error   { background: var(--danger-light);  color: var(--danger);  border: 1px solid #f8b4b4; }
.flash-warning { background: var(--warning-light); color: var(--warning); border: 1px solid #faca15; }
.flash-info    { background: var(--info-light);    color: var(--info);    border: 1px solid #7edce2; }

/* ==============================
   KANBAN PIPELINE
============================== */
.kanban-board {
  display: flex; gap: 1rem; overflow-x: auto;
  padding-bottom: 1rem; min-height: 60vh;
}

.kanban-col {
  min-width: 270px; max-width: 300px; flex-shrink: 0;
  display: flex; flex-direction: column;
}

.kanban-col-header {
  padding: .6rem .85rem;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: space-between;
  color: #fff;
}

.kanban-col-header.col-lead        { background: #64748b; }
.kanban-col-header.col-qualified   { background: var(--info); }
.kanban-col-header.col-proposal    { background: var(--warning); }
.kanban-col-header.col-visit       { background: var(--purple); }
.kanban-col-header.col-negotiation { background: var(--orange); }
.kanban-col-header.col-won         { background: var(--success); }
.kanban-col-header.col-lost        { background: var(--danger); }

.kanban-cards {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  flex: 1;
  padding: .5rem;
  min-height: 200px;
}

.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem;
  margin-bottom: .5rem;
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition);
  box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-card.sortable-drag { opacity: .4; }
.kanban-card.sortable-ghost { outline: 2px dashed var(--primary); background: var(--primary-light); }

.kanban-card .card-client { font-weight: 700; font-size: .85rem; }
.kanban-card .card-property { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.kanban-card .card-value { font-size: .8rem; color: var(--success); font-weight: 600; margin-top: .4rem; }
.kanban-card .card-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: .5rem; font-size: .72rem; color: var(--text-muted);
}
.kanban-card .card-agent { display: flex; align-items: center; gap: .3rem; }
.kanban-card .agent-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: .62rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ==============================
   TIMELINE (Activities)
============================== */
.timeline { position: relative; }
.timeline::before {
  content: '';
  position: absolute;
  right: 15px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
html[dir="ltr"] .timeline::before { right: auto; left: 15px; }

.timeline-item {
  display: flex; gap: 1rem;
  padding: .6rem 0;
  position: relative;
}
.timeline-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  border: 2px solid var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem;
  flex-shrink: 0;
  z-index: 1;
}
.timeline-content { flex: 1; }
.timeline-content .tl-header {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.timeline-content .tl-desc { font-size: .83rem; color: var(--text-secondary); margin-top: .2rem; }
.timeline-content .tl-time { font-size: .73rem; color: var(--text-muted); }

/* ==============================
   FILTER BAR
============================== */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end;
}

.filter-bar .filter-select {
  padding: .4rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-family: inherit; font-size: .82rem;
  outline: none; cursor: pointer;
  min-width: 140px;
}

.filter-bar .filters-toggle {
  display: flex; align-items: center; gap: .35rem;
  color: var(--primary); font-size: .82rem; font-weight: 600; cursor: pointer;
  background: none; border: 1px solid var(--primary); border-radius: var(--radius);
  padding: .4rem .75rem;
}

/* ==============================
   PROPERTY GRID
============================== */
.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.property-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.property-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.property-card .prop-img {
  width: 100%; height: 180px; object-fit: cover;
  background: linear-gradient(135deg, #e7ecfb, #f7ecda);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
}
.property-card .prop-img img { width: 100%; height: 100%; object-fit: cover; }

.property-card .prop-status {
  position: absolute; top: .6rem; right: .6rem;
}

.property-card .prop-body { padding: .9rem; }
.property-card .prop-code { font-size: .7rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; }
.property-card .prop-title { font-weight: 700; font-size: .95rem; margin: .2rem 0 .35rem; }
.property-card .prop-price { font-size: 1.15rem; font-weight: 800; color: var(--warning); }
.property-card .prop-details {
  display: flex; gap: .75rem; flex-wrap: wrap;
  margin-top: .5rem; font-size: .78rem; color: var(--text-secondary);
}
.property-card .prop-details span { display: flex; align-items: center; gap: .25rem; }

.prop-card-relative { position: relative; }

/* ==============================
   STATS / LEADERBOARD
============================== */
.leaderboard-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.leaderboard-item:last-child { border-bottom: none; }

.lb-rank {
  width: 24px; font-weight: 800; font-size: .9rem;
  text-align: center; color: var(--text-muted);
}
.lb-rank.top1 { color: #f59e0b; }
.lb-rank.top2 { color: #94a3b8; }
.lb-rank.top3 { color: #b45309; }

.lb-progress {
  flex: 1;
}
.lb-progress-bar {
  height: 6px; border-radius: 999px;
  background: var(--border);
  margin-top: 4px; overflow: hidden;
}
.lb-progress-bar .fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  transition: width .6s ease;
}
.lb-value { font-weight: 700; font-size: .85rem; white-space: nowrap; }

/* ==============================
   FLOATING QUICK ADD
============================== */
.fab {
  position: fixed;
  left: 1.5rem; bottom: 1.5rem;
  width: 52px; height: 52px;
  background: var(--primary);
  color: #fff; border: none; border-radius: 50%;
  font-size: 1.5rem; cursor: pointer;
  box-shadow: 0 4px 16px rgba(26,86,219,.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 400;
  transition: transform var(--transition), box-shadow var(--transition);
}
html[dir="rtl"] .fab { left: auto; right: 1.5rem; }
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(26,86,219,.45); }
.fab.open { transform: rotate(45deg); }

.fab-menu {
  position: fixed;
  left: 1.5rem; bottom: 4.5rem;
  z-index: 399;
  display: flex; flex-direction: column; gap: .5rem;
  align-items: flex-start;
  opacity: 0; pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition);
}
html[dir="rtl"] .fab-menu { left: auto; right: 1.5rem; align-items: flex-end; }
.fab-menu.open { opacity: 1; pointer-events: auto; transform: translateY(0); }

.fab-item {
  display: flex; align-items: center; gap: .5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .45rem .9rem;
  cursor: pointer; font-size: .84rem; font-weight: 600;
  box-shadow: var(--shadow); white-space: nowrap;
  text-decoration: none; color: var(--text);
  transition: background var(--transition);
}
.fab-item:hover { background: var(--primary-light); color: var(--primary); }

/* ==============================
   NOTIFICATIONS DROPDOWN
============================== */
.notif-dropdown {
  position: absolute;
  top: calc(var(--header-h) - 8px);
  left: 0;
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
}
html[dir="rtl"] .notif-dropdown { left: auto; right: 0; }
.notif-dropdown.open { display: block; }

.notif-dropdown-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .9rem;
  display: flex; align-items: center; justify-content: space-between;
}
.notif-item {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
  display: flex; align-items: flex-start; gap: .6rem;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: var(--primary-light); }
.notif-item .notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary); flex-shrink: 0; margin-top: 4px;
}
.notif-item .notif-title { font-weight: 600; font-size: .83rem; }
.notif-item .notif-text  { font-size: .78rem; color: var(--text-secondary); margin-top: 1px; }
.notif-item .notif-time  { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ==============================
   SKELETON LOADER
============================== */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface2) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
  display: inline-block;
}
@keyframes shimmer { to { background-position: -200% center; } }
.skeleton-line { height: 14px; margin-bottom: 8px; }
.skeleton-line.w-full { width: 100%; }
.skeleton-line.w-3-4  { width: 75%; }
.skeleton-line.w-1-2  { width: 50%; }
.skeleton-rect { width: 100%; height: 180px; }

/* ==============================
   PAGINATOR
============================== */
.paginator {
  display: flex; gap: .3rem; justify-content: center;
  flex-wrap: wrap; margin-top: 1.25rem;
}
.page-btn {
  min-width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .83rem; font-weight: 600; color: var(--text);
  background: var(--surface); cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); text-decoration: none; }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ==============================
   LOGIN PAGE
============================== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #10194c 0%, #1f2f84 55%, #14205d 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%; max-width: 420px;
  background: linear-gradient(180deg, rgba(23,35,98,.92), rgba(11,18,49,.94));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(193,154,87,.24);
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}
.login-logo::before {
  content: '';
  display: block;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 10 / 3;
  margin: 0 auto .9rem;
  background: url('../img/property-stone-logo.svg') center / contain no-repeat;
}
.login-logo .logo-circle,
.login-logo h1 {
  display: none;
}

.login-logo::after {
  content: 'Property Stone CRM';
  display: block;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.login-logo p  { color: rgba(255,255,255,.66); font-size: .82rem; margin-top: .35rem; }

.login-card .form-label { color: rgba(255,255,255,.75); }
.login-card .form-control {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
  color: #fff;
}
.login-card .form-control::placeholder { color: rgba(255,255,255,.35); }
.login-card .form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}

.login-card .btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--warning), var(--primary));
  color: #fff; border: none; padding: .7rem;
  border-radius: var(--radius); font-size: .95rem; font-weight: 700;
  cursor: pointer; margin-top: .5rem;
  transition: opacity var(--transition), transform var(--transition);
}
.login-card .btn-login:hover { opacity: .9; transform: translateY(-1px); }

/* ==============================
   RESPONSIVE
============================== */
@media(max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(100%);
    width: 260px;
  }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content { margin-right: 0; }
  html[dir="ltr"] .main-content { margin-left: 0; }

  .header .sidebar-toggle { display: flex; }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

@media(max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .property-grid { grid-template-columns: 1fr; }
  .header .global-search { display: none; }
}

/* ==============================
   UTILITIES
============================== */
.text-primary   { color: var(--primary) !important; }
.text-success   { color: var(--success) !important; }
.text-danger    { color: var(--danger)  !important; }
.text-warning   { color: var(--warning) !important; }
.text-muted     { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }

.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-1          { gap: .25rem; }
.gap-2          { gap: .5rem; }
.gap-3          { gap: .75rem; }
.gap-4          { gap: 1rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: .25rem; }
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; }

.fw-bold   { font-weight: 700; }
.fw-normal { font-weight: 400; }
.fs-sm     { font-size: .8rem; }
.fs-lg     { font-size: 1.1rem; }

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

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

.hidden  { display: none !important; }
.visible { display: block !important; }

.text-center { text-align: center; }
.text-start  { text-align: right; }
.text-end    { text-align: left; }
html[dir="ltr"] .text-start { text-align: left; }
html[dir="ltr"] .text-end   { text-align: right; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; }

.score-bar {
  display: flex; align-items: center; gap: .6rem;
}
.score-bar .score-track {
  flex: 1; height: 6px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.score-bar .score-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
}
.score-bar .score-num { font-size: .78rem; font-weight: 700; min-width: 28px; }
