@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Kufi+Arabic:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #0891b2; --primary-dark: #0e7490; --primary-light: #ecfeff;
  --accent: #f59e0b; --accent-dark: #d97706;
  --success: #10b981; --danger: #ef4444; --warning: #f59e0b; --info: #3b82f6;
  --surface: #f8fafc; --surface-2: #f1f5f9; --card-bg: rgba(255,255,255,0.8);
  --sidebar-bg: #0f172a; --sidebar-text: #94a3b8; --sidebar-active: #0891b2;
  --text: #1e293b; --text-muted: #64748b; --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0,0,0,0.06); --shadow-lg: 0 12px 40px rgba(0,0,0,0.1);
  --radius: 16px; --radius-sm: 10px; --radius-pill: 50px;
  --transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  --font-en: 'Inter', sans-serif; --font-ar: 'Noto Kufi Arabic', sans-serif;
}

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

html { scroll-behavior: smooth; }
html[dir="ltr"] body { font-family: var(--font-en); }
html[dir="rtl"] body { font-family: var(--font-ar); }

body { background: var(--surface); color: var(--text); line-height: 1.6; min-height: 100vh; }

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface-2); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 24px;
  border-radius: var(--radius-sm); font-weight: 600; border: none; cursor: pointer;
  transition: var(--transition); font-size: 0.9rem; }
.btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #065063); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-outline-danger { background: transparent; border: 2px solid var(--danger); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 6px 16px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: 50%; }

/* ── Cards ── */
.card { background: var(--card-bg); backdrop-filter: blur(20px); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-lg); }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface); }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; padding: 4px 14px; border-radius: var(--radius-pill);
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.3px; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--surface-2); color: var(--text-muted); }

