@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/Vazirmatn-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #0e7490;
  --brand-d: #0c5c72;
  --brand-l: #ecfeff;
  --brand-grad: linear-gradient(135deg, #0e7490 0%, #0891b2 55%, #06b6d4 100%);
  --bg: #eef2f7;
  --card: #ffffff;
  --line: #e6ebf2;
  --text: #0f1f2e;
  --muted: #64748b;
  --radius: 16px;
  --shadow-sm: 0 2px 6px rgba(15,31,46,.05), 0 1px 2px rgba(15,31,46,.06);
  --shadow: 0 10px 30px -12px rgba(15,31,46,.22), 0 4px 10px -6px rgba(15,31,46,.12);
  --shadow-lg: 0 26px 60px -18px rgba(8,80,110,.4);
  --ring: 0 0 0 4px rgba(8,145,178,.16);
}
body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
  color: var(--text);
  direction: rtl;
  font-size: 14px;
  line-height: 1.7;
  background: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 88% -8%, rgba(6,182,212,.16), transparent 60%),
    radial-gradient(900px 500px at -6% 4%, rgba(14,116,144,.14), transparent 55%),
    radial-gradient(700px 700px at 50% 120%, rgba(8,145,178,.10), transparent 60%);
  background-attachment: fixed;
}
.hidden { display: none !important; }
.err { color: #dc2626; font-size: 13px; margin-top: 8px; min-height: 18px; }

/* ورود */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(160deg, #071b23 0%, #0d3a48 50%, #0e7490 120%);
  position: relative; overflow: hidden;
}
.login-screen::before, .login-screen::after {
  content:''; position:absolute; border-radius:50%; filter: blur(60px); opacity:.5;
}
.login-screen::before { width:420px; height:420px; background:#06b6d4; top:-120px; right:-80px; animation: floaty 9s ease-in-out infinite; }
.login-screen::after { width:360px; height:360px; background:#0e7490; bottom:-120px; left:-60px; animation: floaty 11s ease-in-out infinite reverse; }
@keyframes floaty { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(30px) } }
.login-box {
  position: relative; z-index: 1;
  background: rgba(255,255,255,.9); backdrop-filter: blur(14px);
  padding: 46px 40px; border-radius: 22px; width: 350px; text-align: center;
  box-shadow: 0 30px 70px rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.5);
}
.login-box h1 { font-size: 23px; font-weight: 700; letter-spacing: .2px; }
.login-box p { color: var(--muted); margin: 6px 0 26px; font-size: 13px; }
.login-box input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  font-family: inherit; margin-bottom: 16px; text-align: center; font-size: 14px; background: #f8fafc;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.login-box input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: var(--ring); }
.login-box button {
  width: 100%; padding: 12px; background: var(--brand-grad); color: #fff; border: 0;
  border-radius: 12px; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(8,145,178,.7); transition: transform .16s, box-shadow .16s, filter .16s;
}
.login-box button:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -8px rgba(8,145,178,.8); filter: brightness(1.05); }
.login-box button:active { transform: translateY(0); }

