/* ==========================================================================
   پنل مدیریت گروه هورسام
   ========================================================================== */

@font-face {
  font-family: 'Vazir';
  src: url('/static/fonts/Vazir.woff') format('woff');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --p-bg:      #f4f6f9;
  --p-panel:   #ffffff;
  --p-ink:     #17202e;
  --p-ink-2:   #46536b;
  --p-muted:   #7c8798;
  --p-line:    #e3e8ef;
  --p-side:    #161c26;
  --p-side-2:  #1f2733;
  --p-accent:  #fbb134;   /* زرد لوگو */
  --p-accent-2:#e89f1e;   /* هاور */
  --p-accent-ink: #8a5a08; /* زرد تیره برای متن روی زمینه روشن */
  --p-green:   #1f9254;
  --p-red:     #c8412f;
  --p-blue:    #2563a8;
  --p-radius:  8px;
  --p-shadow:  0 1px 2px rgba(23,32,46,.05), 0 8px 24px -14px rgba(23,32,46,.22);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; background: var(--p-bg); color: var(--p-ink);
  font-family: 'Vazir', 'Segoe UI', Tahoma, sans-serif;
  font-size: 15px; line-height: 1.85;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0; line-height: 1.4; }
p { margin: 0 0 .8em; }
p:last-child { margin-bottom: 0; }

/* --- چیدمان ------------------------------------------------------------- */

.p-layout { display: grid; grid-template-columns: 262px 1fr; min-height: 100vh; }

.p-side {
  background: var(--p-side); color: rgba(255,255,255,.72);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.p-side-head {
  padding: 22px 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 12px;
}
.p-logo {
  width: 42px; height: 42px; border-radius: var(--p-radius); flex: none;
  background: var(--p-ink); color: var(--p-accent); display: grid; place-items: center;
  font-weight: 800; font-size: 18px; overflow: hidden;
}
.p-logo img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.p-side-head b { color: #fff; font-size: 16px; display: block; line-height: 1.4; }
.p-side-head span { font-size: 12px; color: rgba(255,255,255,.5); }

.p-menu { padding: 16px 12px; flex: 1; }
.p-menu-label {
  font-size: 11.5px; letter-spacing: .06em; color: rgba(255,255,255,.35);
  padding: 16px 12px 8px; font-weight: 700;
}
.p-menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--p-radius); margin-bottom: 3px;
  font-size: 14.5px; font-weight: 600; transition: all .18s ease;
}
.p-menu a svg { width: 19px; height: 19px; flex: none; opacity: .75; }
.p-menu a:hover { background: rgba(255,255,255,.07); color: #fff; }
.p-menu a.active { background: var(--p-accent); color: var(--p-ink); }
.p-menu a.active svg { opacity: 1; }
.p-menu a .count {
  margin-inline-start: auto; background: rgba(255,255,255,.13); color: #fff;
  font-size: 12px; padding: 1px 8px; border-radius: 100px; font-weight: 700;
}
.p-menu a.active .count { background: rgba(0,0,0,.22); }
.p-menu a .count.hot { background: var(--p-red); }

.p-side-foot { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }

.p-main { min-width: 0; display: flex; flex-direction: column; }

.p-top {
  background: var(--p-panel); border-bottom: 1px solid var(--p-line);
  padding: 0 28px; height: 68px; display: flex; align-items: center;
  justify-content: space-between; gap: 20px;
  position: sticky; top: 0; z-index: 20;
}
.p-top h1 { font-size: 19px; font-weight: 700; }
.p-top-actions { display: flex; align-items: center; gap: 10px; }
.p-user { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--p-muted); }
.p-user b { color: var(--p-ink); }
.p-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--p-accent);
  color: var(--p-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px;
}

.p-body { padding: 28px; flex: 1; }

