/* ============================================
   TaskMaster Pro - Enterprise Styles
   ============================================ */

/* ---- Design Tokens ---- */
:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.15);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.4);
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- App Container ---- */
.todo-app {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
}

/* ---- Header ---- */
.todo-header {
  text-align: center;
  margin-bottom: 28px;
  padding-top: 16px;
}

.todo-header h1 {
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #8b5cf6, #ec4899);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.todo-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ---- Input Section ---- */
.input-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  transition: border-color var(--transition-base);
}

.input-section:focus-within {
  border-color: var(--primary);
}

.input-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.todo-input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.todo-input:hover {
  border-color: var(--surface-hover);
}

.todo-input:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.todo-input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* ---- Buttons ---- */
.btn {
  padding: 14px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background var(--transition-fast);
}

.btn:hover::after {
  background: rgba(255, 255, 255, 0.08);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.45);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--surface-hover);
}

/* ---- Options Row ---- */
.options-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.select-styled {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-base);
  min-width: 140px;
}

.select-styled:hover {
  border-color: var(--surface-hover);
}

.select-styled:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* ---- Controls Section ---- */
.controls-section {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-box input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 16px 11px 42px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.search-box input:hover {
  border-color: var(--surface-hover);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

/* ---- Filter Group ---- */
.filter-group {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border);
}

.filter-btn {
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.filter-btn:hover:not(.active) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.filter-btn.active {
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* ---- Stats Bar ---- */
.stats-bar {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding: 14px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-badge {
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 700;
  color: var(--text);
  font-size: 0.8rem;
  min-width: 28px;
  text-align: center;
  border: 1px solid var(--border);
}

/* ---- Task List ---- */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---- Task Item ---- */
.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition-base);
  animation: slideIn var(--transition-slow) ease;
  position: relative;
}

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

.task-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background: transparent;
  transition: background var(--transition-base);
}

.task-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.task-item:hover::before {
  background: var(--primary);
}

.task-item:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.7;
}

.task-item.editing {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.04);
  box-shadow: 0 0 0 1px var(--warning), var(--shadow-md);
}

.task-item.editing::before {
  background: var(--warning);
}

/* ---- Task Checkbox ---- */
.task-checkbox {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  background: var(--bg);
  position: relative;
}

.task-checkbox:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.task-checkbox:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.task-checkbox.checked {
  background: linear-gradient(135deg, var(--success), #059669);
  border-color: var(--success);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.task-checkbox.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* ---- Task Content ---- */
.task-content {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 1rem;
  font-weight: 500;
  word-break: break-word;
  line-height: 1.5;
  color: var(--text);
  transition: color var(--transition-base);
}

.task-meta {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Priority Badges ---- */
.priority-badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.priority-high {
  background: rgba(239, 68, 68, 0.12);
  color: #f87171;
}

.priority-medium {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
}

.priority-low {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}

/* ---- Task Actions ---- */
.task-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.task-item:hover .task-actions,
.task-item:focus-within .task-actions {
  opacity: 1;
}

.task-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 0.95rem;
}

.task-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
  transform: scale(1.05);
}

.task-btn.delete:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.task-btn.edit:hover {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
}

.task-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---- Edit Input ---- */
.edit-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: box-shadow var(--transition-base);
}

.edit-input:focus {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 70px 24px;
  color: var(--text-muted);
  animation: fadeIn var(--transition-slow) ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  opacity: 0.4;
  filter: grayscale(0.3);
}

.empty-state h3 {
  font-size: 1.25rem;
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 600;
}

.empty-state p {
  font-size: 0.95rem;
  max-width: 300px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ---- Footer Actions ---- */
.footer-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 14px 22px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.3s ease 2.65s forwards;
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(30px);
  }
}

.toast-success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
  color: white;
}

.toast-error {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.95));
  color: white;
}

.toast-info {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(99, 102, 241, 0.95));
  color: white;
}

/* ---- Search Highlight ---- */
.highlight {
  background: rgba(245, 158, 11, 0.25);
  border-radius: 3px;
  padding: 1px 3px;
  font-weight: 600;
  color: #fbbf24;
}

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

/* Focus visible for all interactive elements */
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: none;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .todo-app {
    padding: 16px;
  }

  .input-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .controls-section {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }

  .filter-group {
    justify-content: center;
  }

  .stats-bar {
    justify-content: center;
    gap: 16px;
  }

  .task-item {
    padding: 14px;
    gap: 12px;
  }

  .task-actions {
    opacity: 1;
  }

  .task-meta {
    gap: 8px;
  }

  .footer-actions {
    flex-direction: column;
  }

  .footer-actions .btn {
    width: 100%;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    top: 16px;
  }

  .toast {
    max-width: 100%;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border: #64748b;
    --text-muted: #cbd5e1;
  }
}
