/* =========================================================
   میز کار پشتیبانی — Design System
   یک هلپ‌دسک داخلی: آرام، قابل‌اعتماد، دقیق مثل یک باجه صدور بلیت
   ========================================================= */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn[wght].woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn-SemiBold.woff2') format('woff2');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn-ExtraBold.woff2') format('woff2');
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../fonts/vazir/Vazirmatn-Black.woff2') format('woff2');
  font-weight: 900; font-style: normal; font-display: swap;
}

:root {
  /* ---- palette ---- */
  --ink: #16233F;
  --ink-2: #1E2E52;
  --ink-3: #29406F;
  --paper: #F1F4F9;
  --surface: #FFFFFF;
  --accent: #0F8B8D;
  --accent-dark: #0B6E70;
  --accent-soft: #E3F4F3;
  --gold: #D69A17;
  --gold-soft: #FBF0D8;
  --line: #E3E7EF;
  --line-strong: #CBD3E1;
  --text: #1B2434;
  --text-muted: #6C7688;
  --text-faint: #96A0B2;
  --danger: #D9463A;
  --danger-soft: #FBE7E5;

  /* ---- status / priority ---- */
  --status-open-fg: #2158C7; --status-open-bg: #E7EFFD;
  --status-progress-fg: #B9800A; --status-progress-bg: #FCF1D6;
  --status-resolved-fg: #1B8F60; --status-resolved-bg: #E2F5EC;
  --status-closed-fg: #6C7688; --status-closed-bg: #EDEFF3;

  --priority-urgent-fg: #C23B2E; --priority-urgent-bg: #FBE4E1;
  --priority-high-fg: #C06A16; --priority-high-bg: #FBE9D8;
  --priority-normal-fg: #2158C7; --priority-normal-bg: #E7EFFD;
  --priority-low-fg: #6C7688; --priority-low-bg: #EDEFF3;

  /* ---- metrics ---- */
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 3px rgba(17, 28, 51, 0.07);
  --shadow-md: 0 10px 30px -8px rgba(17, 28, 51, 0.18);
  --shadow-lg: 0 24px 60px -16px rgba(17, 28, 51, 0.32);
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
  background: var(--paper);
  color: var(--text);
  direction: rtl;
  text-align: right;
  font-size: 15px;
  line-height: 1.7;
}

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; font-weight: 700; }
p { margin: 0 0 1em; color: var(--text); }
a { color: var(--accent-dark); }
small, .text-muted { color: var(--text-muted) !important; }

::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* =============== APP SHELL =============== */

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