.p-burger {
  display: none; width: 40px; height: 40px; border: 1px solid var(--p-line);
  border-radius: var(--p-radius); background: #fff; place-items: center; cursor: pointer;
}
.p-burger svg { width: 20px; height: 20px; }

/* --- دکمه‌ها ------------------------------------------------------------ */

.b {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: 1px solid transparent; border-radius: var(--p-radius);
  font: inherit; font-size: 14.5px; font-weight: 700; cursor: pointer;
  background: var(--p-accent); color: var(--p-ink); transition: all .2s ease; white-space: nowrap;
}
.b:hover { background: var(--p-accent-2); }
.b svg { width: 17px; height: 17px; flex: none; }
.b-ghost { background: #fff; color: var(--p-ink-2); border-color: var(--p-line); }
.b-ghost:hover { background: #fff; border-color: var(--p-accent); color: var(--p-accent-ink); }
.b-dark { background: var(--p-side); }
.b-dark:hover { background: #0d1219; }
.b-danger { background: transparent; color: var(--p-red); border-color: #f0d3ce; }
.b-danger:hover { background: var(--p-red); color: #fff; border-color: var(--p-red); }
.b-sm { padding: 7px 13px; font-size: 13.5px; }
.b-icon { padding: 8px; width: 36px; height: 36px; }
.b-block { width: 100%; }

/* --- کارت‌ها ----------------------------------------------------------- */

.card {
  background: var(--p-panel); border: 1px solid var(--p-line);
  border-radius: var(--p-radius); box-shadow: var(--p-shadow);
}
.card-head {
  padding: 18px 22px; border-bottom: 1px solid var(--p-line);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.card-head h2 { font-size: 16.5px; font-weight: 700; }
.card-body { padding: 22px; }

.p-grid { display: grid; gap: 20px; }
.p-g2 { grid-template-columns: repeat(2, 1fr); }
.p-g3 { grid-template-columns: repeat(3, 1fr); }
.p-g4 { grid-template-columns: repeat(4, 1fr); }

/* --- کارت آمار --------------------------------------------------------- */

.kpi {
  background: var(--p-panel); border: 1px solid var(--p-line); border-radius: var(--p-radius);
  padding: 20px 22px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--p-shadow); transition: transform .2s ease;
}
.kpi:hover { transform: translateY(-3px); }
.kpi-ic {
  width: 50px; height: 50px; border-radius: var(--p-radius); flex: none;
  display: grid; place-items: center; background: rgba(251,177,52,.20); color: var(--p-accent-ink);
}
.kpi-ic svg { width: 24px; height: 24px; }
.kpi-ic.g { background: rgba(31,146,84,.12); color: var(--p-green); }
.kpi-ic.b { background: rgba(37,99,168,.12); color: var(--p-blue); }
.kpi-ic.r { background: rgba(200,65,47,.12); color: var(--p-red); }
.kpi b { display: block; font-size: 26px; line-height: 1.3; }
.kpi span { font-size: 13.5px; color: var(--p-muted); }

/* --- جدول -------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.t th {
  text-align: right; padding: 13px 18px; background: #f7f9fc;
  color: var(--p-muted); font-weight: 700; font-size: 13.5px;
  border-bottom: 1px solid var(--p-line); white-space: nowrap;
}
table.t td { padding: 13px 18px; border-bottom: 1px solid var(--p-line); vertical-align: middle; }
table.t tbody tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: #fafbfd; }
table.t .cell-title { font-weight: 700; color: var(--p-ink); }
table.t .cell-title:hover { color: var(--p-accent-ink); }
table.t .thumb { width: 54px; height: 42px; object-fit: cover; border-radius: 5px; background: var(--p-bg); }
.row-actions { display: flex; gap: 6px; justify-content: flex-start; }

table.t .drag-handle { width: 40px; text-align: center; color: var(--p-muted); cursor: grab; }
table.t .drag-handle svg { width: 16px; height: 16px; pointer-events: none; }
table.t tbody tr[data-id] { transition: background-color .15s ease; }
table.t tbody tr.dragging { opacity: .45; }
table.t tbody tr.drag-over { box-shadow: inset 0 2px 0 var(--p-accent), inset 0 -2px 0 var(--p-accent); }

.tag {
  display: inline-block; padding: 3px 11px; border-radius: 100px;
  font-size: 12.5px; font-weight: 700;
}
.tag-on  { background: rgba(31,146,84,.12); color: var(--p-green); }
.tag-off { background: rgba(124,135,152,.14); color: var(--p-muted); }
.tag-hot { background: rgba(251,177,52,.20); color: var(--p-accent-ink); }
.tag-new { background: rgba(200,65,47,.12); color: var(--p-red); }

/* --- فرم‌ها ------------------------------------------------------------ */

.f-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.f-field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.f-field--full { grid-column: 1 / -1; }
.f-field > label { font-size: 14px; font-weight: 700; color: var(--p-ink-2); }
.f-help { font-size: 12.5px; color: var(--p-muted); }
.f-err { font-size: 13px; color: var(--p-red); font-weight: 600; }

.f-input {
  width: 100%; padding: 11px 15px; border: 1px solid var(--p-line);
  border-radius: var(--p-radius); font: inherit; font-size: 14.5px;
  background: #fff; color: var(--p-ink); transition: border-color .18s, box-shadow .18s;
}
.f-input:focus { outline: none; border-color: var(--p-accent); box-shadow: 0 0 0 3px rgba(251,177,52,.28); }
.f-textarea { resize: vertical; min-height: 110px; line-height: 1.9; }
.f-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237c8798' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-size: 17px; background-repeat: no-repeat; background-position: left 14px center; padding-inline-start: 40px; }
.f-file { font-size: 14px; }
.f-check-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; }
.f-check { width: 19px; height: 19px; accent-color: var(--p-accent); cursor: pointer; }
.f-check-row label { font-size: 14.5px; font-weight: 600; cursor: pointer; }

.f-file-preview {
  display: block; width: 100%; max-width: 260px; aspect-ratio: 16/10; object-fit: cover;
  border-radius: var(--p-radius); border: 1px solid var(--p-line); margin-bottom: 10px;
  background: var(--p-bg);
}
.f-file-clear { padding-top: 0; padding-bottom: 8px; }

.f-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-top: 20px; margin-top: 6px; border-top: 1px solid var(--p-line);
}
.f-actions .spacer { flex: 1; }

/* --- ویرایشگر متن ------------------------------------------------------ */

.editor-shell { border: 1px solid var(--p-line); border-radius: var(--p-radius); overflow: hidden; background: #fff; }
.editor-bar {
  display: flex; flex-wrap: wrap; gap: 3px; padding: 8px;
  background: #f7f9fc; border-bottom: 1px solid var(--p-line);
}
.editor-bar button {
  min-width: 34px; height: 34px; padding: 0 9px; border: 1px solid transparent;
  border-radius: 5px; background: transparent; color: var(--p-ink-2);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .15s;
  display: inline-grid; place-items: center;
}
.editor-bar button:hover { background: #fff; border-color: var(--p-line); color: var(--p-accent-ink); }
.editor-bar .sep { width: 1px; background: var(--p-line); margin: 4px 5px; }
.editor-area {
  min-height: 320px; max-height: 620px; overflow-y: auto; padding: 18px 20px;
  line-height: 2; font-size: 15px; outline: none;
}
.editor-area:focus { box-shadow: inset 0 0 0 2px rgba(251,177,52,.3); }
.editor-area:empty::before { content: attr(data-placeholder); color: var(--p-muted); }
.editor-area img { border-radius: 6px; margin: 12px 0; }
.editor-area h2 { font-size: 22px; margin: 18px 0 10px; }
.editor-area h3 { font-size: 18px; margin: 16px 0 8px; }
.editor-area blockquote {
  margin: 14px 0; padding: 10px 18px; border-inline-start: 3px solid var(--p-accent);
  background: var(--p-bg); border-radius: 5px;
}
.editor-area ul, .editor-area ol { padding-inline-start: 22px; }

/* --- گالری در فرم ------------------------------------------------------ */

.gal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.gal-item {
  position: relative; border-radius: var(--p-radius); overflow: hidden;
  border: 1px solid var(--p-line); background: var(--p-bg);
  cursor: grab; transition: box-shadow .18s ease, opacity .18s ease, transform .18s ease;
}
.gal-item:active { cursor: grabbing; }
.gal-item.dragging { opacity: .4; }
.gal-item.drag-over { box-shadow: 0 0 0 2px var(--p-accent) inset; transform: scale(.98); }
.gal-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.gal-item form { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; z-index: 2; }
.gal-item button {
  width: 30px; height: 30px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(23,32,46,.75); color: #fff; display: grid; place-items: center;
  transition: background .2s;
}
.gal-item button:hover { background: var(--p-red); }
.gal-item button svg { width: 15px; height: 15px; }
.gal-item .cap { padding: 8px 10px; font-size: 12.5px; color: var(--p-muted); }

.gal-handle {
  position: absolute; inset-block-start: 8px; inset-inline-start: 8px; z-index: 2;
  width: 28px; height: 22px; border-radius: 6px;
  background: rgba(23,32,46,.6); color: #fff;
  display: grid; place-items: center; opacity: 0; transition: opacity .15s ease;
}
.gal-item:hover .gal-handle { opacity: 1; }
.gal-handle svg { width: 15px; height: 15px; }
.gal-order-badge {
  position: absolute; inset-block-end: 8px; inset-inline-start: 8px; z-index: 2;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: rgba(23,32,46,.72); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.gal-reorder-status { min-height: 18px; }
.gal-reorder-status.saved { color: var(--p-green); font-weight: 700; }
.gal-reorder-status.error { color: var(--p-red); font-weight: 700; }

.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; width: 100%; min-height: 160px; box-sizing: border-box;
  border: 2px dashed var(--p-line); border-radius: var(--p-radius);
  padding: 28px 20px; text-align: center; color: var(--p-muted);
  transition: all .2s ease; cursor: pointer; background: #fbfcfe;
}
.drop-zone:hover, .drop-zone.over { border-color: var(--p-accent); background: rgba(251,177,52,.10); color: var(--p-accent-ink); }
.drop-zone.over { transform: scale(1.01); }
.drop-zone .dz-icon {
  width: 46px; height: 46px; border-radius: 50%; flex: none;
  background: rgba(251,177,52,.14); color: var(--p-accent-ink);
  display: grid; place-items: center; transition: background .2s ease;
}
.drop-zone:hover .dz-icon, .drop-zone.over .dz-icon { background: rgba(251,177,52,.22); }
.drop-zone .dz-icon svg { width: 22px; height: 22px; }
.drop-zone input { display: none; }
.drop-zone b { display: block; color: var(--p-ink); font-size: 15px; font-weight: 700; }
.drop-zone .f-help { max-width: 260px; }

/* --- پیام‌ها ----------------------------------------------------------- */

.p-alert {
  padding: 13px 18px; border-radius: var(--p-radius); margin-bottom: 18px;
  font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 10px;
}
.p-alert svg { width: 19px; height: 19px; flex: none; }
.p-alert-success { background: #e8f6ee; color: #17683c; border: 1px solid #c2e5d1; }
.p-alert-error   { background: #fdecea; color: #9e2717; border: 1px solid #f4c7c1; }
.p-alert-info    { background: #eaf1fb; color: #1d4b8c; border: 1px solid #c8d9f2; }

/* --- ابزارهای بالای لیست ----------------------------------------------- */

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar form { display: flex; gap: 8px; }
.toolbar .f-input { min-width: 240px; }
.toolbar .spacer { flex: 1; }

.p-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.p-tab {
  padding: 8px 16px; border-radius: 100px; border: 1px solid var(--p-line);
  background: #fff; font-size: 13.5px; font-weight: 700; color: var(--p-ink-2); transition: all .18s;
}
.p-tab:hover { border-color: var(--p-accent); color: var(--p-accent-ink); }
.p-tab.active { background: var(--p-side); border-color: var(--p-side); color: #fff; }

/* --- صفحه‌بندی --------------------------------------------------------- */

.p-pager { display: flex; gap: 6px; justify-content: center; padding: 18px; flex-wrap: wrap; }
.p-pager a, .p-pager span {
  min-width: 38px; height: 38px; padding: 0 12px; border: 1px solid var(--p-line);
  border-radius: 6px; display: grid; place-items: center; font-weight: 700;
  font-size: 14px; background: #fff;
}
.p-pager a:hover { border-color: var(--p-accent); color: var(--p-accent-ink); }
.p-pager .current { background: var(--p-side); border-color: var(--p-side); color: #fff; }
.p-pager .disabled { opacity: .45; }

/* --- خالی -------------------------------------------------------------- */

.p-empty { text-align: center; padding: 60px 24px; color: var(--p-muted); }
.p-empty svg { width: 48px; height: 48px; color: #d7dee8; margin: 0 auto 14px; }
.p-empty h3 { color: var(--p-ink); font-size: 18px; margin-bottom: 6px; }
.p-empty p { margin-bottom: 18px; }

/* --- فهرست فعالیت ------------------------------------------------------ */

.feed { display: grid; gap: 2px; }
.feed a, .feed div.row {
  display: flex; align-items: center; gap: 14px; padding: 12px 22px;
  border-bottom: 1px solid var(--p-line); transition: background .15s;
}
.feed a:last-child, .feed div.row:last-child { border-bottom: 0; }
.feed a:hover { background: #fafbfd; }
.feed img, .feed .ph {
  width: 46px; height: 40px; border-radius: 6px; object-fit: cover; flex: none;
  background: var(--p-bg); display: grid; place-items: center; color: var(--p-muted);
}
.feed .ph svg { width: 19px; height: 19px; }
.feed b { display: block; font-size: 14.5px; font-weight: 700; }
.feed small { color: var(--p-muted); font-size: 12.5px; }
.feed .meta { margin-inline-start: auto; text-align: left; flex: none; }

/* --- ورود -------------------------------------------------------------- */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 30px;
  background: linear-gradient(135deg, #161c26, #232c3b);
}
.login-card {
  width: 100%; max-width: 420px; background: #fff; border-radius: 12px;
  padding: 40px 36px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.5);
}
.login-card .p-logo { width: 56px; height: 56px; margin: 0 auto 18px; font-size: 24px; }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--p-muted); font-size: 14px; margin-bottom: 28px; }
.login-back { text-align: center; margin-top: 22px; font-size: 14px; }
.login-back a { color: var(--p-muted); }
.login-back a:hover { color: var(--p-accent-ink); }

/* --- واکنش‌گرایی ------------------------------------------------------- */

@media (max-width: 1100px) {
  .p-g4 { grid-template-columns: repeat(2, 1fr); }
  .p-g3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .p-layout { grid-template-columns: 1fr; }
  .p-side {
    position: fixed; inset-block: 0; inset-inline-end: 0; width: 262px; z-index: 60;
    transform: translateX(100%); transition: transform .25s ease;
  }
  .p-side.open { transform: none; }
  .p-burger { display: grid; }
  .p-body { padding: 18px; }
  .p-top { padding: 0 18px; }
  .f-row, .p-g2 { grid-template-columns: 1fr; }
  .p-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; display: none; }
  .p-scrim.show { display: block; }
}
