/* پنل ادمین - طراحی مدرن با تم روشن/تیره (متغیرها در /css/ui.css) */
* { box-sizing: border-box; }
html { font-size: 112.5%; }
html, body { margin: 0; font-family: var(--font-main); }
input, button, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--color-primary); }
[hidden] { display: none !important; }

/* ---------- ورود ---------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(1200px 600px at 80% -10%, var(--color-primary-soft), transparent 60%), var(--color-bg);
}
.login-box {
  background: var(--color-surface); padding: 34px 30px; border-radius: 20px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 14px;
  animation: ui-pop .6s var(--ease) both;
}
.login-logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 2px; display: block; box-shadow: var(--shadow-md); }
.login-box h1 { margin: 0; text-align: center; font-size: 1.3rem; }
.login-sub { text-align: center; color: var(--color-muted); margin: -8px 0 4px; font-size: .85rem; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: .88rem; color: var(--color-muted); }
label.field > span.hint { font-size: .75rem; opacity: .85; }
input[type=text], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
textarea { resize: vertical; min-height: 80px; }
.form-error { background: var(--color-danger-soft); color: var(--color-danger); padding: 10px 12px; border-radius: 10px; font-size: .88rem; animation: ui-fade-up .3s var(--ease); }
.full-width { width: 100%; }

/* ---------- قالب کلی ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; background: var(--color-sidebar-bg); color: #d7dde3; padding: 18px 12px;
  display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow: auto;
  transition: transform var(--t-med) var(--ease);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 16px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 8px; }
.brand-mark { width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0; box-shadow: var(--shadow-md); }
.brand-text { font-family: "Nian", serif; font-size: .95rem; line-height: 1.4; color: #fff; }
.brand-text small { display: block; font-family: "Lotus", sans-serif; opacity: .6; font-size: .72rem; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #c3cbd3;
  text-decoration: none; position: relative; font-size: .93rem;
  transition: background-color var(--t-fast), color var(--t-fast), transform var(--t-fast) var(--ease);
}
.nav-link .ico { width: 22px; text-align: center; font-size: 1.05rem; }
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; transform: translateX(-3px); }
.nav-link.active { background: rgba(255,255,255,.12); color: #fff; }
.nav-link.active::before {
  content: ""; position: absolute; inset-inline-start: -12px; top: 22%; bottom: 22%; width: 4px; border-radius: 4px;
  background: var(--color-accent); animation: ui-fade-in .3s;
}
.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: .82rem; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--color-primary); color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.user-chip small { display: block; opacity: .6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px; padding: 12px 24px; position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--color-bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--color-border);
}
.topbar h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.view { animation: ui-fade-up .45s var(--ease) both; }

/* ---------- کارت‌ها و آمار ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; padding: 18px; box-shadow: var(--shadow-sm); }
.card h3 { margin: 0 0 12px; font-size: 1rem; }
.card-hover { transition: transform var(--t-med) var(--ease), box-shadow var(--t-med); }
.card-hover:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat { display: flex; align-items: center; gap: 14px; }
.stat .ico { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, var(--color-primary-soft), color-mix(in srgb, var(--color-accent) 25%, var(--color-primary-soft))); color: var(--color-primary); flex-shrink: 0; }
.stat .ico .ic { width: 26px; height: 26px; }
.stat .num { white-space: nowrap; font-size: 1.7rem; font-weight: 900; line-height: 1.1; }
.stat .lbl { color: var(--color-muted); font-size: .82rem; }

.bar-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 10px; align-items: center; margin: 9px 0; font-size: .85rem; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--color-surface-2); height: 10px; border-radius: 10px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, var(--color-primary), var(--color-accent)); transition: width 1s var(--ease); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px dashed var(--color-border); display: flex; gap: 10px; justify-content: space-between; align-items: baseline; font-size: .88rem; }
.list-plain li:last-child { border: none; }
.muted { color: var(--color-muted); font-size: .82rem; }

/* ---------- جدول ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar select { width: auto; min-width: 150px; }
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: start; padding: 11px 14px; background: var(--color-surface-2); color: var(--color-muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
table.data td { padding: 11px 14px; border-top: 1px solid var(--color-border); vertical-align: middle; }
table.data tbody tr { transition: background-color var(--t-fast); animation: ui-fade-up .4s var(--ease) both; }
table.data tbody tr:hover { background: var(--color-primary-soft); }
table.data tbody tr.selected { background: var(--color-primary-soft); }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--color-muted); font-size: .78rem; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .75rem; background: var(--color-primary-soft); color: var(--color-primary); white-space: nowrap; }
.badge.off { background: var(--color-danger-soft); color: var(--color-danger); }
.badge.gold { background: var(--color-warn-soft); color: var(--color-accent); }
.empty { text-align: center; padding: 44px 16px; color: var(--color-muted); }
.empty .big { font-size: 2.4rem; display: block; margin-bottom: 6px; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; padding: 14px; flex-wrap: wrap; }
.pager .btn[aria-current=true] { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.bulk-bar {
  position: sticky; bottom: 14px; margin: 14px auto 0; width: fit-content; max-width: 100%; z-index: 15;
  background: var(--color-sidebar-bg); color: #fff; padding: 10px 14px; border-radius: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  box-shadow: var(--shadow-lg); animation: ui-pop .3s var(--ease) both;
}
.bulk-bar .btn { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
.bulk-bar .btn.danger { background: var(--color-danger); }

/* ---------- فرم‌ها ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.dropzone {
  border: 2px dashed var(--color-border); border-radius: 16px; padding: 30px 16px; text-align: center; cursor: pointer;
  color: var(--color-muted); transition: border-color var(--t-fast), background-color var(--t-fast), transform var(--t-fast) var(--ease);
}
.dropzone:hover, .dropzone.over { border-color: var(--color-primary); background: var(--color-primary-soft); transform: scale(1.01); }
.dropzone .big { font-size: 2.2rem; display: block; }
.progress { height: 12px; background: var(--color-surface-2); border-radius: 12px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--color-primary), var(--color-accent)); transition: width .2s linear; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 10px; cursor: pointer; font-size: .85rem; transition: background-color var(--t-fast), border-color var(--t-fast); }
.check:hover { border-color: var(--color-primary); }
.check input { width: auto; accent-color: var(--color-primary); }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { width: auto; accent-color: var(--color-primary); transform: scale(1.2); }
.notice { background: var(--color-warn-soft); border-radius: 12px; padding: 12px 14px; font-size: .86rem; margin: 10px 0; }
.sep { border: none; border-top: 1px solid var(--color-border); margin: 20px 0; }

/* ---------- درخت دسته‌بندی ---------- */
.tree ul { list-style: none; margin: 0; padding: 0 20px 0 0; }
.tree > ul { padding: 0; }
.tree li { margin: 2px 0; }
.tree-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 10px; transition: background-color var(--t-fast); }
.tree-row:hover { background: var(--color-surface-2); }
.tree-row .name { flex: 1; }
.tree-row .acts { opacity: 0; transition: opacity var(--t-fast); display: flex; gap: 6px; }
.tree-row:hover .acts, .tree-row:focus-within .acts { opacity: 1; }
@media (hover: none) { .tree-row .acts { opacity: 1; } }