.sidebar {
  position: fixed; top: 0; right: 0;
  width: var(--sidebar-w); height: 100vh;
  background: linear-gradient(180deg, var(--ink) 0%, var(--ink-2) 100%);
  color: #EAF0FB;
  display: flex; flex-direction: column;
  padding: 22px 16px;
  z-index: 40;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 12px; margin-bottom: 22px;
}
.sidebar-brand img { width: 38px; height: 38px; border-radius: 9px; background: #fff; object-fit: contain; padding: 3px; }
.sidebar-brand .name { font-weight: 800; font-size: .98rem; color: #fff; }
.sidebar-brand .role { font-size: .74rem; color: #9FB0CE; margin-top: 1px; }

.sidebar-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-section { font-size: .68rem; color: #7C8CAE; font-weight: 700; letter-spacing: .04em; margin: 14px 10px 6px; text-transform: uppercase; }
.sidebar-section:first-child { margin-top: 2px; }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: #C9D5EC; text-decoration: none;
  font-size: .89rem; font-weight: 500;
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.nav-link svg { flex-shrink: 0; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; font-weight: 700; }
.nav-link.active svg { opacity: 1; }
.nav-link .badge-count {
  margin-inline-start: auto; background: var(--gold); color: #3A2A02;
  font-size: .68rem; font-weight: 800; padding: 1px 7px; border-radius: 20px;
}

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); margin-top: 10px; padding-top: 10px; }

.main { margin-right: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(241,244,249,.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar h1 { margin: 0; font-size: 1.28rem; }
.topbar-eyebrow { font-size: .74rem; color: var(--text-faint); font-weight: 600; margin-bottom: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { display: flex; align-items: center; gap: 9px; font-size: .86rem; color: var(--text-muted); }
.topbar-user strong { color: var(--ink); }
.avatar-dot {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: .9rem;
}

.content { padding: 26px 28px 60px; flex: 1; }

@media (max-width: 900px) {
  .sidebar { width: 76px; padding: 16px 10px; }
  .sidebar-brand { flex-direction: column; text-align: center; padding: 10px 4px; }
  .sidebar-brand .name, .sidebar-brand .role, .sidebar-section { display: none; }
  .nav-link span.label { display: none; }
  .nav-link { justify-content: center; }
  .nav-link .badge-count { position: absolute; top: 2px; left: 2px; margin: 0; }
  .main { margin-right: 76px; }
  .content { padding: 18px 14px 50px; }
  .topbar { padding: 14px 16px; }
}

/* =============== CARDS / SURFACES =============== */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.i-accent { background: var(--accent-soft); color: var(--accent-dark); }
.stat-icon.i-gold { background: var(--gold-soft); color: var(--gold); }
.stat-icon.i-danger { background: var(--danger-soft); color: var(--danger); }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--ink); line-height: 1.2; }
.stat-label { font-size: .8rem; color: var(--text-muted); font-weight: 500; }

/* =============== TICKET STUB MOTIF =============== */

.ticket-card {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
  text-decoration: none; color: inherit; display: block;
}
.ticket-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); border-color: var(--line-strong); text-decoration: none; color: inherit; }
.ticket-card::before {
  content: ""; position: absolute; top: -1px; right: 28px;
  width: 16px; height: 16px; background: var(--paper);
  border: 1px solid var(--line); border-top: none; border-radius: 0 0 50% 50%;
}
.ticket-row-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ticket-id { font-weight: 800; color: var(--accent-dark); font-size: .82rem; letter-spacing: .02em; }
.ticket-stub-divider { width: 1px; align-self: stretch; min-height: 14px; border-right: 1.5px dashed var(--line-strong); }
.ticket-subject { font-weight: 700; color: var(--ink); font-size: 1rem; }
.ticket-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; font-size: .8rem; color: var(--text-muted); align-items: center; }
.ticket-meta .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--text-faint); }

/* =============== BADGES / PILLS =============== */

.badge-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 30px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge-pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

.status-open { color: var(--status-open-fg); background: var(--status-open-bg); }
.status-open .dot { background: var(--status-open-fg); }
.status-in_progress, .status-progress { color: var(--status-progress-fg); background: var(--status-progress-bg); }
.status-in_progress .dot, .status-progress .dot { background: var(--status-progress-fg); }
.status-resolved { color: var(--status-resolved-fg); background: var(--status-resolved-bg); }
.status-resolved .dot { background: var(--status-resolved-fg); }
.status-closed { color: var(--status-closed-fg); background: var(--status-closed-bg); }
.status-closed .dot { background: var(--status-closed-fg); }

.priority-urgent { color: var(--priority-urgent-fg); background: var(--priority-urgent-bg); }
.priority-urgent .dot { background: var(--priority-urgent-fg); }
.priority-high { color: var(--priority-high-fg); background: var(--priority-high-bg); }
.priority-high .dot { background: var(--priority-high-fg); }
.priority-normal, .priority-medium { color: var(--priority-normal-fg); background: var(--priority-normal-bg); }
.priority-normal .dot, .priority-medium .dot { background: var(--priority-normal-fg); }
.priority-low { color: var(--priority-low-fg); background: var(--priority-low-bg); }
.priority-low .dot { background: var(--priority-low-fg); }

.badge-unread { position: relative; }
.badge-unread::after {
  content: ""; position: absolute; top: -3px; left: -3px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
  animation: pulse-ring 1.8s ease-in-out infinite;
}
@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(217,70,58,.5); }
  70% { box-shadow: 0 0 0 6px rgba(217,70,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(217,70,58,0); }
}

/* =============== BUTTONS =============== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-weight: 700; font-size: .88rem;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); color: #fff; text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; text-decoration: none; }
.btn-gold { background: var(--gold); color: #3A2A02; }
.btn-gold:hover { background: #C08B0F; color: #3A2A02; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* =============== FORMS =============== */

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 700; font-size: .85rem; color: var(--ink); margin-bottom: 6px; }
.field .hint { font-size: .76rem; color: var(--text-faint); margin-top: 4px; }

.form-control, input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="time"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%; font-family: inherit; font-size: .9rem;
  padding: 10px 13px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.form-control:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft);
}
select { cursor: pointer; }

