/* ─────────────────────────────────────────────
   NDC Task Manager — Styles
   Colors: #F0187A (pink), #111 (bg), #1a1a1a (card)
───────────────────────────────────────────── */

:root {
  --pink:       #F0187A;
  --pink-dim:   #b01057;
  --bg:         #0e0e0e;
  --surface:    #1a1a1a;
  --surface2:   #222222;
  --border:     #2e2e2e;
  --border2:    #3a3a3a;
  --text:       #ffffff;
  --text-muted: #888888;
  --text-dim:   #555555;

  /* Category colors */
  --c-due-now:     #FF3B30;
  --c-due-soon:    #FF9F0A;
  --c-management:  #0A84FF;
  --c-inspiration: #30D158;
  --c-personal:    #BF5AF2;

  --radius:  8px;
  --radius-lg: 12px;
  --shadow:  0 2px 12px rgba(0,0,0,0.4);
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Utility ─────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── Login ───────────────────────────────── */
.login-mode { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.login-wrap {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-logo {
  margin-bottom: 32px;
  display: flex; align-items: baseline; gap: 2px;
}
.logo-mark { font-size: 28px; font-weight: 800; color: var(--pink); }
.logo-slash { font-size: 28px; font-weight: 800; color: var(--text-muted); margin: 0 2px; }
.logo-sub   { font-size: 18px; font-weight: 600; color: var(--text-muted); }

.login-error {
  background: rgba(255,59,48,0.12);
  border: 1px solid rgba(255,59,48,0.3);
  color: #FF6B6B;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Fields ──────────────────────────────── */
.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; }
.label-opt { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); }

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

input[type="text"], input[type="password"], input[type="date"],
select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  transition: border-color 0.15s;
  appearance: none;
}

/* Date picker calendar icon color */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  filter: invert(1);
}
input[type="date"]::-webkit-datetime-edit-fields-wrapper { color: var(--text); }
input[type="date"]::-webkit-datetime-edit-text { color: var(--text-muted); }
input[type="text"]:focus, input[type="password"]:focus,
input[type="date"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pink);
}
select { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea { resize: vertical; }

/* ── Buttons ─────────────────────────────── */
.btn-primary {
  background: var(--pink);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: #d4146b; }
.btn-primary:active { transform: scale(0.97); }
.btn-primary.full { width: 100%; padding: 13px; font-size: 15px; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  width: 36px; height: 36px;
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.btn-icon:hover { border-color: var(--pink); color: var(--pink); }
.btn-icon.small { width: 28px; height: 28px; font-size: 13px; }
.btn-icon.active { border-color: var(--pink); color: var(--pink); background: rgba(240,24,122,0.08); }

.btn-danger {
  background: rgba(255,59,48,0.12);
  color: #FF6B6B;
  border: 1px solid rgba(255,59,48,0.25);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: rgba(255,59,48,0.2); }

/* ── App Layout ──────────────────────────── */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  gap: 12px;
}

.header-left, .header-right { display: flex; align-items: center; gap: 12px; }

.logo { display: flex; align-items: baseline; }
.logo .logo-mark { font-size: 18px; font-weight: 800; color: var(--pink); }
.logo .logo-slash { font-size: 18px; font-weight: 800; color: var(--text-dim); }

.week-nav { display: flex; align-items: center; gap: 6px; }
.week-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; padding: 4px 6px; line-height: 1; transition: color 0.15s; }
.week-btn:hover { color: var(--text); }
#week-label { font-size: 13px; font-weight: 600; color: var(--text); min-width: 90px; text-align: center; }

.view-toggle { display: flex; gap: 4px; }
.view-btn {
  background: none; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-muted); cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 500; padding: 5px 10px;
  transition: all 0.15s; white-space: nowrap;
}
.view-btn:hover { border-color: var(--border2); color: var(--text); }
.view-btn.active { border-color: var(--pink); color: var(--pink); background: rgba(240,24,122,0.08); }

/* ── Quick Add Bar ───────────────────────── */
.quick-add-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  flex-shrink: 0;
}
.quick-add-inner { display: flex; gap: 8px; align-items: center; max-width: 1100px; }
.qa-select { flex-shrink: 0; width: auto; }
#qa-category { min-width: 140px; }
#qa-client   { min-width: 130px; }
.qa-input { flex: 1; min-width: 0; }

/* ── Main Layout ─────────────────────────── */
.main-layout {
  display: flex; flex: 1; overflow: hidden;
}

