/* Vazirmatn is loaded via CDN <link> in layouts/header.php.
   If the server has no outbound internet access, drop a Vazirmatn-Regular.ttf /
   Vazirmatn-Bold.ttf into public/assets/fonts/ and uncomment the @font-face
   rules below (see README "Fonts" section). */
/*
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Regular.ttf') format('truetype'); font-weight: 400; }
@font-face { font-family: 'Vazirmatn'; src: url('../fonts/Vazirmatn-Bold.ttf') format('truetype'); font-weight: 700; }
*/

:root {
  --bg: #f4f6fb;
  --bg-elevated: rgba(255,255,255,0.72);
  --bg-solid: #ffffff;
  --text: #1c2230;
  --text-muted: #6b7488;
  --border: rgba(20,25,40,0.08);
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --shadow: 0 8px 30px rgba(20,25,40,0.08);
  --shadow-lg: 0 20px 60px rgba(20,25,40,0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 250px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-elevated: rgba(30,33,44,0.65);
  --bg-solid: #171922;
  --text: #eef0f6;
  --text-muted: #9099b0;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 8px 30px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background .25s, color .25s;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3,h4 { margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; color: var(--text-muted); }

.app-shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  backdrop-filter: blur(18px);
  border-inline-start: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: transform .25s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; padding: 0 8px 20px;
}
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #ec4899); box-shadow: 0 0 12px var(--primary); }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(99,102,241,0.08); color: var(--text); }
.sidebar-nav a.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: var(--shadow); }
.nav-icon { width: 18px; text-align: center; }
.sidebar-logout { margin-top: auto; }
.sidebar-logout button {
  width: 100%; padding: 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: transparent; color: var(--text-muted); cursor: pointer; font-family: inherit;
}
.sidebar-logout button:hover { background: rgba(220,38,38,0.08); color: var(--danger); }

/* ---------- Topbar ---------- */
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px; background: var(--bg-elevated); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--bg-solid); cursor: pointer; font-size: 16px; color: var(--text);
}
.user-chip { display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; font-weight: 600; }
.user-chip small { color: var(--text-muted); font-weight: 400; font-size: 11px; }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elevated); backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 700px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .sidebar-nav { flex-direction: row; overflow-x: auto; gap: 6px; }
  .sidebar-nav a { white-space: nowrap; }
}

/* ---------- KPI ---------- */
.kpi { border-radius: var(--radius); padding: 18px; background: var(--bg-elevated); border: 1px solid var(--border); box-shadow: var(--shadow); }
.kpi .kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi .kpi-value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.kpi .kpi-icon { float: inline-end; width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: rgba(99,102,241,0.12); color: var(--primary); font-size: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 10px 18px; border-radius: var(--radius-sm); border: none; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; transition: transform .1s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 6px 18px rgba(99,102,241,0.35); }
.btn-secondary { background: var(--bg-solid); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-solid); color: var(--text); font-family: inherit; font-size: 14px; margin-bottom: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.checkbox-row input { width: auto; margin: 0; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: rgba(99,102,241,0.04); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-success { background: rgba(22,163,74,0.12); color: var(--success); }
.badge-warning { background: rgba(217,119,6,0.12); color: var(--warning); }
.badge-danger { background: rgba(220,38,38,0.12); color: var(--danger); }
.badge-info { background: rgba(8,145,178,0.12); color: var(--info); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, rgba(99,102,241,0.18), transparent 40%), radial-gradient(circle at 80% 80%, rgba(236,72,153,0.15), transparent 40%), var(--bg); }
.login-card { width: 380px; padding: 34px; }
.login-card .brand-dot { display: block; margin: 0 auto 14px; width: 44px; height: 44px; border-radius: 14px; }
.login-title { text-align: center; font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.login-sub { text-align: center; font-size: 13px; margin-bottom: 22px; }
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-danger { background: rgba(220,38,38,0.1); color: var(--danger); border: 1px solid rgba(220,38,38,0.25); }
.alert-success { background: rgba(22,163,74,0.1); color: var(--success); border: 1px solid rgba(22,163,74,0.25); }
.alert-warning { background: rgba(245,158,11,0.12); color: #b45309; border: 1px solid rgba(245,158,11,0.3); }

/* ---------- Toasts ---------- */
.toast-host { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius-sm); background: var(--bg-solid); box-shadow: var(--shadow-lg); border: 1px solid var(--border); font-size: 13px; min-width: 220px; animation: toastIn .2s ease; }
.toast-success { border-inline-start: 4px solid var(--success); }
.toast-error { border-inline-start: 4px solid var(--danger); }
.toast-info { border-inline-start: 4px solid var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Wizard / Processing ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 22px; }
.step { flex: 1; padding: 10px; text-align: center; border-radius: var(--radius-sm); background: var(--bg-solid); border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-muted); }
.step.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; border-color: transparent; }
.step.done { background: rgba(22,163,74,0.12); color: var(--success); border-color: transparent; }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; transition: border-color .2s, background .2s; }
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: rgba(99,102,241,0.05); }

.progress-bar-outer { height: 10px; border-radius: 10px; background: var(--border); overflow: hidden; margin: 10px 0; }
.progress-bar-inner { height: 100%; background: linear-gradient(135deg, var(--primary), #ec4899); width: 0%; transition: width .3s; }

.position-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 220px; }
.position-cell { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; background: var(--bg-solid); }
.position-cell.selected { background: var(--primary); border-color: var(--primary); }
.position-cell span { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.position-cell.selected span { background: #fff; }

.preview-box { position: relative; background: #222 center/cover no-repeat; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/10; }
.preview-watermark { position: absolute; border-radius: 8px; font-family: 'Vazirmatn', sans-serif; line-height: 1.2; box-sizing: border-box; white-space: nowrap; }

.color-swatch { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--border); padding: 0; cursor: pointer; }

.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: center; }
.pagination a, .pagination span { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; }
.pagination a.active { background: var(--primary); color: #fff; border-color: transparent; }

.text-muted { color: var(--text-muted); font-size: 12px; }
.mt-2 { margin-top: 16px; } .mb-0 { margin-bottom: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