@media (max-width: 860px) {
  table.data { min-width: 700px; }
  .row-actions { flex-wrap: nowrap; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 50; transform: translateX(100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px; }
  .topbar { padding: 10px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .bar-row { grid-template-columns: 90px 1fr 30px; }
}
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; animation: ui-fade-in .2s both; }

/* آیکون‌های SVG در پنل */
.ic { width: 1.2em; height: 1.2em; flex-shrink: 0; stroke: currentColor; fill: none; }
.nav-link .ico .ic { width: 20px; height: 20px; vertical-align: middle; }
.nav-link .ico { display: inline-flex; justify-content: center; }
.btn .ic { width: 16px; height: 16px; }
.empty .big .ic { width: 44px; height: 44px; color: var(--color-primary); opacity: .7; }
.dropzone .big .ic { width: 46px; height: 46px; color: var(--color-primary); }
.tree-row .ic-folder { color: var(--color-accent); width: 20px; height: 20px; }
.theme-toggle .ic { width: 18px; height: 18px; vertical-align: middle; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.btn.primary { background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark)); }

/* نمودار ستونی بازدید روزانه */
.day-chart { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 8px; }
.day-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: .68rem; color: var(--color-muted); min-width: 0; }
.day-bar { width: 100%; max-width: 22px; height: 0; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--color-accent), var(--color-primary)); transition: height .9s var(--ease); }

table.data th.sortable, table.data thead th { cursor: pointer; user-select: none; }
table.data th.sorted { color: var(--color-primary); }
table.data th[data-arrow]:not([data-arrow=""])::after { content: " " attr(data-arrow); font-size: .7em; }

/* ترتیب دلخواه کتاب‌ها */
.ord-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ord-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; }
.ord-item.dragging { opacity: .4; border-style: dashed; }
.ord-grip { cursor: grab; color: var(--color-muted); letter-spacing: -2px; user-select: none; }
.ord-no { min-width: 28px; text-align: center; color: var(--color-muted); font-size: .85rem; }
.ord-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ord-btns { display: flex; gap: 4px; flex-shrink: 0; }
@media (max-width: 860px) { .ord-title { white-space: normal; } .ord-btns .btn { min-width: 40px; padding: 0; justify-content: center; } .ord-grip { display: none; } }
