/* =========================================================
   TaskFlow design system
   Palette: deep teal (brand/action) + warm amber (signal/progress)
   Type: Manrope (display) / Inter (body) / Tajawal (Arabic) / Noto Sans SC (Chinese)
   Layout uses CSS logical properties throughout so RTL (Arabic)
   mirrors automatically without a separate stylesheet.
   ========================================================= */

:root {
  --ink: #1B2430;
  --ink-soft: #5B6470;
  --bg: #F5F7F8;
  --surface: #FFFFFF;
  --border: #E3E7EA;
  --brand: #1F4B4A;
  --brand-dark: #163837;
  --brand-tint: #E7EFEE;
  --amber: #D9A441;
  --amber-tint: #FBF1DD;
  --green: #3C8F72;
  --green-tint: #E7F4EF;
  --red: #C0533E;
  --red-tint: #FBEAE6;
  --blue-gray: #7C8798;
  --blue-gray-tint: #EEF1F4;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-card: 0 1px 2px rgba(27,36,48,0.04), 0 8px 24px -12px rgba(27,36,48,0.12);
  --shadow-pop: 0 20px 60px -20px rgba(27,36,48,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
}

body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.font-ar { font-family: 'Tajawal', 'Inter', sans-serif; }
body.font-zh { font-family: 'Noto Sans SC', 'Inter', sans-serif; }

h1, h2, h3, h4, .display {
  font-family: 'Manrope', 'Inter', sans-serif;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
body.font-ar h1, body.font-ar h2, body.font-ar h3, body.font-ar h4, body.font-ar .display {
  font-family: 'Tajawal', sans-serif;
  font-weight: 700;
}
body.font-zh h1, body.font-zh h2, body.font-zh h3, body.font-zh h4, body.font-zh .display {
  font-family: 'Noto Sans SC', sans-serif;
  font-weight: 700;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: var(--amber-tint); color: var(--brand-dark); }

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

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--brand);
  color: #EAF1F0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  inset-block-start: 0;
  block-size: 100vh;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-inline-start: 6px;
}
.brand-mark .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(217,164,65,0.25);
}
.brand-mark span {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}

.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  color: #CFE1DE;
  font-weight: 600;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.14); color: #fff; }
.nav-link .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar-footer {
  margin-block-start: auto;
  padding-block-start: 16px;
  border-block-start: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
  color: #BFD3D0;
}
.sidebar-footer .user-name { color: #fff; font-weight: 700; display: block; margin-block-end: 4px; }
.sidebar-footer a { color: #CFE1DE; font-weight: 600; }
.sidebar-footer a:hover { color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 100px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-block-end: 24px;
  flex-wrap: wrap;
}

.topbar h1 { font-size: 24px; }
.topbar .subtitle { color: var(--ink-soft); font-size: 14px; margin-block-start: 4px; }

.lang-switch {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.lang-switch a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.lang-switch a.active { background: var(--brand); color: #fff; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-s);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-amber { background: var(--amber); color: #3A2A08; }
.btn-amber:hover { filter: brightness(0.96); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--blue-gray-tint); }
.btn-danger { background: var(--red-tint); color: var(--red); }
.btn-danger:hover { background: #F5D9D2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards / board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.task-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px rgba(27,36,48,.05), 0 16px 32px -14px rgba(27,36,48,.18); }

.task-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.task-card-title { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 15.5px; line-height: 1.35; }
body.font-ar .task-card-title { font-family: 'Tajawal', sans-serif; }
body.font-zh .task-card-title { font-family: 'Noto Sans SC', sans-serif; }

.task-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.task-card-foot { display: flex; justify-content: space-between; align-items: center; padding-block-start: 10px; border-block-start: 1px dashed var(--border); }
.task-assignee { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }

.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--brand-tint); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; flex-shrink: 0;
}

/* Signature element: condition-completion ring on each task card */
.condition-ring {
  --pct: 0;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: conic-gradient(var(--amber) calc(var(--pct) * 1%), var(--blue-gray-tint) 0);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.condition-ring::after {
  content: attr(data-label);
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: var(--brand-dark);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.badge-pending { background: var(--blue-gray-tint); color: var(--blue-gray); }
.badge-progress { background: var(--brand-tint); color: var(--brand-dark); }
.badge-completed { background: var(--green-tint); color: var(--green); }
.badge-blocked { background: var(--red-tint); color: var(--red); }

.badge-prio-low { background: var(--blue-gray-tint); color: var(--blue-gray); }
.badge-prio-medium { background: var(--amber-tint); color: #8A6512; }
.badge-prio-high { background: #FCE7DC; color: #B15A24; }
.badge-prio-urgent { background: var(--red-tint); color: var(--red); }

.pending-flag {
  font-size: 11px; font-weight: 700; color: var(--amber);
  display: flex; align-items: center; gap: 4px;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-block-end: 16px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
input[type=text], input[type=email], input[type=password], input[type=date],
textarea, select {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-s);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
textarea { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,28,32,0.5);
  display: none;
  align-items: center; justify-content: center;
  padding: 16px;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-l);
  padding: 26px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-pop);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-block-end: 18px; }
.modal-close { cursor: pointer; color: var(--ink-soft); font-size: 20px; line-height: 1; padding: 4px; }

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 20px;
  margin-block-end: 20px;
}
.panel-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 15px;
  margin-block-end: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
body.font-ar .panel-title { font-family: 'Tajawal', sans-serif; }
body.font-zh .panel-title { font-family: 'Noto Sans SC', sans-serif; }

/* condition rows */
.condition-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-block-end: 1px solid var(--border); }
.condition-row:last-child { border-block-end: none; }
.condition-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--green); flex-shrink: 0; }
.condition-row.met span { text-decoration: line-through; color: var(--ink-soft); }

