/* ============================================================
   electrojiz — Persian RTL PWA style
   Palette from brand logo:
   --black:#0A0A0B  --dark:#16181A  --yellow:#FFC400  --yellow-soft:#FFD84D
   --white:#FFFFFF  --gray:#8A8F98
   Mobile-first, works down to 390px. Cards: 16px radius.
   ============================================================ */

@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-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --black: #0A0A0B;
  --dark: #16181A;
  --yellow: #FFC400;
  --yellow-soft: #FFD84D;
  --white: #FFFFFF;
  --gray: #8A8F98;
  --bg: #F3F4F6;
  --green: #0A7A3D;
  --red: #C22525;
  --border: #E4E6EA;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--black);
  line-height: 1.8;
  min-height: 100vh;
}

/* ---------- Header & tabs (black) ---------- */
.app-header {
  background: var(--black);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  height: 44px;
  width: auto;
  border-radius: 10px;
  background: var(--black);
  border: 1px solid #2A2D31;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.5; }
.brand-text strong { font-size: 18px; }
.brand-text span { font-size: 11px; color: var(--gray); letter-spacing: 0.3px; }

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* tabs */
.tabs {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 8px 6px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  border: 0;
  background: transparent;
  color: var(--gray);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
}
.tab.active { background: var(--black); color: var(--yellow); }
.tab:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn:focus-visible { outline: 2px solid var(--black); outline-offset: 2px; }
.btn-primary { background: var(--yellow); color: var(--black); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 1px solid #3A3E44;
}
.btn-ghost:hover { border-color: var(--gray); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid #EAB6B6; }
.btn-danger:hover { background: #FBEDED; }
.btn-next { background: var(--dark); color: var(--yellow-soft); border: 1px solid #2E3237; }

/* ---------- Layout ---------- */
main {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 12px 40px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(10, 10, 11, 0.06);
}

.card-title { font-size: 15px; margin-bottom: 12px; }

.muted { color: var(--gray); font-size: 13px; }

.notice {
  background: var(--yellow-soft);
  color: var(--black);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ---------- Stat cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 720px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-card { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.stat-label { font-size: 12px; color: var(--gray); }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-green { color: var(--green); }
.stat-red { color: var(--red); }

/* ---------- Forms ---------- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 720px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.form-grid .full { grid-column: 1 / -1; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--white);
  color: var(--black);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--yellow);
  border-color: var(--yellow);
}
textarea { resize: vertical; }

.form-actions { display: flex; justify-content: flex-start; padding-top: 4px; }

/* ---------- Search & chips ---------- */
.search-box { margin-bottom: 12px; }

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chip {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--black);
  cursor: pointer;
}
.chip.active { background: var(--black); border-color: var(--black); color: var(--yellow); }
.chip:focus-visible { outline: 2px solid var(--yellow); }

/* ---------- Lists & rows ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
@media (min-width: 720px) {
  .row { flex-direction: row; align-items: center; justify-content: space-between; }
}

.row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-title { font-weight: 700; font-size: 14px; }
.row-sub { font-size: 12.5px; color: var(--gray); overflow-wrap: anywhere; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  width: fit-content;
}
.badge-green { background: #E5F3EB; color: var(--green); }
.badge-red { background: #FBEAEA; color: var(--red); }
.badge-black { background: var(--black); color: var(--yellow); }
.badge-gray { background: #EFF0F2; color: var(--black); }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.mini-list { display: flex; flex-direction: column; gap: 10px; }
.mini-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

/* ---------- Chart ---------- */
.chart-wrap { width: 100%; height: 240px; }

.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 13px; }
.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-inline-end: 6px;
}
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }

/* ---------- Ticket (black/yellow) ---------- */
.ticket {
  background: var(--black);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  color: var(--white);
}
.ticket.hidden, .hidden { display: none; }
.ticket-code {
  color: var(--yellow);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.ticket-sms {
  font-size: 13.5px;
  color: #D9DBDF;
  border-inline-start: 3px solid var(--yellow);
  padding-inline-start: 10px;
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

/* ---------- Chat ---------- */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
  margin-bottom: 12px;
}
.msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  overflow-wrap: anywhere;
}
.msg-user {
  align-self: flex-start;
  background: var(--dark);
  color: var(--white);
}
.msg-bot {
  align-self: flex-end;
  background: #FFF7DB;
  border: 1px solid #F2E2A0;
  color: var(--black);
}

.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }

/* ---------- SMS templates ---------- */
.sms-templates { display: grid; gap: 12px; }
@media (min-width: 720px) { .sms-templates { grid-template-columns: 1fr 1fr; } }

.sms-tpl {
  font-family: inherit;
  text-align: start;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
}
.sms-tpl b { font-size: 13.5px; }
.sms-text { font-size: 12.5px; color: var(--gray); overflow-wrap: anywhere; line-height: 1.9; }

/* ---------- Footer (black) ---------- */
.app-footer {
  background: var(--black);
  color: var(--white);
  padding: 24px 16px 28px;
  margin-top: 24px;
}
.app-footer .footer-logo {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  margin-bottom: 12px;
  display: block;
}
.app-footer strong { font-size: 15px; }
.app-footer p { font-size: 12.5px; color: #C9CDD4; margin-top: 4px; max-width: 640px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  inset-inline: 16px;
  bottom: 18px;
  background: var(--black);
  color: var(--yellow-soft);
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 16px;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Login / role gate ---------- */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--black);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.login-screen.hidden { display: none; }
.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-logo {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  align-self: center;
}
.login-card h2 { font-size: 16px; text-align: center; }
.login-roles { display: flex; gap: 8px; justify-content: center; }
.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form .muted { font-size: 12px; text-align: center; }

/* fix: .hidden must win over .login-form display:flex */
.hidden { display: none !important; }

/* ================= V3 additions ================= */
.full-width { width: 100%; }
.stat-red { color: var(--red); }

/* status timeline (repair detail modal) */
.tl { display: flex; flex-direction: column; gap: 0; margin: 8px 0 14px; }
.tl-item { display: flex; gap: 10px; position: relative; padding-bottom: 14px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; background: #D7DBE0; flex-shrink: 0; margin-top: 5px; position: relative; z-index: 1; }
.tl-item.done .tl-dot { background: var(--green); }
.tl-item::before { content: ""; position: absolute; right: 4.5px; top: 16px; bottom: 0; width: 1.5px; background: #E4E6EA; }
.tl-item:last-child::before { display: none; }
.tl-item.done::before { background: var(--green); }
.tl-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tl-what { font-weight: 700; font-size: 13.5px; }
.tl-when { font-size: 11.5px; color: var(--gray); }
.tl-note { font-size: 12.5px; background: #F3F4F6; border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; }
.tl-item.done .tl-what { color: var(--black); }

/* detail modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,10,11,.55); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 14px;
}
.modal {
  background: #fff; border-radius: 16px; max-width: 560px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 16px;
}
.modal h3 { margin: 0 0 6px; font-size: 16px; }
.modal .muted { margin: 2px 0 10px; }
.m-section { border-top: 1px solid #ECEDEF; padding-top: 10px; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.m-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* inputs inside modal */
.modal label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; }
.modal input, .modal select, .modal textarea {
  border: 1px solid #D7DBE0; border-radius: 10px; padding: 9px 12px;
  font: inherit; font-weight: 400; background: #fff; width: 100%;
  box-sizing: border-box;
}
.modal .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* admin-eye: profit & secrets — admin only */
.admin-eye { display: none; }
body[data-role="admin"] .admin-eye { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
span.admin-eye { display: none; }
body[data-role="admin"] span.admin-eye { display: inline-flex; gap: 6px; align-items: center; }

/* worker-only notes */
.worker-eye { display: none; }
body[data-role="repairman"] .worker-eye { display: block; }

/* assignment card inside modal */
.req {
  border: 1px solid #ECEDEF; border-radius: 12px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px; background: #FAFBFC;
}
.req .row-actions { margin-top: 4px; }
.req-accepted { border-color: var(--green); background: #F3FBF6; }
.req-rejected { opacity: .55; }

/* worker panel inside modal */
.worker-box { border: 1px dashed #C9CED6; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: #FBFCFD; }
.worker-box h4 { margin: 0; font-size: 13.5px; }

/* ads banner */
.ad-banner { border: 2px dashed var(--yellow); background: #FFFDF2; }
.ad-banner .ad-title { font-weight: 800; font-size: 14.5px; margin-bottom: 4px; }
.ad-banner .ad-body { font-size: 13.5px; white-space: pre-wrap; }
.ad-banner .ad-link { margin-top: 6px; font-weight: 700; color: var(--black); text-decoration: underline; }

/* sync bar + refresh */
.mode-bar-ok { background: #E5F3EB; color: #0A7A3D; }
.mode-bar-off { background: #FFF7DB; color: #8a6d00; border: 1px solid #F2E2A0; }
.sync-btn {
  border: 1px solid #D7DBE0; background: #fff; border-radius: 10px;
  padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 700; margin-right: 8px; cursor: pointer;
}
.mini-note { font-size: 11.5px; color: var(--gray); }