.task-area {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 24px;
}

.loading-state { color: var(--text-muted); font-size: 14px; padding: 40px 0; text-align: center; }

/* ── Category Groups ─────────────────────── */
.task-group { }

.group-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  user-select: none;
}

.group-icon { font-size: 18px; line-height: 1; }

.group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em;
  flex: 1;
}

.group-count {
  font-size: 11px; font-weight: 600;
  background: var(--surface2);
  border-radius: 20px;
  padding: 2px 8px;
  color: var(--text-muted);
}

.group-add { opacity: 0; transition: opacity 0.15s; }
.task-group:hover .group-add { opacity: 1; }

.group-list { display: flex; flex-direction: column; gap: 6px; min-height: 4px; }
.group-list.empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 16px; }

/* Category accent colors */
.group--due_now    .group-title { color: var(--c-due-now); }
.group--due_soon   .group-title { color: var(--c-due-soon); }
.group--management .group-title { color: var(--c-management); }
.group--inspiration .group-title { color: var(--c-inspiration); }
.group--personal   .group-title { color: var(--c-personal); }

/* ── Task Cards ──────────────────────────── */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  transition: border-color 0.2s, transform 0.15s;
  cursor: default;
  position: relative;
}

.task-card:hover { border-color: var(--border2); }
.task-card.done { opacity: 0.45; }
.task-card.done .task-title { text-decoration: line-through; color: var(--text-muted); }

/* Left accent bar */
.task-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; border-radius: 3px 0 0 3px;
  background: var(--border);
}
.task-card[data-cat="due_now"]    ::before,
.task-card[data-cat="due_now"]::before    { background: var(--c-due-now); }
.task-card[data-cat="due_soon"]::before   { background: var(--c-due-soon); }
.task-card[data-cat="management"]::before { background: var(--c-management); }
.task-card[data-cat="inspiration"]::before { background: var(--c-inspiration); }
.task-card[data-cat="personal"]::before   { background: var(--c-personal); }

/* Drag handle */
.drag-handle {
  color: var(--text-dim); cursor: grab; font-size: 14px; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s;
  padding: 2px 4px;
}
.task-card:hover .drag-handle { opacity: 1; }
.sortable-drag { opacity: 0.4; }
.sortable-ghost { background: var(--surface2); border-color: var(--pink); }

/* Status checkbox */
.status-btn {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border2);
  background: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; font-size: 10px;
}
.status-btn:hover { border-color: var(--pink); }
.status-btn.in_progress { border-color: var(--c-due-soon); background: rgba(255,159,10,0.15); }
.status-btn.done        { border-color: var(--c-inspiration); background: rgba(48,209,88,0.15); }
.status-btn.done::after { content: '✓'; color: var(--c-inspiration); font-weight: 700; }
.status-btn.in_progress::after { content: '▶'; color: var(--c-due-soon); }

/* Client badge */
.client-badge {
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  flex-shrink: 0; letter-spacing: 0.03em;
  background: rgba(255,255,255,0.06);
}

/* Task title */
.task-title {
  flex: 1; font-size: 14px; font-weight: 500; line-height: 1.35;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Time slider */
.time-wrap {
  display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.time-slider {
  -webkit-appearance: none; appearance: none;
  width: 70px; height: 4px; border-radius: 2px;
  background: var(--border2); outline: none; cursor: pointer;
}
.time-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--pink); cursor: pointer;
  transition: transform 0.1s;
}
.time-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
.time-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  min-width: 32px; text-align: right;
}
.time-label.has-time { color: var(--c-inspiration); }

/* Task actions */
.task-actions {
  display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; flex-shrink: 0;
}
.task-card:hover .task-actions { opacity: 1; }
.task-act-btn {
  background: none; border: none; color: var(--text);
  cursor: pointer; padding: 3px 5px; border-radius: 4px; font-size: 13px;
  transition: color 0.15s, background 0.15s;
}
.task-act-btn:hover { color: var(--pink); background: var(--surface2); }
.task-act-btn.delete:hover { color: #FF6B6B; background: rgba(255,59,48,0.12); }

/* ── Burn Animation (Due Now) ─────────────── */
@keyframes burnPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); border-color: rgba(255,59,48,0.3); }
  50%       { box-shadow: 0 0 14px 2px rgba(255,59,48,0.25); border-color: rgba(255,59,48,0.7); }
}
@keyframes flameFlicker {
  0%, 100% { transform: scaleY(1); }
  33%       { transform: scaleY(1.12) scaleX(0.9); }
  66%       { transform: scaleY(0.92) scaleX(1.08); }
}