/* comments */
.comment { display: flex; gap: 10px; padding-block: 10px; border-block-end: 1px solid var(--border); }
.comment:last-child { border-block-end: none; }
.comment-body { flex: 1; }
.comment-meta { font-size: 12px; color: var(--ink-soft); margin-block-end: 3px; }
.comment-meta strong { color: var(--ink); }
.comment-text { font-size: 14px; }

.comment-form { display: flex; gap: 10px; margin-block-start: 14px; }
.comment-form textarea { flex: 1; min-height: 44px; }

/* follow-up list */
.followup-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-s);
  margin-block-end: 8px;
}

/* empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty-state .emoji { font-size: 36px; margin-block-end: 12px; }

/* login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-l);
  padding: 40px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-pop);
}
.login-card .brand-mark { justify-content: center; margin-block-end: 6px; }
.login-card .brand-mark span { color: var(--brand); }
.login-sub { text-align: center; color: var(--ink-soft); font-size: 13.5px; margin-block-end: 26px; }
.login-error {
  background: var(--red-tint); color: var(--red);
  padding: 10px 14px; border-radius: var(--radius-s);
  font-size: 13.5px; font-weight: 600; margin-block-end: 16px;
}
.login-lang-switch { display: flex; justify-content: center; gap: 14px; margin-block-start: 20px; }
.login-lang-switch a { font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.login-lang-switch a.active { color: var(--brand); }

/* table (staff management) */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: start; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); padding: 10px 12px; border-block-end: 2px solid var(--border);
}
.table td { padding: 12px; border-block-end: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.table tr:last-child td { border-block-end: none; }

/* mobile bottom nav */
.mobile-nav {
  display: none;
  position: fixed; inset-inline: 0; inset-block-end: 0;
  background: var(--surface);
  border-block-start: 1px solid var(--border);
  z-index: 50;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.mobile-nav-inner { display: flex; justify-content: space-around; }
.mobile-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 700; color: var(--ink-soft); padding: 6px 8px;
}
.mobile-nav a.active { color: var(--brand); }
.mobile-nav .ico { font-size: 17px; }

.mobile-topbar { display: none; }

/* toast */
#toast {
  position: fixed; inset-block-end: 24px; inset-inline: 0;
  display: flex; justify-content: center; z-index: 200; pointer-events: none;
}
#toast .toast-msg {
  background: var(--ink); color: #fff; padding: 10px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-pop);
  opacity: 0; transform: translateY(10px); transition: all .25s ease;
}
#toast .toast-msg.show { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: var(--brand); position: sticky; inset-block-start: 0; z-index: 40;
  }
  .mobile-topbar .brand-mark span { color: #fff; }
  .main { padding: 18px 16px 90px; }
  .mobile-nav { display: block; }
  .board { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .topbar { flex-direction: column; align-items: stretch; }
  .modal { padding: 20px; }
}
