/* =====================
   CSS Variables & Reset
   ===================== */
:root {
  --bg: #0d0f14;
  --surface: #13161d;
  --surface2: #1a1e28;
  --border: #252936;
  --border-light: #2e3448;
  --accent: #e8ff47;
  --accent-dim: rgba(232, 255, 71, 0.10);
  --accent-glow: rgba(232, 255, 71, 0.28);
  --text: #f0f2f8;
  --text-muted: #6b7280;
  --text-dim: #9ca3af;
  --danger: #ff4d6d;
  --warning: #ffb347;
  --success: #4ade80;
  --low: #4ade80;
  --medium: #ffb347;
  --high: #ff4d6d;
  --radius: 14px;
  --sidebar-w: 260px;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(232,255,71,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232,255,71,0.015) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* =====================
   Reminder Banner
   ===================== */
.reminder-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 999;
  background: linear-gradient(90deg, #ff4d6d 0%, #ffb347 100%);
  color: #0d0f14;
  padding: 11px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.02em;
  animation: slideDown 0.4s cubic-bezier(0.4,0,0.2,1);
}
.reminder-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.reminder-pulse {
  width: 8px;
  height: 8px;
  background: #0d0f14;
  border-radius: 50%;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.reminder-banner button {
  background: rgba(0,0,0,0.15);
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #0d0f14;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--transition);
}
.reminder-banner button:hover { background: rgba(0,0,0,0.25); }

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* =====================
   Layout
   ===================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* =====================
   Sidebar
   ===================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 12px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}
.logo-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
  line-height: 1.1;
}
.logo-sub {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  font-weight: 600;
  margin-top: 2px;
}

.filter-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.filter-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  position: relative;
}
.filter-btn:hover {
  background: var(--surface2);
  color: var(--text);
}
.filter-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}
.filter-btn.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.filter-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.filter-label { flex: 1; }
.count-badge {
  margin-left: auto;
  background: var(--surface2);
  border-radius: 20px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 24px;
  text-align: center;
  transition: all var(--transition);
}
.count-badge.urgent {
  background: rgba(255, 77, 109, 0.15);
  color: var(--danger);
}
.filter-btn.active .count-badge {
  background: var(--accent-glow);
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}
#progressPercent { color: var(--accent); font-weight: 700; }
.progress-track {
  height: 5px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a3e635);
  border-radius: 99px;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 0 8px var(--accent-glow);
}
.stats-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.stat-item span:first-child {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.stat-item span:last-child {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

/* =====================
   Main
   ===================== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 36px 40px;
  min-height: 100vh;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}
.main-title {
  font-family: var(--font-head);
  font-size: 34px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.main-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 5px;
}
.add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #0d0f14;
  border: none;
  border-radius: 10px;
  padding: 11px 20px;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}
.add-btn-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: 400;
}
.add-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px var(--accent-glow);
}
.add-btn:active { transform: translateY(0); }

/* =====================
   Toolbar
   ===================== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.search-wrap {
  flex: 1;
  position: relative;
  max-width: 360px;
}
.search-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition);
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--text-muted); }
.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}
.sort-wrap select {
  padding: 9px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.sort-wrap select:focus { border-color: var(--accent); }
.sort-wrap select option { background: var(--surface2); }

/* =====================
   Task Grid
   ===================== */
.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  animation: cardIn 0.3s ease both;
  position: relative;
  overflow: hidden;
}
.task-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px; height: 100%;
}
.task-card.priority-low::before    { background: linear-gradient(180deg, var(--low), rgba(74,222,128,0.2)); }
.task-card.priority-medium::before { background: linear-gradient(180deg, var(--medium), rgba(255,179,71,0.2)); }
.task-card.priority-high::before   { background: linear-gradient(180deg, var(--high), rgba(255,77,109,0.2)); }

.task-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.task-card.completed { opacity: 0.5; }
.task-card.overdue-card {
  border-color: rgba(255, 77, 109, 0.3);
  background: rgba(255, 77, 109, 0.03);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.card-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  word-break: break-word;
  line-height: 1.3;
}
.task-card.completed .card-title {
  text-decoration: line-through;
  color: var(--text-muted);
}
.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.due-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-dim);
}
.due-badge.soon    { background: rgba(255,179,71,0.12); color: var(--warning); }
.due-badge.overdue { background: rgba(255,77,109,0.12); color: var(--danger); }
.due-badge.done    { background: rgba(74,222,128,0.1);  color: var(--success); }

