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

html,
body {
  height: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #1f2933 0, #020617 60%);
  color: #e5e7eb;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* Page wrapper */
.page-wrapper {
  width: 100%;
  max-width: 960px;
  padding: 1.5rem 1rem 2.5rem;
  margin-top: 1.5rem;
}

/* Header */
.app-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.app-title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.app-subtitle {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-top: 0.35rem;
}

/* Card */
.app-card {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 1rem;
  padding: 1.25rem 1rem 1rem;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-dot-active {
  background: #22c55e;
}

.legend-dot-completed {
  background: #6366f1;
}

/* =========================
   CONTROL BAR
========================= */

.control-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 14px;
}

/* =========================
   SORT GROUP
========================= */

.sort-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-group label {
  font-size: 14px;
  color: #94a3b8;
  font-weight: 500;
}

.sort-group select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.sort-group select:hover {
  border-color: #6366f1;
}

.sort-group select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

/* Input row */
.input-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.input-row input {
  padding: 0.65rem 0.8rem;
  border-radius: 0.6rem;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  font-size: 0.95rem;
  outline: none;
  transition: border 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.input-row input::placeholder {
  color: #6b7280;
}

.input-row input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.5);
  background: #020617;
}

/* Primary button */
.input-row button {
  padding: 0.6rem 0.8rem;
  border-radius: 0.6rem;
  border: none;
  background: linear-gradient(135deg, #6366f1, #22c55e);
  color: white;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

.input-row button:active {
  transform: translateY(1px) scale(0.99);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.8);
}

.input-row button:hover {
  filter: brightness(1.05);
}

/* Toolbar */
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.85rem;
}

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

.filter-btn {
  border-radius: 999px;
  border: 1px solid #374151;
  background: #020617;
  color: #9ca3af;
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border 0.15s ease;
}

.filter-btn.active {
  background: #6366f1;
  color: #f9fafb;
  border-color: #6366f1;
}

.filter-btn:hover {
  border-color: #6366f1;
}

.stats {
  font-size: 0.8rem;
  color: #9ca3af;
}

/* Task list */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.7rem;
  background: #020617;
  border: 1px solid #111827;
  transition: transform 0.1s ease, box-shadow 0.1s ease, border 0.15s ease,
    background 0.15s ease, opacity 0.2s ease;
}

.task-item:hover {
  border-color: #374151;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.8);
  transform: translateY(-1px);
}

.task-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 1;
  min-width: 0;
}

.task-toggle {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid #4b5563;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: transparent;
  transition: border 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.task-text {
  font-size: 0.9rem;
  color: #e5e7eb;
  word-break: break-word;
}

/* Completed style */
.task-item.completed {
  background: #020617;
  border-color: #312e81;
}

.task-item.completed .task-text {
  color: #9ca3af;
  text-decoration: line-through;
}

.task-item.completed .task-toggle {
  background: #6366f1;
  border-color: #6366f1;
  color: white;
}

/* Actions */
.task-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-btn {
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #6b7280;
  padding: 0.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
  color: #ef4444;
  background: rgba(148, 163, 184, 0.08);
}

.icon-btn:active {
  transform: scale(0.96);
}

/* Bottom actions */
.bottom-actions {
  display: flex;
  justify-content: flex-end;
}

.ghost-btn {
  border-radius: 999px;
  border: 1px dashed #374151;
  background: transparent;
  color: #9ca3af;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border 0.15s ease;
}

.ghost-btn:hover {
  border-style: solid;
  border-color: #6366f1;
  color: #e5e7eb;
  background: rgba(99, 102, 241, 0.08);
}

/* Footer */
.app-footer {
  margin-top: 1.1rem;
  text-align: center;
  font-size: 0.8rem;
  color: #6b7280;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 8px;
}

.active-dot {
  background-color: #22c55e; /* green */
}

.completed-dot {
  background-color: #6366f1; /* blue */
}

/* ---------- RESPONSIVE BREAKPOINTS ---------- */

/* ≥ 480px: put input and button on one row */
@media (min-width: 480px) {
  .input-row {
    flex-direction: row;
  }

  .input-row input {
    flex: 1;
  }

  .input-row button {
    width: auto;
    min-width: 80px;
  }
}

/* ≥ 640px: toolbar in a row, increase paddings */
@media (min-width: 640px) {
  .app-card {
    padding: 1.5rem 1.4rem 1.2rem;
  }

  .toolbar {
    flex-direction: row;
    align-items: center;
  }
}

/* Visually hidden (accessible) */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Custom dropdown container */
.sort-dd {
  position: relative;
  display: inline-block;
  margin-bottom: 14px;
}

/* Trigger button */
.sort-dd__btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  min-width: 160px;
  padding: 8px 12px;

  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: #fff;

  cursor: pointer;
  outline: none;

  backdrop-filter: blur(6px);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.08s ease;
}

.sort-dd__btn:hover {
  border-color: rgba(99,102,241,0.9);
}

.sort-dd__btn:focus-visible {
  border-color: rgba(99,102,241,0.9);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.25);
}

.sort-dd__btn:active {
  transform: translateY(1px);
}

.sort-dd__chev {
  opacity: 0.9;
}

/* Dropdown panel */
.sort-dd__list {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  left: 0;

  width: 100%;
  padding: 8px;
  margin: 0;

  list-style: none;

  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(15,23,42,0.92); /* dark glass */
  backdrop-filter: blur(10px);

  box-shadow: 0 18px 50px rgba(0,0,0,0.45);

  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}

/* Open state */
.sort-dd.is-open .sort-dd__list {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Options */
.sort-dd__opt {
  padding: 10px 10px;
  border-radius: 10px;
  color: rgba(255,255,255,0.92);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.sort-dd__opt:hover {
  background: rgba(99,102,241,0.22);
}

.sort-dd__opt[aria-selected="true"] {
  background: rgba(99,102,241,0.30);
  color: #fff;
}

/* Keyboard highlight (focus/active option) */
.sort-dd__opt.is-active {
  background: rgba(56,189,248,0.18);
}
/* ≥ 900px: card narrower for desktop, center page higher */
@media (min-width: 900px) {
  body {
    align-items: center;
  }

  .app-card {
    max-width: 520px;
    margin-inline: auto;
  }
}

@media (max-width: 480px) {
  .control-bar {
    justify-content: space-between;
  }
}
