/* ===== DESIGN TOKENS ===== */
:root {
  --bg: #0d0f14;
  --bg2: #13161d;
  --bg3: #1a1e28;
  --surface: #1e2230;
  --surface2: #252a3a;
  --border: #2e3348;
  --border2: #3a4060;

  --text: #e8ecf4;
  --text2: #9aa3be;
  --text3: #5a6380;

  --accent: #7c6af5;
  --accent2: #9d8ff7;
  --accent-glow: rgba(124, 106, 245, 0.25);

  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --orange: #f97316;

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

  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm: 0 2px 12px rgba(0,0,0,0.3);

  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  --transition: 0.2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--text); }

/* ===== NAVBAR ===== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 64px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
}

.brand-icon {
  color: var(--accent);
  font-size: 1.1rem;
  animation: spin-slow 8s linear infinite;
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
}
.nav-link:hover { color: var(--text); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-left: 1.5rem;
  border-left: 1px solid var(--border);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text2);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border2);
  color: var(--text3);
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition);
}
.btn-logout:hover { border-color: var(--red); color: var(--red); }

/* ===== MAIN LAYOUT ===== */
.app-main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2.5rem 2rem 4rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.page-sub {
  color: var(--text3);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ===== STATS ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}
.stat-card:hover, .stat-card.active {
  border-color: var(--accent);
  background: var(--surface2);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
  color: var(--text);
}

.stat-num {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.stat-card.active .stat-num { color: var(--accent2); }

.stat-label {
  font-size: 0.78rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}

.stat-pending .stat-num { color: var(--yellow); }
.stat-progress .stat-num { color: var(--blue); }
.stat-done .stat-num { color: var(--green); }
.stat-overdue { border-color: rgba(239,68,68,0.3); }
.stat-overdue .stat-num { color: var(--red); }

/* ===== FILTER BAR ===== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  flex: 1;
  transition: border-color var(--transition);
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-input::placeholder { color: var(--text3); }

.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cat-chip {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  background: transparent;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text2);
  transition: all var(--transition);
  text-decoration: none;
}
.cat-chip:hover, .cat-chip.active {
  border-color: var(--cat-color);
  background: color-mix(in srgb, var(--cat-color) 12%, transparent);
  color: var(--cat-color);
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cat-color);
  flex-shrink: 0;
}

/* ===== TASK LIST ===== */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-card:hover {
  border-color: var(--border2);
  background: var(--surface2);
}

.task-card.priority-high { border-left-color: var(--red); }
.task-card.priority-medium { border-left-color: var(--yellow); }
.task-card.priority-low { border-left-color: var(--green); }
.task-card.task-completed { opacity: 0.6; }

/* Checkbox */
.task-check { padding-top: 2px; }

.task-toggle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  appearance: none;
  cursor: pointer;
  background: transparent;
  transition: all var(--transition);
  position: relative;
}
.task-toggle:checked {
  background: var(--green);
  border-color: var(--green);
}
.task-toggle:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}
.task-toggle:hover:not(:checked) { border-color: var(--accent); }

/* Task body */
.task-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.task-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.task-title.done {
  text-decoration: line-through;
  color: var(--text3);
}

.task-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.badge-cat { border-width: 1px; }

.badge-priority-high { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-priority-medium { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-priority-low { background: rgba(34,197,94,0.15); color: var(--green); }

.badge-status-pending { background: rgba(156,163,175,0.15); color: var(--text3); }
.badge-status-in-progress { background: rgba(59,130,246,0.15); color: var(--blue); }
.badge-status-completed { background: rgba(34,197,94,0.15); color: var(--green); }

.task-desc {
  font-size: 0.875rem;
  color: var(--text2);
  margin-bottom: 0.5rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text3);
}

.task-due { display: flex; align-items: center; gap: 0.25rem; }
.task-due.overdue { color: var(--red); font-weight: 600; }

/* Task actions */
.task-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: center;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-icon:hover { border-color: var(--accent); color: var(--accent); }
.btn-delete:hover { border-color: var(--red); color: var(--red); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text3);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.3rem; color: var(--text2); margin-bottom: 0.5rem; }
.empty-state p { margin-bottom: 1.5rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent2);
  border-color: var(--accent2);
  color: white;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border2);
}

