/* ==========================================
   OnPart — Global Styles
   ========================================== */

:root {
  --primary:       #1d4ed8;
  --primary-dark:  #1e3a8a;
  --primary-darker:#172554;
  --dark:          #0f172a;
  --success:       #16a34a;
  --warning:       #d97706;
  --danger:        #dc2626;
  --purple:        #7c3aed;
  --teal:          #0f766e;

  --bg:            #f3f4f6;
  --card:          #ffffff;
  --border:        #e5e7eb;
  --border-light:  #f0f0f0;

  --text:          #111827;
  --text-muted:    #6b7280;
  --text-light:    #9ca3af;

  --radius-sm:     8px;
  --radius:        12px;
  --radius-lg:     16px;
  --radius-xl:     20px;

  --shadow-sm:     0 1px 3px rgba(0,0,0,.06);
  --shadow:        0 1px 6px rgba(0,0,0,.08);
  --shadow-lg:     0 8px 32px rgba(0,0,0,.12);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 10px 20px; border-radius: var(--radius); border: none; font-size: 13.5px; font-weight: 700; cursor: pointer; transition: all .18s; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: #eff6ff; }
.btn-ghost    { background: #f3f4f6; color: #555; border: none; }
.btn-sm       { padding: 7px 14px; font-size: 12.5px; }
.btn-lg       { padding: 13px 28px; font-size: 15px; }
.btn-full     { width: 100%; justify-content: center; }

/* ── Badges ── */
.badge { display: inline-block; border-radius: 6px; padding: 3px 9px; font-size: 11px; font-weight: 600; }
.badge-blue   { background: #dbeafe; color: var(--primary); }
.badge-green  { background: #dcfce7; color: var(--success); }
.badge-amber  { background: #fef3c7; color: var(--warning); }
.badge-red    { background: #fee2e2; color: var(--danger); }
.badge-purple { background: #f5f3ff; color: var(--purple); }
.badge-gray   { background: #f3f4f6; color: #555; }
.badge-teal   { background: #f0fdfa; color: var(--teal); }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-light); }
.card-title { font-size: 14px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 7px; }
.card-title i { color: var(--primary); }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 12.5px; font-weight: 600; color: #444; }
.form-control {
  background: #f8fafc;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border .2s, box-shadow .2s;
  width: 100%;
}
.form-control:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(29,78,216,.07); }
.form-control::placeholder { color: #bbb; }
.form-select { background: #f8fafc; border: 1.5px solid var(--border); border-radius: var(--radius); padding: 11px 13px; font-size: 13px; color: #333; outline: none; width: 100%; cursor: pointer; }
.form-select:focus { border-color: var(--primary); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { font-size: 11.5px; font-weight: 700; color: #888; text-align: center; padding: 10px 12px; border-bottom: 2px solid var(--border); background: #f8fafc; white-space: nowrap; }
.table td { font-size: 12.5px; color: #333; padding: 11px 12px; border-bottom: 1px solid #f5f5f5; text-align: center; white-space: nowrap; }
.table tbody tr:hover { background: #f9fbff; }
.table th.text-right, .table td.text-right { text-align: right; }

/* ── Toggle ── */
.toggle { width: 42px; height: 24px; border-radius: 12px; cursor: pointer; position: relative; transition: background .2s; flex-shrink: 0; }
.toggle.on  { background: var(--primary); }
.toggle.off { background: var(--border); }
.toggle-thumb { width: 20px; height: 20px; background: #fff; border-radius: 50%; position: absolute; top: 2px; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle.on  .toggle-thumb { left: 20px; }
.toggle.off .toggle-thumb { left: 2px; }

/* ── Pagination ── */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-top: 1px solid var(--border-light); }
.pager-info { font-size: 12.5px; color: var(--text-light); }
.pager-btns { display: flex; gap: 6px; }
.pager-btn { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 7px; background: #fff; cursor: pointer; font-size: 12.5px; color: #555; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.pager-btn:hover, .pager-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Upload Zone ── */
.upload-zone { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; transition: all .2s; background: #fafbfc; }
.upload-zone:hover { border-color: var(--primary); background: #eff6ff; }
.upload-zone.uploaded { border-color: var(--success); background: #f0fdf4; }
.upload-zone i { font-size: 30px; color: #bbb; display: block; margin-bottom: 8px; }
.upload-zone span { font-size: 12.5px; color: #aaa; }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 18px; max-height: 90vh; overflow-y: auto; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--border-light); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; z-index: 5; }
.modal-title { font-size: 16px; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 8px; }
.modal-title i { color: var(--primary); }
.modal-close { width: 32px; height: 32px; background: #f3f4f6; border: none; border-radius: 8px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; color: #666; }
.modal-body { padding: 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border-light); display: flex; gap: 10px; position: sticky; bottom: 0; background: #fff; }

/* ── Utilities ── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.fw-bold { font-weight: 700; }
.fw-black { font-weight: 900; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.p-0  { padding: 0; }
.w-100 { width: 100%; }

/* ── Animations ── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.animate-fade-up { animation: fadeUp 0.4s ease; }
.animate-fade-in { animation: fadeIn 0.3s ease; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .card-body { padding: 16px; }
}
@media (min-width: 769px) {
  .hide-desktop { display: none !important; }
}

/* ═══ Mobile Responsive ═══ */
@media (max-width: 768px) {
  /* Tables */
  .tbl { display: block; overflow-x: auto; white-space: nowrap; }
  .tbl thead { display: none; }
  .tbl tbody tr { display: block; border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 10px; padding: 12px; }
  .tbl tbody td { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border: none; white-space: normal; font-size: 13px; }
  .tbl tbody td::before { content: attr(data-label); font-weight: 700; color: #888; font-size: 11px; margin-left: 8px; }

  /* Stats grid */
  .stats { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .kpis { grid-template-columns: repeat(2, 1fr) !important; }
  .grid2, .grid3 { grid-template-columns: 1fr !important; }
  .fin-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Cards */
  .content { padding: 12px !important; }
  .card { padding: 14px !important; }

  /* Topbar */
  .topbar { padding: 0 12px; }
  .topbar-right .search-box { display: none; }

  /* Modal */
  .modal { width: 95vw !important; margin: 10px; }
  .form-grid { grid-template-columns: 1fr !important; }
  .info-grid { grid-template-columns: 1fr !important; }

  /* Toolbar */
  .toolbar { flex-wrap: wrap; gap: 8px; }
  .toolbar .fi-input { min-width: 100% !important; }
  .tc-actions { flex-wrap: wrap; }

  /* Item rows */
  .item-row { grid-template-columns: 1fr !important; gap: 6px !important; }

  /* Buttons */
  .btn-prim, .btn-sec { padding: 9px 14px; font-size: 13px; }
}

@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr 1fr !important; }
  .modal { width: 98vw !important; }
  .pager-btns { gap: 4px; }
  .pg { width: 26px; height: 26px; font-size: 11px; }
}

/* Mobile sidebar toggle */
.mob-menu-btn {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(29,78,216,.4);
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .mob-menu-btn { display: flex; }
}

/* Shared accessibility and interaction states */
:focus-visible {
  outline: 3px solid rgba(29, 78, 216, .35);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed !important;
  opacity: .55;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
