/* =========================================================
   1303task design system — v2 "Blue"
   Palette: vivid royal blue (brand/action) + cyan accent (progress/highlight)
            amber reserved for warnings/pending states only
   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: #10152A;
  --ink-soft: #5B6478;
  --bg: #F3F5FC;
  --surface: #FFFFFF;
  --border: #E4E8F5;

  --brand: #2E56F2;
  --brand-dark: #16297A;
  --brand-light: #5B82FF;
  --brand-tint: #EAF0FF;

  --accent: #06B6D4;
  --accent-tint: #E1F8FC;

  --amber: #D9A441;
  --amber-tint: #FBF1DD;
  --green: #34A374;
  --green-tint: #E5F6EE;
  --red: #E1503F;
  --red-tint: #FCEAE7;
  --blue-gray: #7C86A6;
  --blue-gray-tint: #EEF1FA;

  --radius-s: 8px;
  --radius-m: 14px;
  --radius-l: 20px;
  --shadow-card: 0 1px 2px rgba(16,21,42,0.04), 0 8px 24px -12px rgba(30,60,180,0.14);
  --shadow-pop: 0 24px 60px -20px rgba(20,35,110,0.35);
  --shadow-glow: 0 6px 20px -6px rgba(46,86,242,0.45);
}

* { 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(--accent-tint); color: var(--brand-dark); }

/* ---------- Layout shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: linear-gradient(165deg, var(--brand-dark) 0%, var(--brand) 100%);
  color: #E3EAFF;
  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(--accent);
  box-shadow: 0 0 0 4px rgba(6,182,212,0.28);
}
.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: #C7D3FA;
  font-weight: 600;
  font-size: 14px;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.16); 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.14);
  font-size: 13px;
  color: #B7C4EF;
}
.sidebar-footer .user-name { color: #fff; font-weight: 700; display: block; margin-block-end: 4px; }
.sidebar-footer a { color: #C7D3FA; font-weight: 600; }
.sidebar-footer a:hover { color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 100px;
  position: relative;
}

.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: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover { filter: brightness(1.05); }
.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: #F9D9D2; }
.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, border-color .15s ease;
}
.task-card:hover {
  transform: translateY(-2px);
  border-color: var(--brand-light);
  box-shadow: 0 4px 6px rgba(16,21,42,.05), 0 18px 36px -14px rgba(46,86,242,.28);
}

.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(--accent) 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(8,14,36,0.55);
  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(--brand); 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;
  padding: 20px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(600px circle at 15% 20%, rgba(6,182,212,0.35), transparent 60%),
    radial-gradient(700px circle at 85% 80%, rgba(91,130,255,0.4), transparent 60%),
    linear-gradient(165deg, var(--brand-dark) 0%, var(--brand) 100%);
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-l);
  padding: 40px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-pop);
  position: relative;
}
.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); }

/* ---------- Notification bell + panel ---------- */
.bell-btn {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-topbar .bell-btn { background: rgba(255,255,255,0.12); border-color: transparent; }
.bell-badge {
  position: absolute;
  top: -4px; inset-inline-end: -4px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 2px solid var(--surface);
}
.mobile-topbar .bell-badge { border-color: var(--brand-dark); }

.desktop-notif-bar { display: flex; justify-content: flex-end; margin-block-end: -8px; }

.notif-panel {
  position: absolute;
  inset-inline-end: 32px;
  inset-block-start: 56px;
  width: 340px;
  max-height: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-pop);
  display: none;
  flex-direction: column;
  z-index: 90;
  overflow: hidden;
}
.notif-panel.open { display: flex; }
.notif-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-block-end: 1px solid var(--border);
  font-weight: 800; font-size: 14px;
}
#notifList { overflow-y: auto; }
.notif-item {
  display: flex; gap: 10px; padding: 12px 16px;
  border-block-end: 1px solid var(--border);
  color: var(--ink);
}
.notif-item:last-child { border-block-end: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--brand-tint); }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); margin-block-start: 6px; flex-shrink: 0;
  opacity: 0;
}
.notif-item.unread .notif-dot { opacity: 1; }
.notif-msg { font-size: 13.5px; line-height: 1.4; }
.notif-time { font-size: 11.5px; color: var(--ink-soft); margin-block-start: 3px; }

@media (max-width: 900px) {
  .notif-panel { inset-inline-end: 12px; inset-inline-start: 12px; inset-block-start: 60px; width: auto; }
}

/* ---------- Summary board ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-block-end: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}
.stat-card-warn { border-color: var(--red); background: var(--red-tint); }
.stat-label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; margin-block-end: 8px; }
.stat-value { font-family: 'Manrope', sans-serif; font-weight: 800; font-size: 30px; color: var(--ink); }
.stat-value-accent { color: var(--brand); }
.stat-value-warn { color: var(--red); }

.progress-bar {
  display: flex;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--blue-gray-tint);
  margin-block-end: 14px;
}
.progress-seg { height: 100%; transition: width .3s ease; }
.progress-completed { background: var(--green); }
.progress-inprogress { background: var(--brand); }
.progress-blocked { background: var(--red); }
.progress-pending { background: var(--blue-gray); }

.progress-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.progress-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 5px; }
.dot-completed { background: var(--green); }
.dot-inprogress { background: var(--brand); }
.dot-blocked { background: var(--red); }
.dot-pending { background: var(--blue-gray); }

.mini-ring {
  --pct: 0;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: conic-gradient(var(--green) calc(var(--pct) * 1%), var(--blue-gray-tint) 0);
  flex-shrink: 0;
}

/* ---------- Activity timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: 12px;
  padding-block-end: 14px;
  position: relative;
}
.timeline-item::before {
  content: '';
  position: absolute;
  inset-inline-start: 3px;
  inset-block-start: 14px;
  inset-block-end: 0;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  margin-block-start: 5px;
  flex-shrink: 0;
}
.timeline-text { font-size: 13.5px; }
.timeline-time { font-size: 11.5px; color: var(--ink-soft); margin-block-start: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; background: linear-gradient(135deg, var(--brand-dark), 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; }
  .desktop-notif-bar { display: none; }
}
.mobile-nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0 10px;
    overflow-x: auto; /* Allows swiping if too many icons */
    gap: 15px;
    /* hide scrollbar */
    -ms-overflow-style: none;  
    scrollbar-width: none;  
}

.mobile-nav-list::-webkit-scrollbar {
    display: none; 
}

.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    white-space: nowrap;
}
