/* modern-style.css - تصميم عصري موحد ومتجاوب */
:root {
  /* الألوان الأساسية */
  --primary: #1877f2;
  --primary-hover: #1565c0;
  --primary-light: rgba(24, 119, 242, 0.1);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  /* الخلفيات والنصوص */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  /* الحدود والظلال */
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.12), 0 8px 10px -6px rgb(0 0 0 / 0.08);
  
  /* الأبعاد والانتقالات */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --header-height: 64px;
  --nav-height: 72px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* الخطوط */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ========== الأساسيات ========== */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  font-size: clamp(15px, 1.2vw, 16px);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-top: var(--header-height);
  padding-bottom: var(--nav-height);
}
a { text-decoration: none; color: inherit; transition: color var(--transition-fast); }
button, input, select, textarea, a { cursor: pointer; outline: none; }
img, video, svg { max-width: 100%; display: block; }

/* ========== الشريط العلوي ========== */
.top-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(12px, 4vw, 24px);
  z-index: 1000; box-shadow: var(--shadow-sm);
}
.logo-container { display: flex; align-items: center; gap: 10px; cursor: pointer; transition: opacity var(--transition-fast); }
.logo-container:hover { opacity: 0.8; }
.logo { font-size: 1.5rem; color: var(--primary); font-weight: 700; }
.app-name, .site-title { font-size: clamp(1.1rem, 3vw, 1.35rem); font-weight: 700; color: var(--primary); letter-spacing: -0.01em; }
.header-search { flex: 1; max-width: 420px; margin: 0 16px; }
.search-box { width: 100%; padding: 0.7rem 1rem; background: var(--bg-elevated); border-radius: var(--radius-full); border: 1px solid var(--border-light); font-size: 0.9rem; transition: var(--transition-fast); }
.search-box:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.header-actions, .header-icons { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-md); color: var(--text-secondary); background: transparent; transition: var(--transition-fast); }
.icon-btn:hover { background: var(--bg-elevated); color: var(--primary); }
#toggleSidebarBtn { @extend .icon-btn; }

/* ========== القائمة الجانبية ========== */
.sidebar {
  position: fixed; top: var(--header-height); right: 0;
  width: 280px; height: calc(100vh - var(--header-height));
  background: var(--bg-surface); border-left: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg); z-index: 1001;
  transform: translateX(100%); transition: transform var(--transition-normal);
  overflow-y: auto; padding: 16px 0;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.sidebar-header h3 { margin: 0; font-size: 1.1rem; color: var(--primary); }
.sidebar-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-secondary); transition: color var(--transition-fast); }
.sidebar-close:hover { color: var(--danger); }
.sidebar-menu { list-style: none; padding: 0; margin: 8px 0; }
.sidebar-menu li { margin-bottom: 2px; }
.sidebar-menu a { display: flex; align-items: center; gap: 12px; padding: 12px 20px; color: var(--text-primary); font-size: 0.95rem; border-radius: var(--radius-md); margin: 2px 12px; transition: var(--transition-fast); }
.sidebar-menu a:hover, .sidebar-menu a.active { background: var(--primary-light); color: var(--primary); }
.sidebar-menu a i { color: var(--primary); width: 20px; text-align: center; }
.sidebar-actions { padding: 16px 20px; border-top: 1px solid var(--border-light); margin-top: 12px; }
.sidebar-action-btn { width: 100%; padding: 10px 16px; margin-bottom: 8px; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); color: var(--text-primary); font-size: 0.9rem; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition-fast); }
.sidebar-action-btn:hover { background: var(--primary); color: white; border-color: var(--primary); transform: translateY(-1px); }
.auth-sidebar-buttons { padding: 16px 20px; border-top: 1px solid var(--border-light); margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.auth-sidebar-btn { padding: 10px 16px; border-radius: var(--radius-md); font-weight: 600; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition-fast); border: none; }
.auth-sidebar-btn.login { background: var(--primary); color: white; }
.auth-sidebar-btn.register { background: var(--success); color: white; }
.auth-sidebar-btn.logout { background: var(--danger); color: white; }
.auth-sidebar-btn.admin { background: #9333ea; color: white; }

/* ========== أشرطة الإجراءات ========== */
.requests-action-bar, .map-action-bar {
  position: fixed; top: var(--header-height); left: 0; right: 0;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light); padding: 10px 16px; display: flex; gap: 10px; align-items: center;
  z-index: 999; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.requests-action-bar::-webkit-scrollbar, .map-action-bar::-webkit-scrollbar { display: none; }
.map-action-bar { top: calc(var(--header-height) + 52px); }
.action-btn { padding: 0.6rem 1.2rem; border-radius: var(--radius-full); font-size: 0.875rem; font-weight: 500; background: var(--bg-surface); color: var(--text-secondary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: var(--transition-fast); white-space: nowrap; border: 1px solid var(--border-light); box-shadow: var(--shadow-sm); }
.action-btn:hover { background: var(--primary); color: white; border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-md); }
#addRequestBtn { background: var(--info); color: white; border: none; }
#viewRequestsBtn { background: var(--success); color: white; border: none; }

/* ========== الخريطة ========== */
#map { position: fixed; top: calc(var(--header-height) + 110px); left: 12px; right: 12px; bottom: calc(var(--nav-height) + 12px); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); border: 1px solid var(--border-light); background: var(--bg-elevated); }
.leaflet-tile, .leaflet-marker-icon, .leaflet-marker-shadow, .leaflet-interactive { will-change: transform; }
.price-marker { background: var(--bg-surface) !important; border: 2px solid var(--success); border-radius: var(--radius-full); padding: 4px 10px; font-weight: 700; font-size: 0.75rem; color: var(--text-primary); text-align: center; box-shadow: var(--shadow-md); white-space: nowrap; cursor: pointer; transition: var(--transition-fast); }
.price-marker:hover { transform: scale(1.05) translateY(-2px); border-color: var(--primary); box-shadow: var(--shadow-lg); }
.price-marker.for-sale { border-color: var(--success); color: var(--success); }
.price-marker.for-rent-below { border-color: var(--danger); color: var(--danger); }

/* ========== الشريط السفلي ========== */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height); background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--border-light); display: flex; justify-content: space-around; align-items: center; z-index: 1000; box-shadow: 0 -4px 12px rgba(0,0,0,0.05); }
.nav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 8px 12px; border-radius: var(--radius-lg); color: var(--text-secondary); transition: var(--transition-fast); position: relative; flex: 1; max-width: 72px; }
.nav-item:hover { background: var(--bg-elevated); color: var(--primary); }
.nav-item.active { color: var(--primary); background: var(--primary-light); }
.nav-icon { font-size: 1.25rem; margin-bottom: 4px; transition: transform var(--transition-fast); }
.nav-item.active .nav-icon { transform: scale(1.15); }
.nav-text { font-size: 0.75rem; font-weight: 500; white-space: nowrap; }
.notification-badge { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); background: var(--danger); color: white; font-size: 0.7rem; min-width: 18px; height: 18px; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-weight: 600; border: 2px solid var(--bg-surface); }