.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--red);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.2); }

.btn-full { width: 100%; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ===== FORMS ===== */
.form-page {
  max-width: 640px;
  margin: 0 auto;
}

.form-header {
  margin-bottom: 2rem;
}

.back-link {
  font-size: 0.85rem;
  color: var(--text3);
  display: inline-block;
  margin-bottom: 0.75rem;
}
.back-link:hover { color: var(--accent2); }

.form-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
}

.task-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text2);
}

.required { color: var(--red); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
textarea,
select {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color var(--transition);
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder { color: var(--text3); }

select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235a6380' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

select option { background: var(--bg3); }

textarea { resize: vertical; min-height: 80px; }

.color-picker {
  height: 42px;
  padding: 0.2rem;
  cursor: pointer;
  width: 80px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ===== AUTH ===== */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3rem;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.auth-brand {
  margin-bottom: 2.5rem;
}

.brand-icon-lg {
  font-size: 2rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.75rem;
  animation: spin-slow 8s linear infinite;
}

.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
}

.auth-brand p {
  color: var(--text3);
  margin-top: 0.25rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-switch {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text3);
}

/* Auth Visual Panel */
.auth-visual {
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.auth-visual::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 60% 40%, rgba(124,106,245,0.12) 0%, transparent 70%);
}

.visual-content {
  position: relative;
  width: 100%;
  max-width: 360px;
}

.floating-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  animation: float 6s ease-in-out infinite;
}

.fc2 { animation-delay: -2s; margin-left: 1.5rem; }
.fc3 { animation-delay: -4s; margin-left: 3rem; }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.fc-priority {
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}
.fc-priority.high { background: rgba(239,68,68,0.15); color: var(--red); }
.fc-priority.medium { background: rgba(245,158,11,0.15); color: var(--yellow); }
.fc-priority.low { background: rgba(34,197,94,0.15); color: var(--green); }

.floating-card p {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 500;
}

.fc-status {
  font-size: 0.75rem;
  color: var(--text3);
  flex-shrink: 0;
}
.fc-status.done { color: var(--green); }

.visual-stats {
  display: flex;
  justify-content: space-around;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.vs-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.vs-item strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent2);
  font-weight: 800;
}
.vs-item span { font-size: 0.75rem; color: var(--text3); }

/* ===== FLASH MESSAGES ===== */
.flash {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  animation: fadeInDown 0.3s ease;
  position: relative;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.flash-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  color: var(--green);
}

.flash-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  color: var(--red);
}

.flash-close {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.7;
  padding: 0;
}

/* ===== CATEGORIES ===== */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.category-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.cat-preview {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 0.75rem;
}

.cat-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cat-item-actions {
  display: flex;
  gap: 0.5rem;
}

.add-category-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 1rem;
}

.add-category-form h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  z-index: 1;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.modal-box h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ===== ERROR PAGE ===== */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.error-num {
  font-family: var(--font-display);
  font-size: 7rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.error-content h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.error-content p {
  color: var(--text3);
  margin-bottom: 2rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-card { padding: 2rem 1.5rem; }

  .navbar { padding: 0 1rem; }
  .nav-links { gap: 0.75rem; }
  .user-name { display: none; }

  .app-main { padding: 1.5rem 1rem 3rem; }

  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .form-row { grid-template-columns: 1fr; }

  .task-card { grid-template-columns: auto 1fr; }
  .task-actions { flex-direction: row; grid-column: 2; justify-content: flex-end; }

  .page-header { flex-direction: column; gap: 1rem; align-items: flex-start; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .task-form { padding: 1.25rem; }
}