.input-row { display: flex; gap: 12px; flex-wrap: wrap; }
.input-row > * { flex: 1; min-width: 160px; }

/* =============== TABLES =============== */

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
table.data-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
table.data-table thead th {
  background: var(--paper); color: var(--text-muted);
  font-weight: 700; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em;
  padding: 12px 16px; text-align: right; border-bottom: 1px solid var(--line);
}
table.data-table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background .12s ease; }
table.data-table tbody tr:hover { background: var(--paper); }

/* =============== ALERTS / EMPTY STATES =============== */

.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: .87rem; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: var(--status-resolved-bg); color: var(--status-resolved-fg); border-color: #C6EBD8; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #F3C9C4; }
.alert-info { background: var(--status-open-bg); color: var(--status-open-fg); border-color: #CFE0FA; }

.empty-state { text-align: center; padding: 54px 20px; color: var(--text-muted); }
.empty-state .glyph { font-size: 2rem; margin-bottom: 10px; opacity: .6; }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }

/* =============== AUTH (login/register) =============== */

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--paper); padding: 24px; }
.auth-card {
  display: flex; width: 100%; max-width: 860px;
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; min-height: 480px;
}
.auth-brand {
  flex: 1;
  background: radial-gradient(120% 120% at 20% 0%, var(--ink-3) 0%, var(--ink) 60%, var(--ink-2) 100%);
  color: #fff; padding: 46px 38px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative;
}
.auth-brand::after {
  content: ""; position: absolute; inset-inline-end: -14px; top: 0; bottom: 0; width: 28px;
  background-image: radial-gradient(circle, var(--paper) 7px, transparent 7.5px);
  background-size: 28px 28px; background-position: center; background-repeat: repeat-y;
}
.auth-brand img { width: 56px; height: 56px; background: #fff; border-radius: 14px; padding: 8px; }
.auth-brand h1 { color: #fff; font-size: 1.5rem; margin-top: 18px; }
.auth-brand p { color: #B9C6E2; font-size: .9rem; }
.auth-brand .tag { font-size: .74rem; color: #8FA0C4; letter-spacing: .04em; font-weight: 700; text-transform: uppercase; }

.auth-form { flex: 1; padding: 46px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-form h2 { margin-bottom: 4px; }
.auth-form .sub { color: var(--text-muted); font-size: .87rem; margin-bottom: 26px; }

@media (max-width: 720px) {
  .auth-brand { display: none; }
  .auth-form { padding: 34px 26px; }
}

/* =============== MISC =============== */

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-muted); font-size: .87rem; margin-top: 2px; }
.section-gap { margin-bottom: 26px; }
.chip-list { display: flex; gap: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); border: none; margin: 20px 0; }

/* =============== JALALI DATEPICKER =============== */

.jdp-field { position: relative; }
.jdp-field input {
  cursor: pointer; background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236C7688' stroke-width='1.7'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 12px center;
  padding-inline-start: 34px;
}
.jdp-popover {
  position: absolute; z-index: 200; top: calc(100% + 6px); inset-inline-start: 0;
  width: 288px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 14px; display: none;
}
.jdp-popover.open { display: block; animation: jdp-in .12s ease; }
@keyframes jdp-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.jdp-head .jdp-title { font-weight: 800; color: var(--ink); font-size: .92rem; }
.jdp-nav-btn { width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.jdp-nav-btn:hover { background: var(--paper); color: var(--ink); }
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.jdp-dow { font-size: .68rem; color: var(--text-faint); font-weight: 700; padding-bottom: 6px; }
.jdp-day { padding: 7px 0; border-radius: 8px; font-size: .82rem; cursor: pointer; color: var(--text); border: none; background: transparent; font-family: inherit; }
.jdp-day:hover { background: var(--accent-soft); color: var(--accent-dark); }
.jdp-day.jdp-today { border: 1.5px solid var(--accent); }
.jdp-day.jdp-selected { background: var(--accent); color: #fff; font-weight: 800; }
.jdp-day.jdp-muted { color: var(--text-faint); opacity: .5; }
.jdp-foot { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.jdp-foot button { background: none; border: none; font-family: inherit; font-size: .78rem; font-weight: 700; color: var(--accent-dark); cursor: pointer; }
.jdp-foot button:hover { text-decoration: underline; }
