/* =========================================================
   TaskFlow — Core Styles
   Design system: refined corporate, dual-theme, JetBrains Mono + Plus Jakarta Sans
========================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- THEME TOKENS ---------- */
:root {
  /* light */
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --surface-3: #f1f3f6;
  --border: #e6e8ee;
  --border-strong: #d8dce5;

  --text: #0c1322;
  --text-soft: #4a5365;
  --text-muted: #8993a4;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.10);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger:  #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --info: #0ea5e9;
  --info-soft: rgba(14, 165, 233, 0.12);
  --purple: #8b5cf6;
  --purple-soft: rgba(139, 92, 246, 0.14);

  --shadow-sm: 0 1px 2px rgba(10, 14, 30, 0.05);
  --shadow-md: 0 6px 18px -8px rgba(10, 14, 30, 0.18), 0 2px 4px rgba(10, 14, 30, 0.04);
  --shadow-lg: 0 20px 50px -16px rgba(10, 14, 30, 0.28), 0 4px 12px rgba(10, 14, 30, 0.06);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --sidebar-w: 248px;
  --topbar-h: 64px;

  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

[data-theme="dark"] {
  --bg: #0b0d12;
  --surface: #14171f;
  --surface-2: #181c26;
  --surface-3: #1f2430;
  --border: #242936;
  --border-strong: #2e3445;

  --text: #ecedf2;
  --text-soft: #b2b8c6;
  --text-muted: #7a8294;

  --accent: #7c75ff;
  --accent-hover: #9b95ff;
  --accent-soft: rgba(124, 117, 255, 0.16);

  --success-soft: rgba(16, 185, 129, 0.18);
  --warning-soft: rgba(245, 158, 11, 0.20);
  --danger-soft: rgba(239, 68, 68, 0.18);
  --info-soft: rgba(14, 165, 233, 0.18);
  --purple-soft: rgba(139, 92, 246, 0.22);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 6px 18px -8px rgba(0,0,0,0.55), 0 2px 4px rgba(0,0,0,0.25);
  --shadow-lg: 0 20px 50px -16px rgba(0,0,0,0.7), 0 4px 12px rgba(0,0,0,0.4);
}

/* ---------- UTILITIES ---------- */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--text-muted); }
.soft  { color: var(--text-soft); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--accent); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============= LOGIN ============= */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(14,165,233,0.10), transparent 60%),
    var(--bg);
}
.login-bg-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.45;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}
[data-theme="dark"] .login-bg-grid { opacity: 0.25; }

.login-shell {
  width: 100%;
  max-width: 460px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
}
.login-brand {
  display: flex; align-items: center; gap: 14px;
}
.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--accent);
  color: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px -10px var(--accent);
}
.brand-mark.sm { width: 32px; height: 32px; border-radius: 8px; }
.brand-name {
  margin: 0;
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
}
.brand-tag {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.login-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
}
.login-card-header h2 {
  margin: 0;
  font-size: 20px; font-weight: 700; letter-spacing: -0.01em;
}
.login-card-header p {
  margin: 6px 0 24px;
  color: var(--text-muted);
  font-size: 13.5px;
}
.login-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.login-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}
.divider {
  position: relative;
  text-align: center;
  margin: 22px 0 18px;
  color: var(--text-muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  position: absolute; top: 50%;
  width: calc(50% - 90px);
  height: 1px; background: var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }
.demo-users {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.demo-card {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.demo-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}
.demo-card .avatar { width: 32px; height: 32px; font-size: 13px; }
.demo-card .name { font-weight: 600; font-size: 13px; }
.demo-card .role { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

.login-footer {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* ============= BUTTONS ============= */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn-ghost {
  background: transparent;
  color: var(--text-soft);
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { filter: brightness(1.05); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

.link-btn {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  font-size: 12.5px;
}
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  transition: background .15s, color .15s;
  position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* Theme icons */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.notif-dot {
  position: absolute; top: 8px; right: 9px;
  width: 8px; height: 8px;
  background: var(--danger);
  border: 2px solid var(--surface);
  border-radius: 50%;
  display: none;
}
.notif-dot.has { display: block; }

/* ============= APP LAYOUT ============= */
.app-view { min-height: 100vh; display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-name {
  font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
}
.sidebar-nav {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 12px;
  flex: 1;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}
.user-card:hover { background: var(--surface-3); }
.user-card .name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-card .role { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.user-card .meta { flex: 1; min-width: 0; }
.user-card .meta .name,
.user-card .meta .role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.logout-menu {
  position: absolute; bottom: 100%; left: 0; right: 0;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 20;
}
.logout-menu button {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}
.logout-menu button:hover { background: var(--surface-3); }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.search-wrap {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-wrap input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-icon { position: absolute; left: 12px; width: 16px; height: 16px; color: var(--text-muted); }
.search-wrap kbd {
  position: absolute; right: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--surface-3);
  color: var(--text-muted);
  border-radius: 4px;
  border: 1px solid var(--border);
}
.topbar-actions {
  display: flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.mobile-only { display: none; }

.page {
  padding: 28px;
  max-width: 1500px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.page-title {
  margin: 0;
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
}
.page-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* ============= NOTIFICATIONS PANEL ============= */
.notif-panel {
  position: absolute;
  top: calc(var(--topbar-h) - 8px);
  right: 16px;
  width: 360px;
  max-height: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  animation: fadeSlide .18s ease;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.notif-head h4 { margin: 0; font-size: 14px; }
.notif-list { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 12px;
  cursor: pointer;
  transition: background .15s;
}
.notif-item:hover { background: var(--surface-3); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread:hover { background: var(--accent-soft); filter: brightness(0.98); }
.notif-item .ic {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--surface-3);
  color: var(--accent);
}
.notif-item .ic svg { width: 16px; height: 16px; }
.notif-item .body { flex: 1; min-width: 0; }
.notif-item .title { font-size: 13px; font-weight: 600; line-height: 1.35; }
.notif-item .meta  { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; font-family: var(--font-mono); }
.notif-empty {
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============= TOASTS ============= */
.toast-root {
  position: fixed;
  bottom: 22px; right: 22px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start;
  animation: toastIn .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.warning { border-left-color: var(--warning); }
.toast.error   { border-left-color: var(--danger); }
.toast .toast-title { font-weight: 600; }
.toast .toast-body { color: var(--text-soft); font-size: 12.5px; margin-top: 2px; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) translateX(10px); }
  to   { opacity: 1; transform: translateY(0)    translateX(0); }
}

/* ============= MODAL ============= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(10, 14, 30, 0.55);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn .15s ease;
}
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,0.7); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: modalIn .2s ease;
  overflow: hidden;
}
.modal.modal-wide { max-width: 880px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
  background: var(--surface-2);
}
.close-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-muted);
}
.close-btn:hover { background: var(--surface-3); color: var(--text); }

/* ============= RESPONSIVE ============= */
@media (max-width: 960px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .mobile-only { display: inline-grid; }
  .page { padding: 18px; }
  .search-wrap kbd { display: none; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 9px 11px; }
}
@media (max-width: 560px) {
  .search-wrap { max-width: none; }
  .demo-users { grid-template-columns: 1fr; }
}