/* ── Forms ── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.form-control, .form-select { width: 100%; padding: 12px 16px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem; transition: var(--transition);
  background: #fff; color: var(--text); }
html[dir="rtl"] .form-control, html[dir="rtl"] .form-select { font-family: var(--font-ar); }
.form-control:focus, .form-select:focus { outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(8,145,178,0.1); }
.form-control::placeholder { color: #cbd5e1; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.input-group { display: flex; align-items: stretch; }
.input-group .form-control { border-radius: 0; }
.input-group > :first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
html[dir="rtl"] .input-group > :first-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group > :last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
html[dir="rtl"] .input-group > :last-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-addon { padding: 12px 16px; background: var(--surface-2); border: 2px solid var(--border);
  border-right: none; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; }
html[dir="rtl"] .input-addon { border-right: 2px solid var(--border); border-left: none; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th { padding: 14px 16px; text-align: start; font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); background: var(--surface); border-bottom: 2px solid var(--border); }
td { padding: 14px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--primary-light); }

/* ── Alerts ── */
.alert { padding: 16px 20px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.9rem; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Stat Cards ── */
.stat-card { display: flex; align-items: center; gap: 16px; padding: 24px; }
.stat-icon { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center;
  justify-content: center; font-size: 1.5rem; flex-shrink: 0; }
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.warning { background: #fef3c7; color: var(--warning); }
.stat-icon.info { background: #dbeafe; color: var(--info); }
.stat-icon.success { background: #d1fae5; color: var(--success); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ── Chat Bubbles ── */
.chat-container { max-height: 400px; overflow-y: auto; padding: 16px; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.chat-bubble { max-width: 80%; padding: 12px 16px; border-radius: 16px; font-size: 0.9rem; line-height: 1.5; position: relative; }
.chat-bubble.admin { background: var(--primary); color: #fff; align-self: flex-start;
  border-bottom-left-radius: 4px; }
html[dir="rtl"] .chat-bubble.admin { align-self: flex-end; border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }
.chat-bubble.client { background: #e2e8f0; color: var(--text); align-self: flex-end;
  border-bottom-right-radius: 4px; }
html[dir="rtl"] .chat-bubble.client { align-self: flex-start; border-bottom-right-radius: 16px; border-bottom-left-radius: 4px; }
.chat-time { font-size: 0.7rem; opacity: 0.7; margin-top: 4px; }

/* ── Sidebar Layout (Admin & Client Portals) ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text); padding: 0;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; display: flex; flex-direction: column;
  transition: var(--transition); overflow-y: auto; }
html[dir="rtl"] .sidebar { left: auto; right: 0; }
.sidebar-brand { padding: 24px 20px; font-size: 1.15rem; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 10px; }
.sidebar-brand span { color: var(--primary); }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); font-size: 0.9rem; font-weight: 500; transition: var(--transition); }
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: rgba(8,145,178,0.15); color: var(--sidebar-active); font-weight: 600; }
.sidebar-link i { font-size: 1.15rem; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); }

.main-content { flex: 1; margin-left: 260px; min-height: 100vh; display: flex; flex-direction: column; }
html[dir="rtl"] .main-content { margin-left: 0; margin-right: 260px; }

.topbar { background: var(--card-bg); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border);
  padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 1.25rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-content { flex: 1; padding: 32px; }
.page-footer { padding: 20px 32px; border-top: 1px solid var(--border); color: var(--text-muted);
  font-size: 0.8rem; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }

/* ── Mobile Sidebar ── */
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 99; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; margin-right: 0 !important; }
  .sidebar-toggle { display: block; }
  .sidebar-overlay.show { display: block; }
  .page-content { padding: 20px 16px; }
  .topbar { padding: 12px 16px; }
  .page-footer { padding: 16px; flex-direction: column; text-align: center; }
}

/* ── Public Page Layout ── */
.public-nav { background: var(--card-bg); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border);
  padding: 16px 0; position: sticky; top: 0; z-index: 100; }
.public-nav .container { max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; }
.public-nav .brand { font-size: 1.3rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.public-nav .brand span { color: var(--primary); }
.public-nav .nav-actions { display: flex; align-items: center; gap: 12px; }

/* ── Hero ── */
.hero { min-height: 85vh; display: flex; align-items: center; padding: 60px 0;
  background: linear-gradient(135deg, var(--surface) 0%, var(--primary-light) 100%); }
.hero .container { max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 60px; align-items: center; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
  background: var(--primary-light); color: var(--primary-dark); border-radius: var(--radius-pill);
  font-size: 0.85rem; font-weight: 600; margin-bottom: 20px; }
.hero h1 { font-size: 3.2rem; font-weight: 800; line-height: 1.15; margin-bottom: 20px; color: var(--text); }
.hero h1 span { color: var(--primary); }
.hero p { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 36px; line-height: 1.7; }
.hero-actions { display: flex; gap: 16px; flex-wrap: wrap; }
.hero-trust { display: flex; gap: 24px; margin-top: 36px; }
.hero-trust span { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-muted); }
.hero-trust i { color: var(--success); }
.hero-img { width: 100%; height: 480px; object-fit: cover; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); }
@media (max-width: 768px) {
  .hero .container { grid-template-columns: 1fr; text-align: center; }
  .hero h1 { font-size: 2.2rem; }
  .hero-actions { justify-content: center; }
  .hero-trust { justify-content: center; }
  .hero-img { height: 280px; }
}

/* ── Features ── */
.features { padding: 80px 0; }
.features .container { max-width: 1200px; margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card { text-align: center; padding: 40px 24px; }
.feature-card:hover { transform: translateY(-6px); }
.feature-icon { width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
  background: var(--primary-light); color: var(--primary); }
.feature-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; }
@media (max-width: 768px) { .features .container { grid-template-columns: 1fr; } }

/* ── Auth Pages ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; background: linear-gradient(135deg, var(--surface), var(--primary-light)); }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 580px; }
.auth-card .card-body { padding: 40px; }
.auth-title { text-align: center; margin-bottom: 32px; }
.auth-title h2 { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.auth-title p { color: var(--text-muted); font-size: 0.9rem; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { font-weight: 600; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; color: var(--text-muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Grid Utilities ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
@media (min-width: 769px) and (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tab { flex: 1; padding: 10px 16px; text-align: center; border-radius: 8px; font-weight: 600; font-size: 0.85rem;
  cursor: pointer; border: none; background: transparent; color: var(--text-muted); transition: var(--transition); }
.tab.active { background: #fff; color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.tab.danger { color: var(--danger); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Utilities ── */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-white { color: #fff; }
.text-sm { font-size: 0.8rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.3rem; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.p-2 { padding: 16px; } .p-3 { padding: 24px; }
.d-flex { display: flex; } .align-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.flex-wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius); width: 100%; max-width: 500px;
  box-shadow: var(--shadow-lg); animation: modalIn 0.3s ease; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 12px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ── Animations ── */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeInUp 0.5s ease forwards; }
.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.2s; }
.animate-in:nth-child(4) { animation-delay: 0.3s; }

/* ── Lang Toggle ── */
.lang-toggle { padding: 6px 14px; border-radius: var(--radius-pill); font-size: 0.8rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); cursor: pointer; transition: var(--transition); }
.lang-toggle:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ── Public Footer ── */
.public-footer { background: var(--sidebar-bg); color: var(--sidebar-text); padding: 32px 0; margin-top: 80px; }
.public-footer .container { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.public-footer .brand { font-weight: 700; color: #fff; font-size: 1.05rem; }
.public-footer small { font-size: 0.8rem; }
