/* TAQYEEM design system — light mode only, RTL/LTR via logical properties. */
:root {
  --plum: #211A35;
  --violet: #7257E8;
  --violet-hover: #5D43CE;
  --lavender: #B8A5FF;
  --lavender-white: #F5F1FA;
  --violet-soft: #F0EBFF;
  --coral: #FF8066;

  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F5F1FA;
  --text: #211A35;
  --text-2: #746D82;
  --text-3: #A59FB0;
  --border: #E8E2F1;
  --border-strong: #D9D0E8;

  --success: #12A150;
  --success-bg: #E8F7EE;
  --danger: #DC3545;
  --danger-bg: #FDECEE;
  --warning: #E07B12;
  --warning-bg: #FFF3E3;
  --info: #6B6880;
  --info-bg: #F1F0F4;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(33, 26, 53, .04);
  --shadow: 0 1px 3px rgba(33, 26, 53, .05), 0 6px 18px -8px rgba(33, 26, 53, .08);
  --shadow-lg: 0 20px 50px -20px rgba(33, 26, 53, .25);
  --ring: 0 0 0 3px rgba(114, 87, 232, .22);

  --font: "Plus Jakarta Sans", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Plus Jakarta Sans", system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html[lang="ar"] { --font: var(--font-ar); }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.6; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
svg.i { width: 18px; height: 18px; flex: none; }
svg.i.inline { display: inline-block; width: 1em; height: 1em; vertical-align: -.15em; margin-inline-end: 4px; }
.badge svg.i { width: 13px; height: 13px; }
a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-hover); }
h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.2rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--text-2); }
.text-3 { color: var(--text-3); }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
::selection { background: var(--violet-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; letter-spacing: .02em; }

/* ---------- buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--text); --b-border: var(--border);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--b-border);
  background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), border-color .15s, transform .1s, box-shadow .15s;
  text-decoration: none; user-select: none;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--b-fg); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-primary { --b-bg: var(--violet); --b-fg: #fff; --b-border: var(--violet); }
.btn-primary:hover { background: var(--violet-hover); border-color: var(--violet-hover); color: #fff; }
.btn-soft { --b-bg: var(--violet-soft); --b-fg: var(--violet-hover); --b-border: transparent; }
.btn-soft:hover { background: #E6DEFF; border-color: transparent; }
.btn-dark { --b-bg: var(--plum); --b-fg: #fff; --b-border: var(--plum); }
.btn-dark:hover { background: #2f2649; color: #fff; }
.btn-danger { --b-bg: var(--danger); --b-fg: #fff; --b-border: var(--danger); }
.btn-danger:hover { background: #c22d3c; color: #fff; }
.btn-ghost { --b-bg: transparent; --b-border: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: 0 24px; font-size: 16px; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: .6; pointer-events: none; }
.btn.is-loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-inline-end-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-2); }
.field .error-text { font-size: 12px; color: var(--danger); }
.req::after { content: " *"; color: var(--coral); }
.input, .select, .textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); font: inherit; font-size: 14px; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--violet); box-shadow: var(--ring); }
.input:user-invalid, .textarea:user-invalid { border-color: var(--danger); }
.input[readonly] { background: var(--surface-2); }
.select {
  appearance: none; padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23746D82' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center;
}
html[dir="ltr"] .select { background-position: right 12px center; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-start-end-radius: 0; border-end-end-radius: 0; }
.input-group .btn { border-start-start-radius: 0; border-end-start-radius: 0; margin-inline-start: -1px; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--violet); margin: 0; flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: inset-inline-start .2s var(--ease); }
.switch input:checked { background: var(--violet); }
.switch input:checked::after { inset-inline-start: 19px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px; }

/* ---------- cards / layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 420px) { .grid-4 { grid-template-columns: 1fr; } }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; } .mt-2 { margin-top: 8px; } .mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; }
.center { text-align: center; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-violet { background: var(--violet-soft); color: var(--violet-hover); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-coral { background: #FFEDE8; color: #D9583F; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); font-size: 12px; color: var(--text-2); }

/* ---------- tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 10px 14px; white-space: nowrap; }
.table th:first-child { border-start-start-radius: 10px; border-end-start-radius: 10px; }
.table th:last-child { border-start-end-radius: 10px; border-end-end-radius: 10px; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FCFBFE; }
.table .actions { text-align: end; white-space: nowrap; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--text-2); }
/* Responsive tables become cards on phones */
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border: 1px solid var(--border); border-radius: 14px; padding: 6px 4px; margin-bottom: 10px; background: #fff; }
  .table.responsive td { border: 0; padding: 6px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: end; }
  .table.responsive td::before { content: attr(data-label); color: var(--text-2); font-size: 12px; font-weight: 600; text-align: start; }
  .table.responsive td.actions { justify-content: flex-end; }
  .table.responsive td.actions::before { display: none; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
html[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--plum); color: #fff; box-shadow: var(--shadow-lg); font-size: 14px; animation: toast-in .25s var(--ease); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.toast.success svg { color: #6EE7A0; } .toast.error svg { color: #FF9A88; } .toast.warning svg { color: #FFC56E; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 20px; box-shadow: var(--shadow-lg); width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 32px); color: var(--text); background: #fff; }
dialog.modal.wide { width: min(880px, calc(100% - 24px)); }
dialog.modal::backdrop { background: rgba(33, 26, 53, .45); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: modal-in .2s var(--ease); display: flex; flex-direction: column; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 560px) {
  dialog.modal { width: 100%; max-width: 100%; margin: auto 0 0; border-end-start-radius: 0; border-end-end-radius: 0; max-height: 92dvh; }
}

/* ---------- states ---------- */
.skeleton { background: linear-gradient(90deg, #F3F0F8 25%, #EAE5F3 37%, #F3F0F8 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.sk-line { height: 12px; margin: 8px 0; } .sk-title { height: 20px; width: 40%; margin-bottom: 14px; } .sk-block { height: 90px; }
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 20px; }
.state-icon { width: 64px; height: 64px; border-radius: 20px; background: var(--violet-soft); color: var(--violet); display: grid; place-items: center; margin-bottom: 6px; }
.state-icon svg { width: 30px; height: 30px; }
.state.error .state-icon { background: var(--danger-bg); color: var(--danger); }
.state.success .state-icon { background: var(--success-bg); color: var(--success); }
.state h3 { margin: 0; }
.state p { max-width: 420px; color: var(--text-2); margin: 0 0 8px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 14px; background: var(--info-bg); color: var(--text); border: 1px solid transparent; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.alert-violet { background: var(--violet-soft); } .alert-violet svg { color: var(--violet); }
.alert-warning { background: var(--warning-bg); } .alert-warning svg { color: var(--warning); }
.alert-danger { background: var(--danger-bg); } .alert-danger svg { color: var(--danger); }
.alert-success { background: var(--success-bg); } .alert-success svg { color: var(--success); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--violet-soft); border-top-color: var(--violet); animation: spin .8s linear infinite; }
.page-loader { min-height: 50vh; display: grid; place-items: center; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--plum); font-weight: 800; letter-spacing: .06em; font-family: "Plus Jakarta Sans", sans-serif; }
.brand img { width: 34px; height: 34px; }
.brand-name { font-size: 18px; line-height: 1; }
.brand-sub { display: block; font-family: var(--font-ar); font-size: 12px; color: var(--violet); letter-spacing: 0; font-weight: 700; margin-top: 3px; }
.dot-coral { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }

/* ---------- misc ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; font-weight: 600; font-size: 14px; color: var(--text-2); border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; font-family: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--violet); border-bottom-color: var(--violet); }
.progress { height: 8px; border-radius: 99px; background: var(--violet-soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--violet); border-radius: inherit; transition: width .3s var(--ease); }
.kbd { font-family: ui-monospace, monospace; font-size: 12px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
.copy-box { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px dashed var(--lavender); border-radius: 12px; background: var(--violet-soft); }
html[dir="rtl"] .copy-box { padding: 6px 12px 6px 6px; }
.copy-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; direction: ltr; text-align: start; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 4px 0; font-size: 13px; color: var(--text-2); }
.dropdown { position: relative; }
.menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); min-width: 200px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; }
.menu button, .menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: 8px; font: inherit; font-size: 14px; color: var(--text); cursor: pointer; text-align: start; }
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu svg { width: 16px; height: 16px; color: var(--text-2); }
.menu .danger { color: var(--danger); } .menu .danger svg { color: var(--danger); }
.menu hr { margin: 6px 0; }

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