/* چیدمان اصلی */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  background: linear-gradient(185deg, #0c2230 0%, #0a2b38 55%, #06313f 100%);
  box-shadow: 6px 0 30px -14px rgba(0,0,0,.5); z-index: 5;
}
.brand {
  font-size: 18px; font-weight: 700; color: #fff; padding: 24px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08); letter-spacing: .3px;
  background: linear-gradient(90deg, rgba(6,182,212,.14), transparent);
}
.sidebar nav { flex: 1; padding: 14px 12px; }
.sidebar nav a {
  position: relative; display: block; padding: 11px 16px; color: #9fb3c4; cursor: pointer; font-size: 13.5px;
  border-radius: 11px; margin-bottom: 4px; font-weight: 500;
  transition: background .18s, color .18s, transform .18s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #eaf2f8; transform: translateX(-3px); }
.sidebar nav a.active {
  background: var(--brand-grad); color: #fff; font-weight: 700;
  box-shadow: 0 10px 22px -8px rgba(8,145,178,.75);
}
.sidebar nav a.active::before {
  content:''; position:absolute; right:-12px; top:50%; transform:translateY(-50%);
  width:4px; height:22px; border-radius:4px; background:#67e8f9; box-shadow:0 0 12px #22d3ee;
}
.sidebar-foot { padding: 16px 24px; font-size: 11px; color: #4b6072; }

.content { flex: 1; padding: 32px 38px; overflow-y: auto; }
h2.page-title {
  font-size: 24px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.2px;
  background: linear-gradient(90deg, #0f2f3e, #0e7490); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.subtitle { color: var(--muted); margin-bottom: 24px; font-size: 13px; }

/* کارت‌های آمار */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(172px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s;
}
.stat::before { content:''; position:absolute; top:0; right:0; left:0; height:4px; background: var(--brand-grad); }
.stat:hover { transform: translateY(-5px); box-shadow: var(--shadow); }
.stat .num {
  font-size: 27px; font-weight: 700;
  background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat .lbl { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

/* پنل و جدول */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s;
}
.panel:hover { box-shadow: var(--shadow); }
.panel h3 { font-size: 15px; font-weight: 700; margin-bottom: 18px; }
.panel > summary { font-size: 15px; font-weight: 700; cursor: pointer; list-style: none; padding: 2px 0; }
.panel > summary::-webkit-details-marker { display: none; }
.panel > summary::before { content: "▸ "; color: var(--brand); font-size: 11px; }
.panel[open] > summary::before { content: "▾ "; }
.settings-block { padding: 18px 0; border-top: 1px solid var(--line); }
.settings-block:first-of-type { border-top: none; margin-top: 14px; }
.settings-block h4 { font-size: 13px; font-weight: 700; color: var(--brand-d); margin-bottom: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th { background: #f4f7fb; text-align: right; padding: 12px; color: var(--muted); font-weight: 700; font-size: 12px; border-bottom: 1px solid var(--line); }
th:first-child { border-radius: 0 10px 0 0; } th:last-child { border-radius: 10px 0 0 0; }
td { padding: 12px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: #f6fbfd; }

/* فرم */
.row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
input, select, textarea {
  padding: 10px 13px; border: 1.5px solid var(--line); border-radius: 11px; font-family: inherit;
  font-size: 13px; flex: 1; min-width: 120px; background: #fff; color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
textarea { width: 100%; min-height: 92px; resize: vertical; margin-bottom: 12px; }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; font-weight: 500; }
.field { flex: 1; min-width: 160px; margin-bottom: 12px; }
.field > input, .field > select { width: 100%; }

button.btn {
  padding: 10px 20px; background: var(--brand-grad); color: #fff; border: 0; border-radius: 11px;
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(8,145,178,.6); transition: transform .16s, box-shadow .16s, filter .16s;
}
button.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 26px -8px rgba(8,145,178,.7); filter: brightness(1.04); }
button.btn:active { transform: translateY(0); }
button.btn.ghost { background: #fff; color: var(--brand-d); border: 1.5px solid var(--line); box-shadow: var(--shadow-sm); }
button.btn.ghost:hover { background: var(--brand-l); border-color: #a5e8f2; }
button.btn.sm { padding: 6px 12px; font-size: 12px; font-weight: 600; border-radius: 9px; box-shadow: none; }
button.btn.sm:hover { transform: translateY(-1px); }
button.btn.danger { background: linear-gradient(135deg,#ef4444,#dc2626); box-shadow: 0 8px 18px -8px rgba(220,38,38,.6); }
button.btn.gray { background: linear-gradient(135deg,#94a3b8,#64748b); box-shadow: 0 8px 18px -8px rgba(100,116,139,.5); }
button.btn.dl { background: linear-gradient(135deg,#059669,#10b981); box-shadow: 0 8px 18px -8px rgba(16,185,129,.5); }

.badge { padding: 4px 11px; border-radius: 20px; font-size: 11px; font-weight: 700; display: inline-block; box-shadow: var(--shadow-sm); }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dbeafe; color: #1e40af; }
.badge.sent, .badge.published, .badge.active { background: #d1fae5; color: #065f46; }
.badge.rejected, .badge.removed { background: #fee2e2; color: #991b1b; }
.badge.draft, .badge.lead, .badge.low_views, .badge.new { background: #eef2f7; color: #475569; }
.badge.imported { background: #d1fae5; color: #065f46; }
.badge.generating, .badge.generating_image { background: #cffafe; color: #0e7490; }

.note {
  background: linear-gradient(90deg,#ecfeff,#f0f9ff); border-right: 4px solid var(--brand);
  padding: 14px 18px; border-radius: 12px; font-size: 12.5px; color: #155e75; margin-bottom: 20px; line-height: 1.9;
  box-shadow: var(--shadow-sm);
}
.hint { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.hint-inline { font-size: 12px; color: var(--muted); }
.err-inline { color: #991b1b; }
.status-line { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.status-line b { color: var(--text); }

/* عکس‌ها: پیش‌نمایش + دانلود */
.img-list { display: flex; flex-direction: column; gap: 10px; }
.img-row { display: flex; align-items: center; gap: 8px; font-size: 12px; flex-wrap: wrap; }
.img-thumb-link { line-height: 0; }
.img-thumb {
  width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 2px solid #fff;
  box-shadow: var(--shadow); cursor: zoom-in; transition: transform .2s, box-shadow .2s;
}
.img-thumb:hover { transform: scale(1.06) rotate(-1deg); box-shadow: var(--shadow-lg); }

/* مودال */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8,20,30,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px;
  animation: fadein .2s ease;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.modal-box {
  background: #fff; border-radius: 20px; max-width: 640px; width: 100%; max-height: 82vh;
  overflow-y: auto; padding: 32px; position: relative; box-shadow: 0 30px 70px rgba(0,0,0,.4);
  animation: popin .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes popin { from { transform: scale(.94) translateY(10px); opacity: 0 } to { transform: none; opacity: 1 } }
.modal-close {
  position: absolute; left: 16px; top: 12px; border: none; background: #f1f5f9; width: 32px; height: 32px;
  border-radius: 50%; font-size: 20px; color: var(--muted); cursor: pointer; line-height: 1; transition: background .15s;
}
.modal-close:hover { background: #e2e8f0; }
.modal-box h3 { font-size: 18px; margin-bottom: 12px; padding-left: 30px; }
.modal-box h4 { font-size: 14px; margin: 18px 0 8px; color: var(--brand-d); }
.modal-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.8; }
.modal-text { font-size: 13.5px; line-height: 2; white-space: pre-wrap; }

.toast {
  position: fixed; bottom: 26px; left: 26px;
  background: linear-gradient(135deg,#0c2230,#0e7490); color: #fff;
  padding: 13px 22px; border-radius: 13px; font-size: 13px; font-weight: 500;
  box-shadow: 0 16px 36px rgba(0,0,0,.3); opacity: 0; transform: translateY(14px) scale(.98);
  transition: .28s cubic-bezier(.2,.8,.2,1); z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0) scale(1); }

/* بلوک لوگوی برند و چک‌باکس */
.logo-block { background: linear-gradient(180deg,#fafdff,#f4f9fc); border-style: dashed; }
.logo-block h4 { font-size: 13px; font-weight: 700; color: var(--brand-d); }
.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-thumb {
  width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; padding: 5px; box-shadow: var(--shadow-sm);
}
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 500; cursor: pointer; }
.check-line input { width: auto; min-width: 0; flex: none; margin: 0; accent-color: var(--brand); width: 17px; height: 17px; }

/* ====== افکت زنده و سه‌بعدی «در حال ساخت» ====== */
.gen-card {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 22px;
  border-radius: 18px; padding: 26px 28px; margin-bottom: 20px;
  background: linear-gradient(120deg, #0e7490, #0891b2, #22d3ee, #0891b2, #0e7490);
  background-size: 300% 300%;
  animation: gen-aurora 5s ease infinite;
  box-shadow: 0 16px 44px rgba(8,145,178,.38);
  color: #fff;
}
@keyframes gen-aurora { 0%{background-position:0% 50%} 50%{background-position:100% 50%} 100%{background-position:0% 50%} }
.gen-card::after {
  content:''; position:absolute; inset:0; pointer-events:none;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,.28) 50%, transparent 65%);
  transform: translateX(-120%); animation: gen-shimmer 2.4s cubic-bezier(.4,0,.2,1) infinite;
}
@keyframes gen-shimmer { to { transform: translateX(120%); } }

.gen-orb {
  position: relative; width: 74px; height: 74px; flex-shrink: 0;
  transform-style: preserve-3d; animation: gen-float 3s ease-in-out infinite;
}
@keyframes gen-float { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-9px) } }
.gen-orb .ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid transparent; border-top-color: #fff; border-right-color: rgba(255,255,255,.6);
  animation: gen-spin3d 1.6s linear infinite;
}
.gen-orb .ring.r2 { inset: 11px; border-top-color: #a5f3fc; border-right-color: transparent; border-left-color: rgba(165,243,252,.7); animation-duration: 2.4s; animation-direction: reverse; }
.gen-orb .ring.r3 { inset: 22px; border-top-color: #fff; animation-duration: 1.1s; }
@keyframes gen-spin3d { to { transform: rotateY(360deg) rotateZ(360deg); } }
.gen-orb .core {
  position: absolute; inset: 30px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 18px 4px rgba(255,255,255,.85);
  animation: gen-pulse 1.4s ease-in-out infinite;
}
@keyframes gen-pulse { 0%,100%{ transform: scale(.8); opacity:.8 } 50%{ transform: scale(1.15); opacity:1 } }

.gen-text { flex: 1; }
.gen-text .gen-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.gen-text .gen-stage { font-size: 13.5px; opacity: .92; }
.gen-dots::after { content:''; animation: gen-dots 1.4s steps(4,end) infinite; }
@keyframes gen-dots { 0%{content:''} 25%{content:'.'} 50%{content:'..'} 75%{content:'...'} }
.gen-bars { display:flex; gap:5px; margin-top:12px; }
.gen-bars span {
  width: 5px; height: 22px; border-radius: 3px; background: rgba(255,255,255,.85);
  animation: gen-eq 1s ease-in-out infinite;
}
.gen-bars span:nth-child(2){ animation-delay:.15s } .gen-bars span:nth-child(3){ animation-delay:.3s }
.gen-bars span:nth-child(4){ animation-delay:.45s } .gen-bars span:nth-child(5){ animation-delay:.6s }
.gen-bars span:nth-child(6){ animation-delay:.75s } .gen-bars span:nth-child(7){ animation-delay:.9s }
@keyframes gen-eq { 0%,100%{ transform: scaleY(.4) } 50%{ transform: scaleY(1) } }

.img-skeleton {
  width: 96px; height: 96px; border-radius: 12px; position: relative; overflow: hidden;
  background: #dbe4ee; box-shadow: var(--shadow-sm);
}
.img-skeleton::after {
  content:''; position:absolute; inset:0;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.7) 50%, transparent 70%);
  transform: translateX(-100%); animation: gen-shimmer 1.5s infinite;
}
.img-skeleton .lbl { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; text-align:center; font-size:10.5px; color:#475569; font-weight:700; z-index:1; padding:6px; }