.task-card.burning {
  animation: burnPulse 2.5s ease-in-out infinite;
}
.task-card.burning .task-title { color: #ffcccc; }
.group--due_now .group-icon { display: inline-block; animation: flameFlicker 1.8s ease-in-out infinite; }

/* ── Stats Panel ─────────────────────────── */
.stats-panel {
  width: 300px; flex-shrink: 0; border-left: 1px solid var(--border);
  background: var(--surface); overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 20px;
}
.stats-panel.hidden { display: none; }

.stats-header { display: flex; align-items: center; justify-content: space-between; }
.stats-header h3 { font-size: 14px; font-weight: 700; color: var(--text); }

.stat-block { }
.stat-block-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 12px; }

.stat-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-value { font-size: 15px; font-weight: 700; color: var(--text); }
.stat-value.pink   { color: var(--pink); }
.stat-value.green  { color: var(--c-inspiration); }
.stat-value.red    { color: var(--c-due-now); }
.stat-value.orange { color: var(--c-due-soon); }

/* Progress bar */
.prog-bar { height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.prog-fill { height: 100%; border-radius: 3px; background: var(--c-inspiration); transition: width 0.4s ease; }

/* Mini bar chart */
.mini-chart { display: flex; align-items: flex-end; gap: 4px; height: 50px; }
.mini-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mini-bar {
  width: 100%; border-radius: 3px 3px 0 0;
  background: var(--c-inspiration);
  transition: height 0.4s ease;
  min-height: 2px;
}
.mini-bar.burn { background: var(--c-due-now); }
.mini-bar-label { font-size: 9px; color: var(--text-dim); }

/* Mood indicator */
.mood-block { text-align: center; padding: 12px; background: var(--surface2); border-radius: var(--radius); }
.mood-emoji { font-size: 36px; display: block; margin-bottom: 6px; }
.mood-text  { font-size: 12px; color: var(--text-muted); }

/* Category breakdown */
.cat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cat-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.cat-name { font-size: 12px; color: var(--text-muted); flex: 1; }
.cat-bar-wrap { width: 80px; height: 6px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 3px; }
.cat-pct { font-size: 11px; font-weight: 600; color: var(--text); min-width: 28px; text-align: right; }

/* ── Modal ───────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%; max-width: 460px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; }

/* ── Client Group View ───────────────────── */
.client-group-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 8px;
}
.client-group-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.client-group-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
  .app-header { padding: 0 14px; height: 52px; }
  .quick-add-bar { padding: 8px 14px; }
  .quick-add-inner { flex-wrap: wrap; }
  #qa-category, #qa-client { min-width: calc(50% - 4px); font-size: 15px; }
  .qa-input { order: 3; width: 100%; font-size: 16px; } /* 16px prevents iOS zoom */
  #qa-add { order: 4; width: 100%; padding: 12px; font-size: 16px; }
  .task-area { padding: 12px; gap: 16px; }
  .view-toggle { display: none; }
  .stats-panel { position: fixed; right: 0; top: 52px; bottom: 0; z-index: 50; width: 280px; box-shadow: -4px 0 20px rgba(0,0,0,0.5); }
  .time-wrap { display: none; }
  .task-actions { opacity: 1; }
  .drag-handle { opacity: 0.4; }
  .field-row { flex-direction: column; }
  .field-group.half { width: 100%; }
  #week-label { min-width: 70px; font-size: 13px; }
  .group-icon { font-size: 20px; }
  .group-title { font-size: 13px; }
  .group-count { font-size: 12px; }
  .task-card { padding: 12px 12px; gap: 10px; }
  .task-title { font-size: 15px; }
  .client-badge { font-size: 11px; padding: 3px 8px; }
  .status-btn { width: 24px; height: 24px; }
  .task-act-btn { padding: 6px 8px; font-size: 15px; }
}

@media (max-width: 480px) {
  html { font-size: 16px; }
  .logo-mark, .logo-slash { font-size: 17px; }
  .app-header { gap: 8px; padding: 0 12px; }
  .header-right { gap: 6px; }
  .btn-icon { width: 34px; height: 34px; font-size: 17px; }
  .week-btn { font-size: 20px; }
  #week-label { font-size: 13px; }
}