/* ===================================================
   MapPulse AI - Premium Design System (Arabic RTL / Modern SaaS)
   =================================================== */

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

:root {
  --bg-dark: #0a0e17;
  --bg-card: #121826;
  --bg-card-hover: #172033;
  --bg-sidebar: #0d121f;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(59, 130, 246, 0.4);
  
  --primary: #3b82f6;
  --primary-glow: rgba(59, 130, 246, 0.25);
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  color: var(--text-main);
  direction: rtl;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* Layout */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.brand-info h2 {
  font-size: 19px;
  font-weight: 800;
  background: linear-gradient(90deg, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  transition: all 0.2s ease;
}

.nav-item a:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  transform: translateX(-3px);
}

.nav-item.active a {
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.15));
  color: #60a5fa;
  border-right: 3px solid #3b82f6;
  box-shadow: 0 0 15px rgba(59, 130, 246, 0.15);
}

.nav-badge {
  margin-right: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
}
.badge-alert {
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.4);
}
.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}
.badge-primary {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: white;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-dark);
}

.top-navbar {
  height: 72px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(13, 18, 31, 0.7);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.page-title-box h1 {
  font-size: 22px;
  font-weight: 800;
}
.page-title-box p {
  font-size: 13px;
  color: var(--text-muted);
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0284c7);
  color: white;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #0369a1);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}
.btn-accent:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}
.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.content-body {
  padding: 32px;
  flex: 1;
}

/* Cards & Grid */
.grid-cols-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.grid-cols-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.grid-cols-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
}
.stat-card.blue::before { background: #3b82f6; }
.stat-card.emerald::before { background: #10b981; }
.stat-card.amber::before { background: #f59e0b; }
.stat-card.rose::before { background: #f43f5e; }

.stat-info p {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.stat-info h3 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
}
.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.stat-icon.emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.stat-icon.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.stat-icon.rose { background: rgba(244, 63, 94, 0.15); color: #fb7185; }

/* Dashboard Sections */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.card-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
}
.card-title i {
  color: var(--primary);
}

/* Alert Box for Duplicate Locations */
.duplicate-alert-banner {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.12), rgba(245, 158, 11, 0.12));
  border: 1px solid rgba(244, 63, 94, 0.35);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.alert-badge-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.2);
  color: #fb7185;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.alert-content h4 {
  font-size: 17px;
  font-weight: 800;
  color: #fda4af;
  margin-bottom: 6px;
}
.alert-content p {
  font-size: 14px;
  color: #cbd5e1;
  margin-bottom: 12px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}
table.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}
table.custom-table th {
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
}
table.custom-table td {
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 14px;
  vertical-align: middle;
}
table.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
}
.tag-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.tag-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.tag-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.tag-primary { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.tag-purple { background: rgba(139, 92, 246, 0.15); color: #c4b5fd; }

/* Forms & Inputs */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 8px;
}
.form-control {
  width: 100%;
  padding: 12px 14px;
  background-color: #0b111e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s ease;
}
.form-control:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Social Grid & Composer */
.social-accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.account-icon {
  font-size: 26px;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-body {
  padding: 24px;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #1e293b;
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  border-right: 4px solid var(--primary);
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
  font-size: 14px;
  font-weight: 600;
  animation: slideIn 0.3s ease;
  min-width: 300px;
}
@keyframes slideIn {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: 1fr; }
  .grid-cols-2 { grid-template-columns: 1fr; }
  .sidebar { width: 240px; }
}
@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .top-navbar { padding: 0 16px; }
  .content-body { padding: 16px; }
  .grid-cols-4 { grid-template-columns: 1fr; }
}