/* ========== المودالات والنوافذ ========== */
.modal-content, .auth-modal-content, .account-modal-content, .add-property-content, .property-card, .estimate-content, .confirm-delete-content {
  background: var(--bg-surface); padding: 24px; border-radius: var(--radius-lg); width: 90%; max-width: 480px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-xl); position: relative; border: 1px solid var(--border-light); animation: modalFadeIn 0.3s var(--transition-normal) forwards;
}
@keyframes modalFadeIn { from { opacity: 0; transform: translateY(20px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.close-btn { position: absolute; top: 16px; left: 16px; width: 32px; height: 32px; border-radius: 50%; background: var(--bg-elevated); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition-fast); }
.close-btn:hover { background: var(--danger); color: white; transform: rotate(90deg); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.8rem 1rem; background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius-md); transition: var(--transition-fast); font-size: 0.9rem; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); background: var(--bg-surface); }
.auth-btn, .btn, .btn-primary { width: 100%; padding: 0.85rem; background: var(--primary); color: white; border-radius: var(--radius-md); font-weight: 600; cursor: pointer; transition: var(--transition-fast); display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: none; }
.auth-btn:hover, .btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-outline { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-medium); }
.btn-outline:hover { background: var(--bg-elevated); }
.btn-danger { background: var(--danger); color: white; }

