/* مسیر: public/assets/css/ui.css */
/* ==========================================================================
   ui.css — اجزای عمومی و قابل‌استفاده‌ی مجدد: دکمه‌ها، پیام فلش، مودال، جدول، صفحه‌بندی
   (بارگذاری در layouts/app.php و layouts/auth.php؛ صفحه‌های جدید همین کلاس‌ها را استفاده کنند)
   ========================================================================== */
:root {
  --warn: #b26a00;
  --warn-bg: #fff3dd;
}

/* ---------- دکمه‌ها ---------- */
.btn-light { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn-light:hover { background: var(--bg); }
.btn-ghost-dark { background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn-ghost-dark:hover { color: var(--text); background: var(--bg); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #962a22; }
.btn-warn { background: #d98300; }
.btn-warn:hover { background: #b26a00; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #17613a; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 0; font: inherit; font-size: 13px; color: var(--blue); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn .icon { width: 15px; height: 15px; }

.icon-btn {
  width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--muted); cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.icon-btn .icon { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--blue); border-color: var(--blue); background: var(--info-bg); }
.icon-btn.is-warn:hover { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.icon-btn.is-ok:hover { color: var(--ok); border-color: var(--ok); background: var(--ok-bg); }
.icon-btn.is-danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-bg); }

/* ---------- پیام فلش: کارت وسط صفحه + نوار پیشرفت ---------- */
.flash-layer {
  position: fixed; inset: 0; z-index: 300; padding: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(13, 34, 54, .26); pointer-events: none;
  animation: flashFade .25s ease both;
}
.flash-layer.is-leaving { animation: flashFadeOut .3s ease forwards; }
.flash-card {
  position: relative; overflow: hidden; width: min(390px, 100%); pointer-events: auto; cursor: pointer;
  background: #fff; border-radius: 20px; padding: 28px 26px 32px; text-align: center;
  box-shadow: 0 30px 70px rgba(13, 34, 54, .38);
  animation: flashPop .45s cubic-bezier(.2, 1.15, .4, 1) both;
}
.flash-card.is-leaving { animation: flashOut .3s ease forwards; }
.flash-icon {
  width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  animation: flashIcon .6s cubic-bezier(.2, 1.4, .4, 1) .12s both;
}
.flash-icon .icon { width: 36px; height: 36px; stroke-width: 2.2; }
.flash-title { font-size: 17px; font-weight: 800; margin-bottom: 4px; }
.flash-text { color: var(--muted); font-size: 14px; line-height: 1.9; }
.flash-list { list-style: none; margin: 8px 0 0; padding: 0; text-align: right; color: var(--muted); font-size: 14px; }
.flash-list li { position: relative; padding: 3px 18px 3px 0; }
.flash-list li::before { content: ""; position: absolute; right: 2px; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.flash-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: rgba(13, 34, 54, .08); }
.flash-progress span { display: block; height: 100%; transform-origin: right center; animation: flashBar 2s linear forwards; }
.flash-success .flash-icon { background: var(--ok-bg); color: var(--ok); }
.flash-success .flash-progress span { background: var(--ok); }
.flash-error .flash-icon { background: var(--danger-bg); color: var(--danger); }
.flash-error .flash-progress span { background: var(--danger); }
.flash-info .flash-icon { background: var(--info-bg); color: var(--blue); }
.flash-info .flash-progress span { background: var(--blue); }

@keyframes flashFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes flashFadeOut { to { opacity: 0; } }
@keyframes flashPop { from { opacity: 0; transform: translateY(18px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes flashOut { to { opacity: 0; transform: translateY(-10px) scale(.96); } }
@keyframes flashIcon { from { transform: scale(.3) rotate(-30deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flashBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- مودال (<dialog>) ---------- */
body.modal-open { overflow: hidden; }
.modal {
  padding: 0; border: 0; border-radius: 18px; background: #fff; color: var(--text); font: inherit;
  width: min(540px, calc(100% - 28px)); max-height: calc(100vh - 28px); overflow: hidden;
  box-shadow: 0 40px 90px rgba(13, 34, 54, .5);
}
.modal-sm { width: min(430px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(13, 34, 54, .62); backdrop-filter: blur(3px); }
.modal[open] { display: flex; flex-direction: column; animation: modalIn .26s cubic-bezier(.2, .9, .3, 1.1) both; }
.modal[open]::backdrop { animation: flashFade .2s ease both; }
.modal > form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 28px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 24px; border-top: 4px solid var(--blue); border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-x { display: flex; padding: 6px; border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; }
.modal-x:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 22px 24px 8px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px;
  border-top: 1px solid var(--line); background: #f8fafc;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(.95); } to { opacity: 1; transform: none; } }

.confirm-body { padding: 30px 26px 22px; text-align: center; }
.confirm-icon {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--warn-bg); color: var(--warn);
}
.confirm-icon .icon { width: 32px; height: 32px; }
.confirm-icon.is-danger { background: var(--danger-bg); color: var(--danger); }
.confirm-icon.is-success { background: var(--ok-bg); color: var(--ok); }
.confirm-body h3 { margin-bottom: 8px; font-size: 18px; }
.confirm-body p { color: var(--muted); line-height: 1.9; }

/* ---------- فرم‌های مودال ---------- */
.hint-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 6px; }
.hint-row .hint { margin: 0; }
.perm-fieldset { margin: 4px 0 14px; padding: 14px 16px 16px; border: 1px solid var(--line); border-radius: 12px; }
.perm-fieldset legend { padding: 0 8px; font-weight: 700; font-size: 14px; }
.perm-fieldset .hint { margin: 0 0 10px; }
.perm-grid { display: grid; gap: 10px; }
.check-card {
  position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer; transition: border-color .15s, background .15s;
}
.check-card input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 22px; height: 22px; flex: none; margin-top: 2px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #b8c6d3; border-radius: 6px; color: transparent; transition: all .15s;
}
.check-box .icon { width: 14px; height: 14px; stroke-width: 3.5; }
.check-card input:checked ~ .check-box { background: var(--blue); border-color: var(--blue); color: #fff; }
.check-card input:checked ~ .check-text strong { color: var(--blue-dark); }
.check-card:hover { border-color: #9cc4e0; }
.check-card:has(input:checked) { border-color: var(--blue); background: var(--info-bg); }
.check-card input:focus-visible ~ .check-box { outline: 3px solid rgba(0, 116, 187, .45); outline-offset: 2px; }
.check-text { display: flex; flex-direction: column; line-height: 1.6; }
.check-text small { color: var(--muted); font-size: 12px; }

/* ---------- جدول داده، وضعیت، چیپ ---------- */
.table-card { padding: 0; overflow: hidden; }
.data-table th { background: #f7f9fb; font-size: 12.5px; padding: 12px 14px; }
.data-table td { padding: 12px 14px; vertical-align: middle; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: #f6fafd; }
.col-actions { width: 1%; }
.row-actions { display: flex; gap: 6px; }
.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--line); font-size: 13px;
}
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-on { background: var(--ok-bg); color: var(--ok); }
.status-off { background: #eef1f4; color: #66727f; }
.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--info-bg); color: var(--blue-dark); font-size: 12px; font-weight: 600; }

.empty-state { padding: 54px 20px; text-align: center; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 50%; background: var(--info-bg); color: var(--blue); display: flex; align-items: center; justify-content: center; }
.empty-icon .icon { width: 30px; height: 30px; }
.empty-state h3 { margin-bottom: 4px; }

/* ---------- صفحه‌بندی ---------- */
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pager-btn {
  min-width: 34px; height: 34px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); text-decoration: none; font-size: 13px;
}
.pager-btn .icon { width: 15px; height: 15px; }
a.pager-btn:hover { border-color: var(--blue); color: var(--blue); }
.pager-btn.is-active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.pager-btn.is-disabled { opacity: .45; }
.pager-gap { color: var(--muted); padding: 0 2px; }

@media (max-width: 600px) {
  .modal-head, .modal-body, .modal-foot { padding-left: 16px; padding-right: 16px; }
  .pager-btn span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .flash-card, .flash-icon, .flash-layer, .modal[open], .modal[open]::backdrop { animation: none !important; }
}

/* ---------- لیست به‌صورت «کارت» در موبایل ----------
   استفاده در هر صفحه‌ی جدید: کلاس table-cards روی <table class="data-table table-cards">
   و data-label="عنوان ستون" روی هر <td>. سلول‌های خاص:
     td.td-primary  عنوان کارت (بالا، بدون برچسب)    td.td-status  نشان وضعیت (گوشه‌ی بالای کارت)
     td.td-actions  دکمه‌ها (پایین کارت؛ داخل .btn-label متن دکمه فقط در موبایل دیده می‌شود)
   در دسکتاپ هیچ تغییری نمی‌کند. */
.btn-label { display: none; }

@media (max-width: 768px) {
  .table-card { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .table-card .table-wrap { overflow: visible; }

  .table-cards, .table-cards tbody { display: block; }
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }   /* فقط برای صفحه‌خوان */
  .table-cards tbody tr {
    position: relative; display: block; margin-bottom: 12px; padding: 4px 16px 14px;
    background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 3px rgba(13, 34, 54, .06);
  }
  .table-cards tbody tr:hover { background: #fff; }
  .table-cards td {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 0; border-bottom: 1px dashed var(--line); white-space: normal; text-align: right;
  }
  .table-cards td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 13px; }
  .table-cards td.ltr { direction: rtl; unicode-bidi: normal; }   /* ترتیب برچسب/مقدار برعکس نشود */

  .table-cards td.td-primary { justify-content: flex-start; padding: 14px 0 12px 96px; border-bottom: 1px solid var(--line); }
  .table-cards td.td-primary strong { font-size: 16px; }
  .table-cards td.td-status { position: absolute; top: 18px; left: 16px; padding: 0; border: 0; }
  .table-cards td.td-status::before { display: none; }
  .table-cards td.td-actions { padding: 14px 0 0; border-bottom: 0; }

  .table-cards .row-actions { width: 100%; gap: 8px; }
  .table-cards .icon-btn { flex: 1; width: auto; height: 42px; gap: 6px; font: inherit; font-size: 13px; }
  .table-cards .btn-label { display: inline; }

  .table-card .table-foot { flex-direction: column; align-items: stretch; gap: 10px; padding: 6px 0 0; border-top: 0; text-align: center; }
  .table-card .pager { justify-content: center; }
  .table-card .empty-state { background: #fff; border: 1px solid var(--line); border-radius: 14px; }
}
