/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg-base:       #f0f2f8;
  --bg-surface:    #ffffff;
  --bg-elevated:   #e8eaf0;
  --bg-sidebar:    #f5f6fb;
  --bg-topbar:     rgba(255,255,255,0.85);

  --text-primary:  #1a1a2e;
  --text-muted:    #6b7280;
  --text-inverse:  #ffffff;

  --accent:        #6c63ff;
  --accent-dim:    #ede9ff;
  --accent-dark:   #4f46e5;

  --danger:        #ef4444;
  --danger-dim:    #fee2e2;

  --border:        #dde1ec;
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.14);

  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;

  --transition:    all 0.18s ease;

  --topbar-h:      56px;
  --sidebar-w:     240px;
}

html.dark {
  --bg-base:       #0e0e1a;
  --bg-surface:    #13131f;
  --bg-elevated:   #1c1c2e;
  --bg-sidebar:    #111120;
  --bg-topbar:     rgba(19,19,31,0.92);

  --text-primary:  #e8e8f4;
  --text-muted:    #8888aa;
  --text-inverse:  #ffffff;

  --accent:        #6c63ff;
  --accent-dim:    #1e1b3a;
  --accent-dark:   #8b85ff;

  --danger:        #f87171;
  --danger-dim:    #2c1111;

  --border:        #25253a;
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.30);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.45);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.60);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Hide the app until Vue has mounted and removed v-cloak */
[v-cloak] { display: none !important; }

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
}
/* Transition added after first paint via JS to avoid flash */
body.transitions-ready {
  transition: background 0.25s, color 0.25s;
}

ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
button:disabled { cursor: not-allowed !important; opacity: 0.4; }
input, select { font-family: inherit; font-size: inherit; }

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--transition);
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(108,99,255,0.35); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

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

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.icon-btn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: var(--transition);
}
.icon-btn:hover { background: var(--accent-dim); color: var(--accent); }

.theme-toggle {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 1.1rem;
  transition: var(--transition);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.theme-toggle:hover { transform: rotate(20deg) scale(1.1); }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
  display: flex;
  padding-top: var(--topbar-h);
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.sidebar-sticky {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 20px 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 12px;
}

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.category-list { padding: 0 8px; }

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  gap: 8px;
}
.category-item:hover { background: var(--bg-elevated); }
.category-item.active {
  background: var(--accent);
  color: var(--text-inverse);
}
.category-item.active .category-delete { color: rgba(255,255,255,0.65); }
.category-item.active .category-delete:hover { color: #fff; background: rgba(255,255,255,0.15); }

.category-item.dragging, .task-row.dragging {
  opacity: 0.5;
  background: var(--bg-elevated);
}
.category-item.drag-over-up, .task-item.drag-over-up > .task-row {
  box-shadow: 0 -2px 0 var(--accent);
}
.category-item.drag-over-down, .task-item.drag-over-down {
  box-shadow: 0 2px 0 var(--accent);
}
.category-item.drag-over-up { border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.category-item.drag-over-down { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.task-item.drag-over-up > .task-row { border-top-left-radius: 0; border-top-right-radius: 0; }


.category-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-delete {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 4px;
  font-size: 1rem;
  color: var(--text-muted);
  opacity: 0;
  transition: var(--transition);
  flex-shrink: 0;
}
.category-item:hover .category-delete,
.category-item.active .category-delete { opacity: 1; }
.category-delete:hover { background: var(--danger-dim); color: var(--danger); }

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
  flex: 1;
  padding: 32px 36px;
  overflow-y: auto;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.main-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ============================================================
   TASK LIST & TASK ITEM
   ============================================================ */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-item { display: flex; flex-direction: column; gap: 0; }

.task-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.task-row:hover { box-shadow: var(--shadow-md); border-color: var(--accent); }

/* Stage circle */
.stage-circle {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: var(--transition);
  user-select: none;
}
.stage-circle:hover { transform: scale(1.12); }

.stage-circle--muted {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 2px solid var(--border);
}
.stage-circle--muted:hover { border-color: var(--accent); color: var(--accent); }

.stage-circle--outlined {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.stage-circle--outlined:hover { background: var(--accent-dim); }

.stage-circle--filled {
  background: var(--accent);
  color: #fff;
  border: 2px solid var(--accent);
}
.stage-circle--filled:hover { background: var(--accent-dark); }

/* Stage dropdown */
.stage-select {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  max-width: 130px;
}
.stage-select:hover { border-color: var(--accent); }
.stage-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,99,255,0.15); }

/* Task title */
.task-title {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.9rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  min-width: 0;
}
.task-title:hover { background: var(--bg-elevated); }
.task-title:focus {
  outline: none;
  background: var(--bg-elevated);
  box-shadow: 0 0 0 2px var(--accent);
}

/* +sub and × buttons */
.task-action-btn {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
  border: 1px solid transparent;
}
.task-action-btn:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.task-delete-btn {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}
.task-delete-btn:hover { color: var(--danger); background: var(--danger-dim); }

/* Subtasks */
.subtasks {
  margin-left: 36px;
  margin-top: 6px;
  border-left: 2px solid var(--accent-dim);
  padding-left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
html.dark .subtasks { border-left-color: #2a2550; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 480px;
  max-width: calc(100vw - 32px);
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}

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

.modal-sub {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 12px;
}

.modal-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.modal-form { display: flex; flex-direction: column; gap: 10px; }

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15);
}

/* Type list */
.type-list { display: flex; flex-direction: column; gap: 10px; }

.type-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.type-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.type-name { font-weight: 600; font-size: 0.875rem; }

.stage-badges { display: flex; flex-wrap: wrap; gap: 5px; }

.stage-badge {
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(108,99,255,0.2);
}

.empty-hint { color: var(--text-muted); font-size: 0.875rem; text-align: center; padding: 12px 0; }

/* ============================================================
   ERROR BANNER
   ============================================================ */
.error-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.2s ease;
}
.error-dismiss { opacity: 0.75; font-size: 0.8rem; }

/* ============================================================
   TOASTS
   ============================================================ */
/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  z-index: 500;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-surface);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: var(--radius-md) solid var(--accent);
  cursor: pointer;
  max-width: 380px;
  width: fit-content;
  min-width: 240px;
  transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.toast-success { border-left-color: #10b981; }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent); }

.toast-icon {
  font-size: 1.2rem;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}
.toast-success .toast-icon { color: #10b981; }
.toast-error .toast-icon { color: var(--danger); }
.toast-info .toast-icon { color: var(--accent); }

.toast-message {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
  white-space: normal;
}

/* Vue Transitions */
.toast-enter-from {
  transform: translateX(40px);
  opacity: 0;
}
.toast-leave-to {
  transform: translateX(40px);
  opacity: 0;
}
.toast-leave-active {
  position: absolute;
  right: 0;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
