/* ════════════════════════════════════════════════════════════
   اندیشکده فولاد — Admin Panel UI  (navy #032340 / gold #CD9E53)
   Redesign: CSS-only. Markup/classes from app.js are unchanged.
   ════════════════════════════════════════════════════════════ */
:root {
  --navy:        #032340;
  --navy-600:    #0a3a5e;
  --gold:        #cd9e53;
  --gold-700:    #b8893d;
  --gold-soft:   #f7ecd7;

  --paper:       #f4f1ea;
  --surface:     #ffffff;
  --surface-2:   #faf8f3;

  --ink:         #1c2128;
  --ink-2:       #4b5563;
  --ink-3:       #6b7280;
  --ink-5:       #9aa1ac;

  --rule:        #e7e2d6;
  --rule-soft:   #f0ece2;

  --red:         #dc2626;
  --red-soft:    #fef2f2;
  --green:       #16a34a;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(3,35,64,.06), 0 1px 3px rgba(3,35,64,.05);
  --shadow-md: 0 6px 18px -6px rgba(3,35,64,.18);
  --shadow-lg: 0 18px 44px -20px rgba(3,35,64,.32);
  --font: 'Vazirmatn', 'Vazir', 'Segoe UI', Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 480px at 100% -10%, rgba(205,158,83,.10), transparent 60%),
    radial-gradient(1000px 460px at -10% 0%, rgba(3,35,64,.06), transparent 55%),
    var(--paper);
  background-attachment: fixed;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--gold-soft); color: var(--navy); }

/* nicer scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--rule) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--ink-5); background-clip: content-box; }

/* ── Buttons ───────────────────────────────────────────────── */
button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 18px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .06s ease;
  line-height: 1.4;
  white-space: nowrap;
}
button:hover { border-color: var(--navy); background: var(--surface-2); }
button:active { transform: translateY(1px); }

button.primary {
  background: linear-gradient(180deg, var(--navy-600), var(--navy));
  color: #fff;
  border-color: var(--navy);
  box-shadow: var(--shadow-sm);
}
button.primary:hover { filter: brightness(1.12); border-color: var(--navy); background: linear-gradient(180deg, var(--navy-600), var(--navy)); }

button.ghost { background: transparent; border-color: var(--rule); color: var(--ink-2); }
button.ghost:hover { background: var(--surface-2); color: var(--ink); }

button.danger { border-color: #f1b4b4; color: var(--red); background: var(--surface); }
button.danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

/* ── Inputs ────────────────────────────────────────────────── */
input, textarea, select {
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 13px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  border-radius: var(--r-sm);
  transition: border-color .16s, box-shadow .16s;
}
input::placeholder, textarea::placeholder { color: var(--ink-5); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(205,158,83,.22);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.7; }

label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 4px;
  letter-spacing: .1px;
}
label > input, label > textarea, label > select { margin-top: 7px; font-weight: 400; }

/* ── Utilities ─────────────────────────────────────────────── */
.muted { color: var(--ink-3); font-size: 12px; }
.error, .alert-error {
  color: #991b1b;
  background: var(--red-soft);
  padding: 10px 14px;
  border: 1px solid #f3c7c7;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 600;
}
.alert {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--gold-soft);
  border: 1px solid #ecd8b3;
  color: var(--gold-700);
  font-size: 12.5px;
  font-weight: 600;
}
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Auth screen ───────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.card, .auth-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 36px 34px;
  width: 100%;
  max-width: 400px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.auth-card::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 5px;
  background: linear-gradient(90deg, var(--navy), var(--gold));
}
.card h1 { font-size: 20px; font-weight: 900; margin: 6px 0 4px; color: var(--navy); letter-spacing: -.3px; }
.card p { margin: 0 0 22px; color: var(--ink-3); }
.card label { margin-top: 14px; }
.card button { width: 100%; margin-top: 22px; padding: 12px; font-size: 14px; }

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-sm);
}
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: linear-gradient(120deg, var(--navy) 0%, var(--navy-600) 100%);
  color: #fff;
  flex-wrap: wrap;
}
.topbar .brand {
  font-weight: 900;
  font-size: 16px;
  letter-spacing: -.3px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .brand::before {
  content: '';
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(205,158,83,.22);
}
.topbar .actions { display: flex; gap: 10px; }
/* buttons living on the navy bar */
.topbar-row .actions button { box-shadow: none; }
.topbar-row .actions button.primary {
  background: linear-gradient(180deg, #e0b269, var(--gold));
  color: var(--navy);
  border-color: transparent;
  font-weight: 800;
}
.topbar-row .actions button.primary:hover { filter: brightness(1.06); }
.topbar-row .actions button.ghost {
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.28);
  color: #fff;
}
.topbar-row .actions button.ghost:hover { background: rgba(255,255,255,.18); }

/* group switcher (on navy) */
.groups { display: flex; gap: 6px; }
.groups .group-btn {
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.82);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 18px;
  border-radius: 999px;
}
.groups .group-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.groups .group-btn.group-active {
  background: var(--gold);
  color: var(--navy);
  border-color: var(--gold);
  box-shadow: 0 2px 10px -2px rgba(205,158,83,.6);
}

