/* ============================================================
   App-level overrides on top of Pico CSS
   ============================================================ */

/* ---- Layout ---- */
:root {
  --app-max-width: 860px;
}

body {
  min-height: 100vh;
  background-color: var(--pico-background-color);
}

/* Sticky header */
header.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--pico-card-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding: 0.75rem 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

header.app-header .container {
  max-width: var(--app-max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

header.app-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--pico-primary);
  white-space: nowrap;
}

/* Navbar filter links */
.nav-filters {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-filters li a {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--pico-border-radius);
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--pico-muted-color);
  transition: background 0.15s, color 0.15s;
}

.nav-filters li a:hover {
  background-color: var(--pico-secondary-background);
  color: var(--pico-color);
}

.nav-filters li a[aria-current="page"] {
  background-color: var(--pico-primary-background);
  color: var(--pico-primary);
  font-weight: 600;
}

/* ---- Main content ---- */
main.app-main {
  max-width: var(--app-max-width);
  margin: 1.5rem auto;
  padding: 0 1rem;
}

/* ---- Priority badges ---- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-high {
  background-color: #ffe0e0;
  color: #c0392b;
}

.badge-medium {
  background-color: #fff3cd;
  color: #856404;
}

.badge-low {
  background-color: #d1fae5;
  color: #065f46;
}

/* ---- Todo item ---- */
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--pico-border-radius);
  border: 1px solid var(--pico-muted-border-color);
  background-color: var(--pico-card-background-color);
  margin-bottom: 0.625rem;
  transition: box-shadow 0.15s;
}

.todo-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.todo-item.completed .todo-title {
  text-decoration: line-through;
  color: var(--pico-muted-color);
}

.todo-checkbox {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.1rem;
  cursor: pointer;
  accent-color: var(--pico-primary);
}

.todo-content {
  flex: 1;
  min-width: 0;
}

.todo-title {
  font-weight: 500;
  word-break: break-word;
  margin-bottom: 0.2rem;
}

.todo-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.todo-due-date {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
}

.todo-due-date.overdue {
  color: #e74c3c;
  font-weight: 600;
}

.todo-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.todo-actions button {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  min-width: 44px;
  min-height: 44px;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--pico-muted-color);
}

.empty-state svg {
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 3px solid var(--pico-muted-border-color);
  border-top-color: var(--pico-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-center {
  display: flex;
  justify-content: center;
  padding: 3rem;
}

/* ---- Mobile ---- */
@media (max-width: 600px) {
  .app-title {
    font-size: 1.1rem;
  }

  .nav-filters li a {
    padding: 0.3rem 0.5rem;
    font-size: 0.82rem;
  }

  .todo-item {
    padding: 0.75rem;
  }

  .todo-actions button {
    padding: 0.5rem 0.5rem;
  }
}

/* ============================================================
   Responsive Enhancements & Mobile Optimization
   ============================================================ */

/* ---- App Header Bar (sticky, with search + filters) ---- */
.app-header-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--pico-background-color);
  border-bottom: 1px solid var(--pico-muted-border-color);
  padding-bottom: 0.5rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.app-header-bar nav {
  align-items: center;
}

/* ---- Search Input ---- */
.search-input {
  margin-bottom: 0;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  width: 220px;
  min-width: 0;
  border-radius: var(--pico-border-radius);
}

/* ---- Status Filter Bar ---- */
.status-filter-bar {
  display: flex;
  gap: 0.375rem;
  padding: 0.5rem 1rem 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.status-filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  padding: 0.3rem 0.875rem;
  font-size: 0.8rem;
  border-radius: 999px;
  white-space: nowrap;
  margin-bottom: 0;
  min-height: 36px;
  cursor: pointer;
  border: 1px solid var(--pico-muted-border-color);
  background: transparent;
  color: var(--pico-muted-color);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.filter-btn:hover {
  background: var(--pico-secondary-background);
  color: var(--pico-color);
  border-color: var(--pico-secondary);
}

.filter-btn-active {
  background: var(--pico-primary-background);
  color: var(--pico-primary);
  border-color: var(--pico-primary);
  font-weight: 600;
}

/* ---- Todo Row (responsive list item) ---- */
.todo-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--pico-table-border-color);
  min-height: 48px;
  transition: background 0.12s;
}

.todo-row:last-child {
  border-bottom: none;
}

.todo-row--done .todo-title-text {
  text-decoration: line-through;
  color: var(--pico-muted-color);
}

.todo-title-text {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

/* ---- Priority Badge ---- */
.priority-badge {
  padding: 0.125rem 0.5rem;
  border-radius: var(--pico-border-radius);
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.8rem;
}

.priority-badge[data-priority="high"] {
  background: color-mix(in srgb, var(--pico-color-red-500) 15%, transparent);
  color: var(--pico-color-red-500);
}

.priority-badge[data-priority="medium"] {
  background: color-mix(in srgb, var(--pico-color-amber-500) 15%, transparent);
  color: var(--pico-color-amber-500);
}

.priority-badge[data-priority="low"] {
  background: color-mix(in srgb, var(--pico-color-green-500) 15%, transparent);
  color: var(--pico-color-green-500);
}

/* ---- Delete Button ---- */
.todo-delete-btn {
  padding: 0.25rem 0.5rem;
  margin-bottom: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Keyboard Shortcut Hint (desktop only) ---- */
.kbd-hint {
  font-size: 0.75rem;
  color: var(--pico-muted-color);
  margin-top: 0.5rem;
  margin-bottom: 0;
  text-align: right;
}

kbd {
  display: inline-block;
  padding: 0.1em 0.4em;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.85em;
  background: var(--pico-card-background-color);
  color: var(--pico-muted-color);
}

/* ---- FAB (Floating Action Button) — mobile only ---- */
.fab {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  font-size: 1.75rem;
  line-height: 1;
  padding: 0;
  margin: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 200;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  background: var(--pico-primary);
  color: #fff;
  border: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.fab:active {
  transform: scale(0.96);
}

/* ---- Hover states (pointer devices only) ---- */
@media (hover: hover) {
  .todo-row:hover {
    background-color: var(--pico-secondary-background);
    border-radius: var(--pico-border-radius);
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* ---- Desktop layout (>= 768px) ---- */
@media (min-width: 768px) {
  .search-input {
    width: 240px;
  }

  .header-count {
    display: list-item;
  }

  .kbd-hint {
    display: block;
  }
}

/* ---- Mobile layout (< 768px) ---- */
@media (max-width: 767px) {
  .fab {
    display: flex;
  }

  .search-input {
    width: 130px;
    font-size: 0.8rem;
  }

  .header-count {
    display: none;
  }

  .kbd-hint {
    display: none;
  }

  .todo-row {
    padding: 0.875rem 0;
    min-height: 52px;
  }

  /* Extra bottom padding so FAB doesn't overlap last item */
  main.container {
    padding-bottom: 5rem;
  }

  /* Larger touch targets for checkboxes */
  .todo-row input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
  }

  /* Touch-friendly priority badge on narrow screens */
  .priority-badge {
    display: none;
  }
}
