/**
 * Bazyaft Visual Design Library — Global Styles
 * RTL-first, Persian typography, mobile-first responsive baseline
 */

/* ───────────────────────── FONT LOADING ───────────────────────── */
/* Load Vazirmatn from Google Fonts CDN (fallback to system fonts if offline) */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

@font-face {
  font-family: 'Vazirmatn';
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  src: local('Vazirmatn'),
       url('../assets/fonts/Vazirmatn-Regular.woff2') format('woff2');
}

/* ───────────────────────── RESET & BASE ───────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  direction: rtl;
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-fa);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-normal);
  color: var(--text-main);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Numbers in Persian UIs should use system locale glyphs */
/* Input numbers remain Latin for keyboard usability */
p, span, td, th, li, label, h1, h2, h3, h4, h5, h6 {
  font-feature-settings: "ss01" 1; /* Vazirmatn alternate digit forms */
}

/* ───────────────────────── TYPOGRAPHY ───────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--text-main);
}
h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p { margin-bottom: var(--space-4); }
p:last-child { margin-bottom: 0; }

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

/* ───────────────────────── LAYOUT UTILITIES ───────────────────────── */
.container {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.flex-wrap { flex-wrap: wrap; }

.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); }

/* Spacing Utilities */
.p-1 { padding: var(--space-1); }
.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.px-2 { padding-inline: var(--space-2); }
.px-3 { padding-inline: var(--space-3); }
.px-4 { padding-inline: var(--space-4); }
.px-6 { padding-inline: var(--space-6); }
.py-2 { padding-block: var(--space-2); }
.py-3 { padding-block: var(--space-3); }
.py-4 { padding-block: var(--space-4); }

.m-0 { margin: 0; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.ms-2 { margin-inline-start: var(--space-2); }
.ms-auto { margin-inline-start: auto; }
.me-2 { margin-inline-end: var(--space-2); }

/* Text Utilities */
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.font-medium { font-weight: var(--font-weight-medium); }
.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-primary { color: var(--color-primary-700); }
.text-danger { color: var(--color-danger-base); }
.text-success { color: var(--color-success-base); }
.text-warning { color: var(--color-amber-500); }
.text-center { text-align: center; }
.text-start { text-align: start; }
.text-end { text-align: end; }

/* Visibility */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────────────────────── SCROLLBAR ───────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-surface-subtle); }
::-webkit-scrollbar-thumb { background: var(--color-neutral-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-neutral-400); }

/* ───────────────────────── FOCUS RING ───────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary-700);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ───────────────────────── DEMO BANNER ───────────────────────── */
.demo-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-toast);
  background: var(--color-neutral-900);
  color: #fbbf24;
  text-align: center;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.08em;
  padding: 5px var(--space-4);
  pointer-events: none;
  user-select: none;
}

/* ───────────────────────── SKELETON LOADING ───────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--color-neutral-200) 25%, var(--color-neutral-100) 50%, var(--color-neutral-200) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ───────────────────────── STATUS BADGES ───────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
  white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success-text); border: 1px solid var(--color-success-border); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning-text); border: 1px solid var(--color-warning-border); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text);  border: 1px solid var(--color-danger-border); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info-text);    border: 1px solid var(--color-info-border); }
.badge-neutral { background: var(--color-neutral-100); color: var(--color-neutral-700); border: 1px solid var(--color-neutral-200); }
.badge-primary { background: var(--color-primary-100); color: var(--color-primary-800); border: 1px solid var(--color-primary-200); }

/* ───────────────────────── DOMAIN BADGES ───────────────────────── */
.domain-citizen     { background: rgba(16,185,129,0.1); color: #065f46; border: 1px solid #a7f3d0; }
.domain-driver      { background: rgba(245,158,11,0.1); color: #92400e; border: 1px solid #fde68a; }
.domain-operations  { background: rgba(59,130,246,0.1); color: #1e40af; border: 1px solid #bfdbfe; }
.domain-warehouse   { background: rgba(139,92,246,0.1); color: #4c1d95; border: 1px solid #ddd6fe; }
.domain-finance     { background: rgba(13,148,136,0.1); color: #134e4a; border: 1px solid #99f6e4; }
.domain-employees   { background: rgba(236,72,153,0.1); color: #831843; border: 1px solid #fbcfe8; }
.domain-organization{ background: rgba(99,102,241,0.1); color: #312e81; border: 1px solid #c7d2fe; }
.domain-admin       { background: rgba(15,23,42,0.08);  color: #0f172a; border: 1px solid #e2e8f0; }

/* ───────────────────────── VERSION TAG ───────────────────────── */
.tag-v1     { background: var(--color-primary-100); color: var(--color-primary-800); border-radius: 4px; padding: 1px 6px; font-size: 0.65rem; font-weight: 700; }
.tag-future { background: var(--color-neutral-100); color: var(--color-neutral-500); border-radius: 4px; padding: 1px 6px; font-size: 0.65rem; font-weight: 600; }

/* ───────────────────────── TOAST NOTIFICATIONS ───────────────────────── */
#toast-container {
  position: fixed;
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 2rem);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-neutral-900);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  animation: toast-in 0.25s ease;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.toast.success { background: var(--color-success-text); border-right: 4px solid var(--color-success-base); }
.toast.error   { background: var(--color-danger-text);  border-right: 4px solid var(--color-danger-base); }
.toast.warning { background: var(--color-warning-text); border-right: 4px solid var(--color-warning-base); }
.toast.info    { background: var(--color-info-text);    border-right: 4px solid var(--color-info-base); }
@keyframes toast-in {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ───────────────────────── MODAL ───────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modal-in 0.2s ease;
}
@keyframes modal-in {
  from { transform: scale(0.95); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-body { padding: var(--space-6); }
.modal-footer {
  display: flex; gap: var(--space-3); justify-content: flex-end;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

/* ───────────────────────── EMPTY STATE ───────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-4);
  padding: var(--space-16);
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; opacity: 0.4; }
.empty-state-title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); color: var(--text-main); }

/* ───────────────────────── OFFLINE INDICATOR ───────────────────────── */
.offline-bar {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid var(--color-warning-border);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-sm);
}
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-amber-500); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ───────────────────────── SYNC QUEUE INDICATOR ───────────────────────── */
.sync-queue-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  background: var(--color-warning-base);
  color: white;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
}