/* ========== البطاقات والقوائم ========== */
.listing-card, .post-card, .agent-card, .request-item, .stat-card {
  background: var(--bg-surface); border-radius: var(--radius-lg); border: 1px solid var(--border-light); overflow: hidden; transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.listing-card:hover, .post-card:hover, .agent-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.listing-content, .post-info { padding: 16px; }
.listing-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.listing-title { font-size: 1.05rem; font-weight: 600; color: var(--text-primary); line-height: 1.4; }
.price-tag { background: var(--primary-light); color: var(--primary); padding: 6px 14px; border-radius: var(--radius-full); font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.detail-item { background: var(--bg-elevated); padding: 12px; border-radius: var(--radius-md); display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.detail-label { font-size: 0.85rem; color: var(--text-secondary); }
.detail-value { font-weight: 600; color: var(--text-primary); }
.action-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; padding: 12px 0; border-top: 1px solid var(--border-light); border-bottom: 1px solid var(--border-light); }
.action-buttons .action-btn { flex: 1; min-width: 100px; font-size: 0.85rem; }
.whatsapp-btn { background: #25D366; color: white; padding: 10px 16px; border-radius: var(--radius-md); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: var(--transition-fast); }
.whatsapp-btn:hover { background: #128C7E; transform: translateY(-2px); }

/* ========== لوحة تحكم المسؤول ========== */
.admin-container { max-width: 1200px; margin: 20px auto; padding: 0 16px; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-number { font-size: 1.8rem; font-weight: 700; color: var(--primary); margin: 8px 0 4px; }
.stat-label { color: var(--text-secondary); font-size: 0.9rem; }
.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--bg-surface); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.admin-table th, .admin-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-light); text-align: center; }
.admin-table th { background: var(--bg-elevated); font-weight: 600; color: var(--text-secondary); font-size: 0.9rem; }
.action-btn-sm { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 0.8rem; cursor: pointer; transition: var(--transition-fast); border: none; }
.action-btn-sm.approve { background: var(--success); color: white; }
.action-btn-sm.reject { background: var(--danger); color: white; }
.action-btn-sm:hover { opacity: 0.9; transform: translateY(-1px); }

/* ========== صفحة الملف الشخصي ========== */
.profile-container { max-width: 800px; margin: 24px auto; background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
.profile-cover { height: 140px; background: linear-gradient(135deg, var(--primary), #9333ea); position: relative; }
.profile-avatar-wrapper { position: absolute; bottom: -45px; left: 50%; transform: translateX(-50%); width: 110px; height: 110px; border-radius: 50%; border: 4px solid var(--bg-surface); background: var(--bg-surface); box-shadow: var(--shadow-md); overflow: hidden; }
.profile-avatar { width: 100%; height: 100%; object-fit: cover; }
.profile-info { text-align: center; padding: 60px 20px 24px; }
.profile-info h2 { margin: 0 0 4px; font-size: 1.4rem; }
.profile-coins { background: var(--primary-light); color: var(--primary); padding: 6px 16px; border-radius: var(--radius-full); font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; }
.profile-tabs { display: flex; border-bottom: 1px solid var(--border-light); padding: 0 8px; overflow-x: auto; scrollbar-width: none; }
.profile-tabs::-webkit-scrollbar { display: none; }
.tab-btn { padding: 14px 20px; background: none; border: none; border-bottom: 3px solid transparent; color: var(--text-secondary); font-weight: 500; cursor: pointer; transition: var(--transition-fast); white-space: nowrap; }
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-content { padding: 20px; }
.posts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }

/* ========== الإشعارات والعناصر المحملة ========== */
.notification { position: fixed; top: 80px; left: 50%; transform: translateX(-50%); padding: 14px 24px; border-radius: var(--radius-lg); font-weight: 500; z-index: 9999; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow-lg); background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-light); animation: slideIn 0.3s var(--transition-normal) forwards; }
.notification.success { border-left: 4px solid var(--success); }
.notification.error { border-left: 4px solid var(--danger); }
.notification.info { border-left: 4px solid var(--info); }
@keyframes slideIn { from { transform: translateX(-50%) translateY(-20px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(-50%) translateY(0); opacity: 1; } to { transform: translateX(-50%) translateY(-20px); opacity: 0; } }
.loader { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1002; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border-medium); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-message { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(15, 23, 42, 0.85); color: white; padding: 16px 24px; border-radius: var(--radius-lg); z-index: 1002; display: none; text-align: center; backdrop-filter: blur(6px); }
.admin-only { display: none; }
.admin-only.visible { display: block; }

/* ========== الوضع الليلي ========== */
body.dark-mode {
  --bg-body: #0b1120;
  --bg-surface: #151c2c;
  --bg-elevated: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-light: #2a354d;
  --border-medium: #374151;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}
body.dark-mode .top-header,
body.dark-mode .bottom-nav,
body.dark-mode .sidebar,
body.dark-mode .requests-action-bar,
body.dark-mode .map-action-bar,
body.dark-mode .profile-container {
  background: rgba(15, 23, 42, 0.85);
  border-color: var(--border-light);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
body.dark-mode .search-box,
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea,
body.dark-mode .detail-item,
body.dark-mode .action-btn,
body.dark-mode .close-btn {
  background: var(--bg-elevated);
  border-color: var(--border-medium);
  color: var(--text-primary);
}
body.dark-mode .icon-btn:hover,
body.dark-mode .sidebar-menu a:hover,
body.dark-mode .sidebar-menu a.active,
body.dark-mode .nav-item:hover { background: rgba(255,255,255,0.06); }
body.dark-mode .notification { background: var(--bg-surface); color: var(--text-primary); border-color: var(--border-medium); }
body.dark-mode .listing-card,
body.dark-mode .post-card,
body.dark-mode .agent-card,
body.dark-mode .stat-card,
body.dark-mode .admin-table { background: var(--bg-surface); border-color: var(--border-light); }

/* ========== تحسينات للشاشات الصغيرة ========== */
@media (max-width: 768px) {
  .header-search { display: none; }
  .top-header { padding: 0 12px; }
  .sidebar { width: 260px; }
  #map { left: 8px; right: 8px; top: calc(var(--header-height) + 100px); }
  .requests-action-bar, .map-action-bar { top: calc(var(--header-height) + 2px); padding: 8px 12px; }
  .map-action-bar { top: calc(var(--header-height) + 48px); }
  .admin-table { font-size: 0.85rem; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  :root { --header-height: 56px; --nav-height: 64px; }
  .bottom-nav { height: var(--nav-height); }
  .nav-item { padding: 6px 8px; max-width: 64px; }
  .nav-icon { font-size: 1.1rem; }
  .nav-text { font-size: 0.7rem; }
  .profile-cover { height: 110px; }
  .profile-avatar-wrapper { width: 90px; height: 90px; bottom: -35px; }
  .profile-info { padding: 45px 16px 16px; }
}