/* =============================================
   NAQLA v10 — Unified Design System
   Arabic-first RTL | Modern Saudi Fintech
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  /* Core Palette */
  --naqla-ink: #0B1426;
  --naqla-navy: #162444;
  --naqla-blue: #7C3AED;
  --naqla-blue-light: #8B5CF6;
  --naqla-cyan: #06B6D4;
  --naqla-green: #059669;
  --naqla-green-light: #10B981;
  --naqla-amber: #F59E0B;
  --naqla-red: #EF4444;
  --naqla-purple: #6D28D9;

  /* Neutrals */
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Surfaces */
  --surface: #FFFFFF;
  --surface-raised: #FFFFFF;
  --surface-overlay: rgba(11, 20, 38, 0.6);
  --bg-primary: #F8FAFC;
  --bg-secondary: #F1F5F9;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.08), 0 4px 10px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px -8px rgba(0,0,0,0.1);

  /* Spacing Scale */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--gray-800);
  line-height: 1.7;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---- Container ---- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 var(--sp-6); }
.container-narrow { max-width: 960px; margin: 0 auto; padding: 0 var(--sp-6); }

/* =============================================
   HEADER — Sticky glass header
   ============================================= */
.nq-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--gray-200);
  transition: box-shadow var(--duration) var(--ease);
}
.nq-header.scrolled { box-shadow: var(--shadow-md); }
.nq-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 72px; max-width: 1280px; margin: 0 auto; padding: 0 var(--sp-6);
}
.nq-header__logo {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: 1.5rem; font-weight: 700; color: var(--naqla-ink);
}
.nq-header__logo-mark {
  width: 40px; height: 40px; background: transparent;
  border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 1.1rem;
}
.nq-header__nav { display: flex; align-items: center; gap: var(--sp-1); }
.nq-header__nav a {
  padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; color: var(--gray-600);
  transition: all var(--duration) var(--ease);
}
.nq-header__nav a:hover { color: var(--naqla-blue); background: rgba(124,58,237,0.06); }
.nq-header__nav a.active { color: var(--naqla-blue); background: rgba(124,58,237,0.1); font-weight: 600; }
.nq-header__actions { display: flex; align-items: center; gap: var(--sp-3); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5); border-radius: var(--radius-sm); border: none;
  font-weight: 600; font-size: 0.9rem; cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}
.btn-primary {
  background: #7C3AED; color: white;
  box-shadow: 0 2px 8px rgba(124,58,237,0.35);
}
.btn-primary:hover { background: #6D28D9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(124,58,237,0.35); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-outline { background: #F5F3FF; border: 2px solid #7C3AED; color: #6D28D9; font-weight: 600; }
.btn-outline:hover { border-color: #5B21B6; color: #5B21B6; background: #EDE9FE; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-800); }
.btn-success { background: var(--naqla-green); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--naqla-red); color: white; }
.btn-lg { padding: var(--sp-4) var(--sp-8); font-size: 1rem; border-radius: var(--radius-md); }
.btn-sm { padding: var(--sp-2) var(--sp-3); font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--radius-sm); }

/* ---- Cards ---- */
.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200); overflow: hidden;
  transition: all 300ms var(--ease);
}
.card:hover { box-shadow: var(--shadow-lg); border-color: var(--gray-300); transform: translateY(-2px); }
.card__body { padding: var(--sp-5); }
.card__footer { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--gray-100); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 3px 10px; border-radius: var(--radius-full);
  font-size: 0.75rem; font-weight: 600;
}
.badge-blue { background: rgba(124,58,237,0.1); color: var(--naqla-blue); }
.badge-green { background: rgba(5,150,105,0.1); color: var(--naqla-green); }
.badge-amber { background: rgba(245,158,11,0.1); color: #B45309; }
.badge-red { background: rgba(239,68,68,0.1); color: var(--naqla-red); }
.badge-purple { background: rgba(124,58,237,0.1); color: var(--naqla-purple); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-verified {
  background: linear-gradient(135deg, rgba(5,150,105,0.12), rgba(6,182,212,0.12));
  color: var(--naqla-green); border: 1px solid rgba(5,150,105,0.2);
}

/* ---- Form Controls ---- */
.form-group { margin-bottom: var(--sp-5); }
.form-label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--gray-700); margin-bottom: var(--sp-2); }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: var(--sp-3) var(--sp-4);
  border: 1.5px solid var(--gray-300); border-radius: var(--radius-md);
  background: white; color: var(--gray-800);
  transition: all var(--duration) var(--ease);
  font-size: 0.95rem;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--naqla-blue);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.form-textarea { min-height: 120px; resize: vertical; }
.form-hint { font-size: 0.8rem; color: var(--gray-500); margin-top: var(--sp-1); }

/* ---- Stats ---- */
.stat-card {
  background: white; border-radius: var(--radius-lg); padding: var(--sp-6);
  border: 1px solid var(--gray-200);
}
.stat-card__value { font-size: 2rem; font-weight: 700; color: var(--naqla-ink); line-height: 1.2; }
.stat-card__label { font-size: 0.85rem; color: var(--gray-500); margin-top: var(--sp-1); }

