@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-hover: #eef2f7;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --success: #16a34a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Vazirmatn', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79, 70, 229, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(8, 145, 178, 0.08), transparent);
}

a { color: inherit; text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 16rem;
  flex-shrink: 0;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
  border-left: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: .75rem;
  background: linear-gradient(135deg, var(--primary), #0891b2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}

.gradient-text {
  background: linear-gradient(135deg, #4f46e5, #0891b2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-nav { flex: 1; padding: 1rem; overflow-y: auto; }

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: .75rem;
  color: var(--text-muted);
  margin-bottom: .25rem;
  transition: .2s;
  font-size: .875rem;
  font-weight: 500;
}

.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link.active { background: rgba(79,70,229,.12); color: var(--primary); }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.sidebar-footer-box {
  background: var(--surface-hover);
  border-radius: .75rem;
  padding: 1rem;
  font-size: .75rem;
  color: var(--text-muted);
}
.logout-link {
  display: block;
  margin-top: .5rem;
  color: var(--danger);
  font-size: .8rem;
}

/* Mobile top bar */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(15,23,42,.06);
}

.mobile-menu-btn {
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .5rem .75rem;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.4);
  z-index: 39;
}

.sidebar-overlay.show { display: block; }

/* ===== Main ===== */
.main { flex: 1; min-width: 0; overflow: auto; }
.container { max-width: 80rem; margin: 0 auto; padding: 1.5rem 2rem; }

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title { font-size: 1.5rem; font-weight: 700; line-height: 1.4; }
.page-subtitle { font-size: .875rem; color: var(--text-muted); margin-top: .25rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 4px 16px rgba(15,23,42,.05);
  padding: 1.25rem;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .75rem;
}

.stat-value { font-size: 1.875rem; font-weight: 700; margin-top: .5rem; }
.stat-label { font-size: .875rem; color: var(--text-muted); }

.stat-icon {
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  border-radius: .75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

/* ===== Buttons & Forms ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .625rem 1rem;
  border-radius: .75rem;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  transition: .2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.25);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

.btn-danger {
  background: rgba(220,38,38,.1);
  color: var(--danger);
  border: 1px solid rgba(220,38,38,.3);
}

.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: .375rem;
}
.form-label .req { color: var(--danger); margin-right: .25rem; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: .625rem 1rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .875rem;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.form-textarea { resize: vertical; min-height: 5rem; }
.ltr { direction: ltr; text-align: left; }

.alert {
  padding: .75rem 1rem;
  border-radius: .75rem;
  margin-bottom: 1rem;
  font-size: .875rem;
}
.alert-error { background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.3); color: var(--danger); }
.alert-success { background: rgba(22,163,74,.1); border: 1px solid rgba(22,163,74,.3); color: var(--success); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .25rem .625rem;
  border-radius: .5rem;
  font-size: .75rem;
  font-weight: 500;
}
.badge-dot { width: .375rem; height: .375rem; border-radius: 50%; }

.contact-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: var(--surface);
  margin-bottom: .75rem;
  transition: .2s;
}
.contact-item:hover { border-color: #cbd5e1; }

.contact-name { font-size: 1.125rem; font-weight: 700; }
.contact-meta { font-size: .875rem; color: var(--text-muted); margin-top: .25rem; }
.contact-tags { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; align-items: center; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: .75rem; }

.brand-badge {
  background: rgba(79, 70, 229, 0.12);
  color: #4f46e5;
}

.brand-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .5rem;
  max-height: 12rem;
  overflow-y: auto;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: var(--surface-hover);
}

.brand-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .875rem;
  cursor: pointer;
  padding: .35rem .5rem;
  border-radius: .5rem;
}

.brand-check:hover { background: var(--surface); }

.brand-check input { width: 1rem; height: 1rem; cursor: pointer; }

.progress-bar {
  height: .5rem;
  background: var(--surface-hover);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 999px; transition: width .5s; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; min-width: 480px; }
th, td { padding: .75rem; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 500; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card { width: 100%; max-width: 28rem; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15,23,42,.4);
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: 0 25px 50px rgba(15,23,42,.15);
  width: 100%;
  max-width: 42rem;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.modal-body { padding: 1.25rem; }
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: .375rem;
  border-radius: .5rem;
  color: var(--text-muted);
  font-size: 1.25rem;
}
.modal-close:hover { background: var(--surface-hover); }

.hidden { display: none !important; }

.domain-card { position: relative; overflow: hidden; }

.color-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.color-dot {
  width: 2rem;
  height: 2rem;
  border-radius: .5rem;
  border: 2px solid transparent;
  cursor: pointer;
}
.color-dot.selected { outline: 2px solid var(--text); outline-offset: 2px; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .layout { flex-direction: column; }

  .mobile-topbar { display: flex; }

  .sidebar {
    position: fixed;
    top: 0;
    right: -17rem;
    width: 16rem;
    height: 100vh;
    transition: right .3s ease;
    box-shadow: -4px 0 24px rgba(15,23,42,.12);
  }

  .sidebar.open { right: 0; }

  .container { padding: 1rem; }

  .page-title { font-size: 1.2rem; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .filters { grid-template-columns: 1fr; }

  .stat-value { font-size: 1.5rem; }

  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .btn { width: 100%; }

  .brand-checkboxes { grid-template-columns: 1fr; }

  th, td { white-space: normal; }
  table { min-width: 0; }
}

@media (max-width: 480px) {
  .modal { max-height: 95vh; border-radius: .75rem; }
  .modal-body { padding: 1rem; }
}