/* sub-tabs (white strip) */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
}
.tabs button {
  border: none;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 700;
  padding: 13px 16px 11px;
  border-bottom: 2.5px solid transparent;
  border-radius: 0;
  white-space: nowrap;
}
.tabs button:hover { background: transparent; color: var(--navy); border-bottom-color: var(--rule); }
.tabs button.tab-active { color: var(--navy); border-bottom-color: var(--gold); }

/* ── Page shell ────────────────────────────────────────────── */
.page, .page-body { max-width: 1120px; margin: 0 auto; padding: 34px 28px 64px; }
.page h2 {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.5px;
  margin: 0 0 6px;
  color: var(--navy);
}
.page > .muted { margin-bottom: 18px; }

/* ── Category filter chips ─────────────────────────────────── */
.cat-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.cat-btn {
  padding: 6px 15px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.cat-btn:hover { border-color: var(--gold); color: var(--navy); }
.cat-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ── Content-type picker grid ──────────────────────────────── */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 8px;
}
.type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 22px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  text-align: right;
  box-shadow: var(--shadow-sm);
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.type-card:hover {
  border-color: var(--gold);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}
.type-icon {
  font-size: 26px; line-height: 1;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gold-soft);
  border-radius: var(--r-md);
}
.type-card strong { font-size: 15px; font-weight: 800; color: var(--navy); }
.type-desc { font-size: 12px; color: var(--ink-3); font-weight: 400; line-height: 1.5; }

/* ── List + rows (card style) ──────────────────────────────── */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: transparent;
  border: none;
}
.row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 18px;
  align-items: center;
  background: var(--surface);
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.row:hover { border-color: var(--gold); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.row-cover {
  width: 92px;
  height: 68px;
  background-color: var(--surface-2);
  background-size: cover;
  background-position: center;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
}
.row-main { min-width: 0; }
.row-main h3 { font-size: 14.5px; font-weight: 800; margin: 5px 0; color: var(--ink); }
.row-main p { margin: 0; color: var(--ink-3); }
.row-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions { display: flex; gap: 8px; }
.row-actions button { padding: 7px 14px; font-size: 12.5px; }

/* ── Pills / badges ────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  background: var(--gold-soft);
  color: var(--gold-700);
  letter-spacing: .3px;
  border-radius: 999px;
}
.pill.red   { background: var(--red);   color: #fff; }
.pill.green { background: var(--green); color: #fff; }

.pill.level-critical    { background: #7f1d1d; color: #fff; }
.pill.level-high        { background: #b91c1c; color: #fff; }
.pill.level-medium      { background: #b45309; color: #fff; }
.pill.level-low         { background: #166534; color: #fff; }
.pill.level-opportunity { background: #1e40af; color: #fff; }

.risk-row { grid-template-columns: 1fr auto; }
.risk-row .row-meta strong { font-size: 13px; color: var(--navy); }

/* ── Avatar ────────────────────────────────────────────────── */
.row-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  background: linear-gradient(140deg, var(--navy), var(--navy-600));
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* ── Editor forms ──────────────────────────────────────────── */
.editor .grid, form.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 26px;
  box-shadow: var(--shadow-sm);
}
.editor .col.span-2, .col.span-2 { grid-column: 1 / -1; }
.editor .row-end, .row-end { display: flex; justify-content: flex-start; }

.checkbox {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 9px;
  margin-top: 22px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  padding: 10px 14px;
}
.checkbox input { width: auto; margin: 0; accent-color: var(--gold); width: 17px; height: 17px; }
.checkbox span { font-weight: 700; color: var(--ink); }

.cover-row { display: flex; gap: 16px; align-items: center; margin-top: 6px; }
.cover-row input[type=file] { flex: 1; }
.cover-row img {
  width: 130px; height: 86px;
  object-fit: cover;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
}
.cover-row img[src=""] { visibility: hidden; }

/* block editor (article body) */
.blocks-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--rule);
  border-radius: var(--r-md);
  padding: 16px;
  margin-top: 8px;
}

/* file inputs */
input[type=file] {
  padding: 8px;
  font-size: 12.5px;
  background: var(--surface-2);
  cursor: pointer;
}
input[type=file]::file-selector-button {
  font-family: inherit; font-weight: 700; font-size: 12px;
  border: 1px solid var(--rule); background: var(--surface);
  color: var(--navy); padding: 7px 14px; border-radius: var(--r-sm);
  cursor: pointer; margin-inline-end: 12px;
}
input[type=file]::file-selector-button:hover { border-color: var(--gold); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 760px) {
  .editor .grid, form.grid { grid-template-columns: 1fr; padding: 18px; }
  .editor .col.span-2, .col.span-2 { grid-column: 1; }
  .topbar-row { padding: 12px 16px; }
  .tabs { padding: 0 12px; }
  .page, .page-body { padding: 20px 16px 48px; }
  .row { grid-template-columns: 64px 1fr; }
  .row-actions { grid-column: 1 / -1; }
  .row-cover { width: 64px; height: 50px; }
}