/* ---- Tables ---- */
.nq-table { width: 100%; border-collapse: collapse; }
.nq-table th {
  text-align: right; padding: var(--sp-3) var(--sp-4);
  font-size: 0.8rem; font-weight: 600; color: var(--gray-500);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200); background: var(--gray-50);
}
.nq-table td {
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}
.nq-table tr:hover td { background: var(--gray-50); }

/* ---- Tags / Chips ---- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 0.8rem; font-weight: 500;
  background: var(--gray-100); color: var(--gray-600);
}

/* ---- Progress Bar ---- */
.progress { height: 6px; background: var(--gray-200); border-radius: var(--radius-full); overflow: hidden; }
.progress__bar { height: 100%; border-radius: var(--radius-full); transition: width 500ms var(--ease); }
.progress__bar--blue { background: transparent; }
.progress__bar--green { background: var(--naqla-green); }

/* ---- Empty States ---- */
.empty-state {
  text-align: center; padding: var(--sp-16) var(--sp-8);
  color: var(--gray-400);
}
.empty-state__icon { font-size: 3rem; margin-bottom: var(--sp-4); }
.empty-state__title { font-size: 1.1rem; font-weight: 600; color: var(--gray-600); margin-bottom: var(--sp-2); }

/* ---- Divider ---- */
.divider { height: 1px; background: var(--gray-200); margin: var(--sp-6) 0; }

/* ---- Section Headers ---- */
.section-header { margin-bottom: var(--sp-8); }
.section-header__title { font-size: 1.75rem; font-weight: 700; color: var(--naqla-ink); }
.section-header__subtitle { font-size: 1rem; color: var(--gray-500); margin-top: var(--sp-2); }

/* ---- Footer ---- */
.nq-footer {
  background: var(--naqla-ink); color: var(--gray-400); padding: var(--sp-16) 0 var(--sp-8);
  margin-top: var(--sp-20);
}
.nq-footer__grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: var(--sp-8); margin-bottom: var(--sp-12); }
.nq-footer__brand h3 { color: white; font-size: 1.4rem; margin-bottom: var(--sp-3); }
.nq-footer__brand p { font-size: 0.9rem; line-height: 1.8; }
.nq-footer__col h4 { color: white; font-size: 0.95rem; margin-bottom: var(--sp-4); }
.nq-footer__col a { display: block; color: var(--gray-400); font-size: 0.9rem; padding: var(--sp-1) 0; transition: color var(--duration); }
.nq-footer__col a:hover { color: white; }
.nq-footer__bottom { border-top: 1px solid rgba(255,255,255,0.08); padding-top: var(--sp-6); display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
@media (max-width: 768px) {
  .nq-footer__grid { grid-template-columns: 1fr 1fr; gap: var(--sp-8); }
  .nq-footer__bottom { flex-direction: column; gap: var(--sp-3); }
}

/* ---- Utility ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-gray { color: var(--gray-500); }
.text-blue { color: var(--naqla-blue); }
.text-green { color: var(--naqla-green); }
.text-bold { font-weight: 700; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.p-4 { padding: var(--sp-4); } .p-6 { padding: var(--sp-6); }

/* ---- Animations ---- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.animate-fadeUp { animation: fadeUp 600ms var(--ease) both; }
.animate-slideIn { animation: slideIn 500ms var(--ease) both; }
.delay-1 { animation-delay: 100ms; }
.delay-2 { animation-delay: 200ms; }
.delay-3 { animation-delay: 300ms; }
.delay-4 { animation-delay: 400ms; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .nq-header__nav { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .nq-header__inner { height: 60px; }
  .container { padding: 0 var(--sp-4); }
}

/* ---- WhatsApp Float ---- */
.whatsapp-float {
  position: fixed; bottom: 24px; left: 24px; z-index: 90;
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; color: white; font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(37,211,102,0.4);
  transition: transform 200ms var(--ease);
}
.whatsapp-float:hover { transform: scale(1.1); }

/* ==========================================
   PWA Mobile Optimizations
   ========================================== */

/* Safe area for notched phones */
body { padding-top: env(safe-area-inset-top); }

/* Touch targets minimum 44px */
a, button, input[type="submit"], .svc-card .action-btn {
  min-height: 44px;
}

/* Smooth scrolling */
html { scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
  
  /* Stack grids on mobile */
  .svc-grid { grid-template-columns: 1fr !important; }
  
  /* Full-width cards */
  .svc-card, .tier-card { min-width: unset !important; }
  
  /* Responsive tables */
  .comparison-table { font-size: .75rem; }
  .comparison-table td, .comparison-table th { padding: 8px 4px; }
  
  /* Bottom nav spacing */
  footer.nq-footer { margin-bottom: 70px; }
  
  /* Pull-to-refresh visual */
  body::before {
    content: '';
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    border: 3px solid #7C3AED;
    border-top-color: transparent;
    border-radius: 50%;
    z-index: 99999;
    opacity: 0;
    transition: opacity .3s, top .3s;
    pointer-events: none;
  }
  
  /* Install banner space */
  body.pwa-banner-visible { padding-bottom: 100px; }
}

/* Standalone mode (when installed as app) */
@media (display-mode: standalone) {
  /* Hide browser-specific UI hints */
  .browser-only { display: none !important; }
  
  /* Extra top padding for status bar */
  .nq-header { padding-top: env(safe-area-inset-top, 20px); }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #0B1426;
    --bg-secondary: #1E1045;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --border: #334155;
  }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