.priority-tag {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.priority-tag.low    { background: rgba(74,222,128,0.1);  color: var(--low); }
.priority-tag.medium { background: rgba(255,179,71,0.1);  color: var(--medium); }
.priority-tag.high   { background: rgba(255,77,109,0.1);  color: var(--high); }

.card-actions {
  display: flex;
  gap: 7px;
  margin-top: 2px;
}
.btn-check, .btn-edit, .btn-del {
  flex: 1;
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-check:hover { background: rgba(74,222,128,0.1);  color: var(--success); border-color: rgba(74,222,128,0.4); }
.btn-edit:hover  { background: rgba(232,255,71,0.08); color: var(--accent);  border-color: rgba(232,255,71,0.3); }
.btn-del:hover   { background: rgba(255,77,109,0.1);  color: var(--danger);  border-color: rgba(255,77,109,0.4); }

/* =====================
   Empty State
   ===================== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  animation: fadeInUp 0.4s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.empty-icon { font-size: 52px; margin-bottom: 16px; opacity: 0.6; }
.empty-state p { font-family: var(--font-head); font-size: 20px; font-weight: 700; color: var(--text-dim); margin-bottom: 6px; }
.empty-state span { font-size: 13px; }

/* =====================
   Modal
   ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 12, 0.85);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  padding: 32px;
  animation: modalUp 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
}
@keyframes modalUp {
  from { transform: translateY(24px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0) scale(1);       opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.modal-header h2 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.modal-close {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 34px; height: 34px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: all var(--transition);
}
.modal-close:hover { color: var(--danger); border-color: rgba(255,77,109,0.4); background: rgba(255,77,109,0.08); }

.form-group { margin-bottom: 18px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.required { color: var(--danger); }

input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { resize: vertical; min-height: 80px; }
select { cursor: pointer; }
select option { background: var(--surface2); }

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.5);
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}
.btn-cancel {
  flex: 1;
  padding: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-cancel:hover { color: var(--text); border-color: var(--border-light); }
.btn-save {
  flex: 2;
  padding: 12px;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #0d0f14;
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}
.btn-save:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.btn-save:active { transform: translateY(0); }

/* =====================
   Toast Notifications
   ===================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.35s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  pointer-events: auto;
  min-width: 220px;
  max-width: 320px;
}
.toast.success { border-color: rgba(74,222,128,0.35); }
.toast.success .toast-icon { color: var(--success); }
.toast.danger  { border-color: rgba(255,77,109,0.35); }
.toast.danger  .toast-icon { color: var(--danger); }
.toast.info    { border-color: rgba(232,255,71,0.3); }
.toast.info    .toast-icon { color: var(--accent); }
.toast-icon { font-size: 15px; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px) scale(0.95); }
}

/* =====================
   Utilities
   ===================== */
.hidden { display: none !important; }

/* =====================
   Responsive
   ===================== */
@media (max-width: 900px) {
  .main { padding: 28px 24px; }
}
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: column;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .logo { margin-bottom: 16px; padding-bottom: 16px; }
  .filter-nav { flex-direction: row; flex-wrap: wrap; gap: 5px; }
  .filter-btn { padding: 8px 12px; font-size: 13px; }
  .filter-label { display: none; }
  .count-badge { display: none; }
  .sidebar-footer { padding-top: 14px; margin-top: 14px; }
  .app-wrapper { flex-direction: column; }
  .main { margin-left: 0; padding: 20px 16px; }
  .main-header { flex-direction: column; gap: 14px; }
  .add-btn { width: 100%; justify-content: center; }
  .toolbar { flex-wrap: wrap; }
  .search-wrap { max-width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .modal { padding: 24px; }
}
@media (max-width: 480px) {
  .main-title { font-size: 26px; }
  .task-grid { grid-template-columns: 1fr; }
}
