/* ================================================================
   Task Management Platform — Base Styles
   ================================================================ */

:root {
  --primary:    #1677ff;
  --success:    #52c41a;
  --warning:    #faad14;
  --danger:     #ff4d4f;
  --info:       #1890ff;
  --sidebar-w:  250px;
  --header-h:   64px;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
  --shadow-md:  0 4px 20px rgba(0,0,0,.12);
  --sidebar-bg: #0f1923;
  --sidebar-border: rgba(255,255,255,.07);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f6fb;
  color: #1a202c;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[dir="rtl"],
[dir="rtl"] * {
  font-family: 'Noto Sans Arabic', Tahoma, -apple-system, sans-serif;
}

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

.app-sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
  overflow: hidden;
}

[dir="rtl"] .app-sidebar { right: 0; left: auto; }
[dir="ltr"] .app-sidebar { left: 0; right: auto; }

.app-main { flex: 1; min-height: 100vh; transition: margin .3s ease; }
[dir="ltr"] .app-main { margin-left: var(--sidebar-w); }
[dir="rtl"] .app-main { margin-right: var(--sidebar-w); }

/* ── Sidebar: Logo ──────────────────────────────────────────── */
.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 11px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(22,119,255,.35);
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.2px;
}

/* ── Sidebar: Nav ───────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  padding: 6px 10px 4px;
  color: rgba(255,255,255,.3);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  transition: all .18s ease;
  position: relative;
}

.sidebar-link:hover {
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.07);
}

.sidebar-link.active {
  color: #fff;
  background: rgba(22,119,255,.25);
  box-shadow: inset 0 0 0 1px rgba(22,119,255,.3);
}

.sidebar-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  opacity: .8;
}

.sidebar-link.active .sidebar-link-icon { opacity: 1; }

.sidebar-link-label { flex: 1; }

/* ── Sidebar: Footer ────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--sidebar-border);
  padding: 12px 10px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  margin-bottom: 4px;
}

.sidebar-user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: #fff;
  flex-shrink: 0;
}

.sidebar-user-details { overflow: hidden; }
.sidebar-user-name {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,.9);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px; color: rgba(255,255,255,.35);
  text-transform: uppercase; letter-spacing: .06em;
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 0 #f0f0f0, 0 2px 8px rgba(0,0,0,.04);
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-user-name { font-weight: 600; font-size: 13.5px; color: #333; }

.hamburger-btn {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: 7px; color: #666; border-radius: 7px;
  transition: background .2s;
}
.hamburger-btn:hover { background: #f5f5f5; }

.header-page-title { font-size: 15px; font-weight: 600; color: #1a202c; }

.header-user {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
}

.header-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #1677ff, #0958d9);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}

/* Language toggle */
.lang-toggle {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  border: 1.5px solid #e8e8e8; border-radius: 20px;
  cursor: pointer; font-size: 12.5px; font-weight: 500;
  background: #fafafa; color: #555;
  transition: all .2s;
}
.lang-toggle:hover { border-color: var(--primary); color: var(--primary); background: #f0f7ff; }

/* ── Notification Bell ──────────────────────────────────────── */
.notif-bell {
  position: relative; cursor: pointer;
  padding: 8px; border-radius: 9px;
  border: none; background: none;
  transition: background .2s; color: #555;
  display: flex; align-items: center;
}
.notif-bell:hover { background: #f5f5f5; }

.notif-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  background: var(--danger); color: #fff;
  border-radius: 8px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; line-height: 1;
  border: 2px solid #fff;
}

/* ── Online Dot ─────────────────────────────────────────────── */
.online-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #d9d9d9;
}
.online-dot.online  { background: var(--success); box-shadow: 0 0 0 2px rgba(82,196,26,.2); }
.online-dot.offline { background: #d9d9d9; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform .18s, box-shadow .18s;
  border: 1px solid rgba(0,0,0,.04);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-body .stat-value { font-size: 28px; font-weight: 700; line-height: 1; color: #1a202c; }
.stat-body .stat-label { font-size: 12.5px; color: #8c8c8c; margin-top: 3px; }

/* ── Priority & Status Tags ─────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}

.tag-critical { background: #fff1f0; color: #cf1322; border-color: #ffa39e; }
.tag-high     { background: #fff7e6; color: #d46b08; border-color: #ffd591; }
.tag-medium   { background: #fffbe6; color: #d48806; border-color: #ffe58f; }
.tag-low      { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }

.tag-pending  { background: #fff7e6; color: #d46b08; border-color: #ffd591; }
.tag-started  { background: #e6f4ff; color: #0958d9; border-color: #91caff; }
.tag-done     { background: #f6ffed; color: #389e0d; border-color: #b7eb8f; }
.tag-failed   { background: #fff1f0; color: #cf1322; border-color: #ffa39e; }
.tag-blocked  { background: #f9f0ff; color: #531dab; border-color: #d3adf7; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.05);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #f5f5f5;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: 14.5px; color: #1a202c;
  gap: 8px;
}
.card-header-icon {
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 20px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  background: #fafafa; padding: 11px 16px;
  text-align: start; font-weight: 600; color: #6b7280;
  border-bottom: 1px solid #f0f0f0; white-space: nowrap;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
  vertical-align: middle;
}
.data-table tr:hover td { background: #fafbff; }
.data-table tr:last-child td { border-bottom: none; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: #374151; margin-bottom: 7px;
}
.form-label .required { color: var(--danger); margin-inline-start: 2px; }
.form-control {
  width: 100%; padding: 9px 13px;
  border: 1.5px solid #e5e7eb; border-radius: 8px;
  font-size: 14px; background: #fafafa; color: #1a202c;
  transition: border-color .2s, box-shadow .2s, background .15s;
  font-family: inherit;
}
.form-control:focus {
  outline: none; border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(22,119,255,.1);
}
.form-control.error { border-color: var(--danger); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .18s; text-decoration: none; white-space: nowrap;
  font-family: inherit; line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #0958d9; border-color: #0958d9; box-shadow: 0 4px 12px rgba(22,119,255,.3); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #389e0d; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #cf1322; }

.btn-outline { background: #fff; color: #555; border-color: #d9d9d9; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f0f7ff; }

.btn-ghost { background: transparent; color: #666; border-color: transparent; }
.btn-ghost:hover { background: #f5f5f5; color: #333; }

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* Currently-active status button on the task detail page */
.btn.status-btn-active {
  cursor: default;
  box-shadow: 0 0 0 3px rgba(22,119,255,.2);
  opacity: 1;
}

/* ── Flash messages ─────────────────────────────────────────── */
.flash {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 18px; font-size: 13.5px;
  display: flex; align-items: center; gap: 9px;
  border: 1px solid transparent;
}
.flash-success { background: #f6ffed; border-color: #b7eb8f; color: #389e0d; }
.flash-error   { background: #fff1f0; border-color: #ffa39e; color: #cf1322; }
.flash-warning { background: #fffbe6; border-color: #ffe58f; color: #d48806; }
.flash-info    { background: #e6f4ff; border-color: #91caff; color: #0958d9; }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid #f0f0f0;
  margin-bottom: 20px; gap: 0;
}

.tab-btn {
  padding: 10px 20px; font-size: 13.5px; color: #8c8c8c;
  cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .2s; font-weight: 500;
  display: flex; align-items: center; gap: 7px;
  font-family: inherit;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Notification items ─────────────────────────────────────── */
.notif-list { display: flex; flex-direction: column; }

.notif-item {
  display: flex; gap: 13px;
  padding: 15px 18px;
  border-bottom: 1px solid #f5f5f5;
  transition: background .15s; position: relative;
  cursor: pointer;
}
.notif-item:hover { background: #fafbff; }
.notif-item.unread { background: #f4f8ff; }
.notif-item.unread::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 3px; background: var(--primary);
}
[dir="ltr"] .notif-item.unread::before { left: 0; }
[dir="rtl"] .notif-item.unread::before { right: 0; }

/* Flip directional icons in RTL (back arrow, etc.) */
.rtl-flip { display: inline-flex; align-items: center; }
[dir="rtl"] .rtl-flip { transform: scaleX(-1); }

.notif-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.notif-icon-assigned  { background: #e6f4ff; color: #1677ff; }
.notif-icon-status    { background: #f6ffed; color: #52c41a; }
.notif-icon-watcher   { background: #fff7e6; color: #fa8c16; }
.notif-icon-system    { background: #f9f0ff; color: #722ed1; }

.notif-content { flex: 1; min-width: 0; }
.notif-message { font-size: 13.5px; color: #333; line-height: 1.5; }
.notif-meta    { font-size: 12px; color: #aaa; margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.notif-receipt { font-size: 11px; color: var(--success); display: flex; align-items: center; gap: 3px; }

/* Critical notification */
.notif-critical { background: #fff5f5 !important; }
.notif-critical .notif-message { color: #cf1322; font-weight: 600; }
.notif-critical-bar {
  position: absolute; top: 0; inset-inline-start: 0; inset-inline-end: 0;
  height: 2px;
  background: linear-gradient(90deg, #ff4d4f, #ff7875, #ff4d4f);
  background-size: 200% 100%;
  animation: criticalPulse 1.5s ease-in-out infinite;
}
@keyframes criticalPulse {
  0%,100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* ── Timeline / History ─────────────────────────────────────── */
.timeline { position: relative; padding-inline-start: 28px; }
.timeline::before {
  content: ''; position: absolute; top: 0; bottom: 0; width: 2px; background: #f0f0f0;
}
[dir="ltr"] .timeline::before { left: 9px; }
[dir="rtl"] .timeline::before { right: 9px; }

.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot {
  position: absolute; width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); top: 4px;
  border: 2px solid #fff; box-shadow: 0 0 0 2px var(--primary);
}
[dir="ltr"] .timeline-dot { left: -23px; }
[dir="rtl"] .timeline-dot { right: -23px; }
.timeline-content { background: #fafafa; border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.timeline-time { font-size: 11px; color: #aaa; margin-top: 4px; }

/* ── Page header ────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: #1a202c; margin: 0; letter-spacing: -.3px; }
.page-subtitle { font-size: 13px; color: #8c8c8c; margin: 3px 0 0; }

/* ── Kanban ─────────────────────────────────────────────────── */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(200px, 1fr));
  gap: 16px; align-items: start;
  overflow-x: auto; padding-bottom: 16px;
}
.kanban-col { min-width: 200px; }
.kanban-col-header {
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
  font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  color: #fff;
}
.kanban-col-body {
  min-height: 200px; display: flex; flex-direction: column; gap: 10px;
  padding: 10px; background: #f4f6fb;
  border-radius: 0 0 var(--radius) var(--radius);
}
.kanban-card {
  background: #fff; border-radius: 8px; padding: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); font-size: 13px;
  border-top: 3px solid transparent; transition: box-shadow .2s, transform .15s;
}
.kanban-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kanban-pending .kanban-col-header  { background: #fa8c16; }
.kanban-started .kanban-col-header  { background: #1677ff; }
.kanban-done    .kanban-col-header  { background: #52c41a; }
.kanban-failed  .kanban-col-header  { background: #ff4d4f; }
.kanban-blocked .kanban-col-header  { background: #722ed1; }
.kanban-pending .kanban-card  { border-color: #fa8c16; }
.kanban-started .kanban-card  { border-color: #1677ff; }
.kanban-done    .kanban-card  { border-color: #52c41a; }
.kanban-failed  .kanban-card  { border-color: #ff4d4f; }
.kanban-blocked .kanban-card  { border-color: #722ed1; }

/* ── Task Cards Grid ────────────────────────────────────────── */
.task-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}

.task-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.05);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .18s, transform .15s;
  border-top: 3px solid transparent;
}
.task-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

/* Border top color by priority */
.task-card[data-priority="critical"] { border-top-color: #ff4d4f; }
.task-card[data-priority="high"]     { border-top-color: #fa8c16; }
.task-card[data-priority="medium"]   { border-top-color: #faad14; }
.task-card[data-priority="low"]      { border-top-color: #52c41a; }

.task-card-top {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap;
}

.task-card-title {
  font-size: 14px; font-weight: 600; color: #1a202c;
  text-decoration: none; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.task-card-title:hover { color: var(--primary); }

.task-card-desc {
  font-size: 12.5px; color: #6b7280; line-height: 1.5; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.task-card-meta { display: flex; flex-direction: column; gap: 4px; }
.task-card-meta-row {
  display: flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: #555;
}

.task-card-footer {
  display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px;
  padding-top: 10px; border-top: 1px solid #f5f5f5;
}

@media (max-width: 600px) {
  .task-cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (max-width: 380px) {
  .task-cards-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-start  { text-align: start; }
.text-end    { text-align: end; }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.ms-auto { margin-inline-start: auto; }
.w-100   { width: 100%; }
.text-muted  { color: #9ca3af; font-size: 13px; }
.ellipsis    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fw-600      { font-weight: 600; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 24px; color: #bbb; }
.empty-state-icon { margin-bottom: 14px; display: flex; justify-content: center; }
.empty-state p { font-size: 14px; color: #aaa; }

/* ── Overlay ────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.45); z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ── Browser notification permission banner ─────────────────── */
#notif-permission-banner {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: min(560px, calc(100vw - 32px));
  background: #fff; border: 1px solid #e8e8e8; border-radius: 14px;
  padding: 16px 20px;
  box-shadow: 0 8px 32px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
  z-index: 10000; opacity: 0;
  transition: opacity .35s ease, transform .35s cubic-bezier(0.34,1.56,0.64,1);
}
#notif-allow-btn:hover   { background: #0958d9 !important; }
#notif-dismiss-btn:hover { border-color: #1677ff !important; color: #1677ff !important; }

/* ── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(0,0,0,.1); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Task row highlight on real-time update */
@keyframes rowHighlight { 0% { background: #fffbe6; } 100% { background: transparent; } }
.row-updated { animation: rowHighlight 1.5s ease-out; }

/* ── App content ────────────────────────────────────────────── */
.app-content { padding: 24px; max-width: 1400px; margin: 0 auto; }

/* ── Section headings ───────────────────────────────────────── */
.section-heading {
  font-size: 15px; font-weight: 700; color: #1a202c;
  margin: 0 0 16px; padding-bottom: 10px;
  border-bottom: 2px solid #f0f0f0;
  display: flex; align-items: center; gap: 8px;
}

/* ── Dashboard two-column grid ──────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ── Performance / Stats components ────────────────────────── */
.perf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* Donut chart card */
.donut-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.05);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.donut-card-title {
  font-size: 13px; font-weight: 600; color: #6b7280;
  text-align: center; text-transform: uppercase; letter-spacing: .05em;
}
.donut-wrap { position: relative; width: 120px; height: 120px; }
.donut-svg { transform: rotate(-90deg); }
.donut-bg   { fill: none; stroke: #f0f2f5; stroke-width: 10; }
.donut-fill { fill: none; stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .8s ease; }
.donut-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.donut-pct   { font-size: 22px; font-weight: 700; color: #1a202c; line-height: 1; }
.donut-sub   { font-size: 11px; color: #aaa; margin-top: 2px; }
.donut-meta  { font-size: 13px; color: #555; text-align: center; }

/* Stat bar (priority / status distribution) */
.stat-bars { width: 100%; display: flex; flex-direction: column; gap: 9px; }
.stat-bar-row { display: flex; align-items: center; gap: 8px; }
.stat-bar-label { font-size: 12px; color: #555; width: 60px; flex-shrink: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.stat-bar-track {
  flex: 1; height: 8px; background: #f0f2f5; border-radius: 10px; overflow: hidden;
}
.stat-bar-fill  { height: 100%; border-radius: 10px; transition: width .6s ease; }
.stat-bar-count { font-size: 12px; font-weight: 600; color: #333; width: 28px; text-align: end; flex-shrink: 0; }

/* User performance table card */
.perf-table-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,.05);
  overflow: hidden;
  margin-bottom: 24px;
}

/* Mini progress bar inside table */
.mini-bar-track {
  width: 80px; height: 6px; background: #f0f2f5; border-radius: 10px; overflow: hidden; display: inline-block;
}
.mini-bar-fill  { height: 100%; border-radius: 10px; background: var(--success); transition: width .5s ease; }

/* Avg days badge */
.avg-days-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #f0f7ff; color: #0958d9;
  border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600;
}

/* Alert badge (overdue) */
.overdue-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fff1f0; color: #cf1322;
  border-radius: 20px; padding: 4px 12px; font-size: 13px; font-weight: 600;
  border: 1px solid #ffa39e;
}

@media (max-width: 600px) {
  .perf-grid { grid-template-columns: 1fr; gap: 14px; }
  .stat-bar-label { width: 48px; font-size: 11px; }
  .mini-bar-track { width: 50px; }
}

/* ── Task detail layout ─────────────────────────────────────── */
.task-detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  align-items: start;
}
.task-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ================================================================
   RESPONSIVE — Mobile & Tablet
   ================================================================ */

/* ── Tablet (≤ 900px) ─────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }

  /* Sidebar: hidden off-screen, slides in on open */
  .app-sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: 260px;
    box-shadow: none;
  }
  [dir="rtl"] .app-sidebar {
    transform: translateX(100%);
    left: auto; right: 0;
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,.25);
  }
  [dir="rtl"] .app-sidebar.open {
    box-shadow: -4px 0 32px rgba(0,0,0,.25);
  }

  /* Main area fills full width */
  [dir="ltr"] .app-main { margin-left: 0; }
  [dir="rtl"] .app-main { margin-right: 0; }

  /* Show hamburger button */
  .hamburger-btn { display: flex; }

  /* Tighten header */
  .app-header { padding: 0 16px; }
  .header-user-name { display: none; }

  /* Content padding */
  .app-content { padding: 16px; }

  /* Stat cards: 2 columns */
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Task detail: single column */
  .task-detail-grid { grid-template-columns: 1fr; }
  .task-meta-grid   { grid-template-columns: 1fr 1fr; }

  /* Kanban: scrollable row */
  .kanban-board {
    grid-template-columns: repeat(5, 240px);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px;
    scrollbar-width: thin;
  }

  /* Tabs: scrollable */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; padding: 10px 14px; }

  /* Filter bar: wrap tightly */
  #task-filters { gap: 10px; }
  #task-filters > div { min-width: 0 !important; flex: 1 1 140px; }

  /* Page header: stack on overflow */
  .page-header { gap: 10px; }
  .page-header .btn { white-space: nowrap; }

  /* Cards */
  .card-body { padding: 16px; }
  .card-header { padding: 14px 16px; }

  /* Users table: shrink avatar column */
  .data-table th, .data-table td { padding: 10px 12px; }
}

/* ── Mobile (≤ 600px) ─────────────────────────────────────────── */
@media (max-width: 600px) {
  .app-content { padding: 12px; }

  /* Stat cards: 2 per row, more compact */
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card  { padding: 14px 12px; gap: 10px; }
  .stat-icon  { width: 40px; height: 40px; border-radius: 10px; }
  .stat-body .stat-value { font-size: 22px; }
  .stat-body .stat-label { font-size: 11px; }

  /* Meta grid: single column */
  .task-meta-grid { grid-template-columns: 1fr; }

  /* Page title */
  .page-title { font-size: 17px; }

  /* Buttons in page-header: wrap */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header > div:last-child,
  .page-header > a { align-self: flex-start; }

  /* Table: hide less-important columns on small phones */
  .data-table .hide-mobile { display: none; }

  /* Notification items: tighter */
  .notif-item { padding: 12px 14px; gap: 10px; }
  .notif-icon { width: 34px; height: 34px; }

  /* Form: full width selects */
  .form-control { font-size: 16px; /* prevent iOS zoom */ }

  /* Tabs: icon only on very small */
  .tab-btn { font-size: 12.5px; padding: 8px 12px; gap: 5px; }

  /* Buttons: smaller */
  .btn { padding: 8px 14px; font-size: 13px; }
  .btn-sm { padding: 5px 10px; font-size: 11.5px; }

  /* Filter inputs stack */
  #task-filters { flex-direction: column; gap: 8px; }
  #task-filters > div { flex: 1 1 auto !important; min-width: 100% !important; }
  #filter-search-clear { top: 38px !important; }

  /* Kanban: narrower cards, still scrollable */
  .kanban-board { grid-template-columns: repeat(5, 200px); gap: 10px; }
  .kanban-col-body { padding: 8px; gap: 8px; }
  .kanban-card { padding: 10px; }

  /* Cards */
  .card-body { padding: 14px; }
  .card-header { padding: 12px 14px; font-size: 13.5px; }

  /* Task action buttons: wrap */
  .task-actions { flex-wrap: wrap; gap: 6px; }

  /* Timeline: tighter */
  .timeline { padding-inline-start: 22px; }
  .timeline-content { padding: 8px 12px; }

  /* Header */
  .app-header { padding: 0 12px; gap: 8px; }
  .lang-toggle { padding: 5px 8px; font-size: 11.5px; }
  .lang-label { display: none; } /* hide text, keep globe icon */

  /* Notification permission banner: full-width bottom sheet */
  #notif-permission-banner {
    bottom: 0; left: 0; right: 0;
    width: 100% !important;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%) !important;
  }
  #notif-permission-banner.visible {
    transform: translateY(0) !important;
  }
}

/* ── Dashboard live-update animations ───────────────────────── */
@keyframes stat-number-glow {
  0%   { color: inherit; text-shadow: none; }
  20%  { color: #1677ff; text-shadow: 0 0 12px rgba(22,119,255,.5); }
  100% { color: inherit; text-shadow: none; }
}
@keyframes card-pulse-glow {
  0%   { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
  20%  { box-shadow: 0 0 0 3px rgba(22,119,255,.22), 0 4px 16px rgba(22,119,255,.12); }
  100% { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
}
@keyframes activity-slide-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stat-value.stat-updated   { animation: stat-number-glow 1.4s ease-out forwards; }
.stat-card.card-updated    { animation: card-pulse-glow  1.4s ease-out forwards; }
.timeline-item.log-new     { animation: activity-slide-in .35s ease-out; }

/* ── Notification Dropdown ───────────────────────────────────── */
.notif-bell-wrap { position: relative; }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 340px;
  background: #fff;
  border: 1px solid #e8e8e8;
  border-radius: 14px;
  box-shadow: 0 8px 36px rgba(0,0,0,0.13);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease;
  overflow: hidden;
}
.notif-dropdown.open { opacity: 1; pointer-events: all; transform: translateY(0); }
[dir="rtl"] .notif-dropdown { right: auto; left: 0; }

.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f0f0f0;
}
.notif-dropdown-title { font-size: 14px; font-weight: 600; color: #111; }
.notif-dropdown-mark-all {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: #1677ff; padding: 0; font-family: inherit;
}
.notif-dropdown-mark-all:hover { text-decoration: underline; }

.notif-dropdown-list { max-height: 360px; overflow-y: auto; }

.notif-dropdown-loading { display: flex; justify-content: center; padding: 24px; }

.notif-dropdown-empty {
  text-align: center; padding: 28px 16px;
  color: #bbb; font-size: 13px;
}

.notif-dropdown-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid #f8f8f8;
  cursor: pointer; transition: background .12s;
}
.notif-dropdown-item:last-child { border-bottom: none; }
.notif-dropdown-item:hover { background: #f8f9ff; }
.notif-dropdown-item.unread { background: #f0f5ff; }
.notif-dropdown-item.unread:hover { background: #e6efff; }

.notif-dropdown-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #1677ff; flex-shrink: 0; margin-top: 5px;
}
.notif-dropdown-msg { font-size: 13px; color: #333; line-height: 1.45; }
.notif-dropdown-time { font-size: 11px; color: #aaa; margin-top: 3px; }

.notif-dropdown-footer {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 11px 16px; font-size: 13px; color: #1677ff;
  text-decoration: none; border-top: 1px solid #f0f0f0;
  font-weight: 500; transition: background .12s;
}
.notif-dropdown-footer:hover { background: #f0f5ff; }

@media (max-width: 600px) {
  .notif-dropdown { width: calc(100vw - 24px); right: -12px; }
  [dir="rtl"] .notif-dropdown { left: -12px; right: auto; }
}

/* ── Status-change Modal ─────────────────────────────────────── */
.status-modal-overlay {
  position: fixed; inset: 0; z-index: 4000;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  opacity: 0; transition: opacity .18s ease;
}
.status-modal-overlay.open { opacity: 1; }

.status-modal-card {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 380px;
  padding: 24px; box-shadow: 0 16px 48px rgba(0,0,0,0.18);
  transform: translateY(-14px) scale(.97);
  transition: transform .2s ease;
}
.status-modal-overlay.open .status-modal-card {
  transform: translateY(0) scale(1);
}

.status-modal-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 6px;
}
.status-modal-head-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: #f0f5ff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.status-modal-title {
  font-size: 15px; font-weight: 600; color: #111;
}
.status-modal-subtitle {
  font-size: 13px; color: #666; margin-bottom: 16px;
  padding-inline-start: 52px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.status-modal-notes {
  width: 100%; box-sizing: border-box; margin-bottom: 18px;
  resize: vertical; min-height: 72px;
}
.status-modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ── Extra small (≤ 380px) ────────────────────────────────────── */
@media (max-width: 380px) {
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card  { padding: 12px 10px; gap: 8px; }
  .stat-icon  { width: 34px; height: 34px; border-radius: 8px; }
  .stat-body .stat-value { font-size: 20px; }
  .app-content { padding: 10px; }
  .page-title { font-size: 16px; }
}
