/* ==========================================================================
   TaskManager — Component Styles
   Buttons, cards, modals, inputs, badges, toasts
   ========================================================================== */

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: transform 0.15s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #16161c;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 0 1px var(--accent-dim), 0 10px 28px rgba(245, 166, 35, 0.22);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

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

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
}

.btn-danger:hover { background: #ef535038; }

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

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

.btn-icon.sm { width: 32px; height: 32px; }

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ----- Theme toggle ----- */
.theme-toggle {
  position: relative;
  width: 52px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 3px;
}

.theme-toggle-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  transition: transform 0.3s var(--ease-spring);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #16161c;
}

.theme-toggle-thumb svg { width: 12px; height: 12px; }

[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(22px);
}

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.project-card {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--project-color, var(--accent)), transparent);
  opacity: 0.8;
}

.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.project-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.project-card-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  background: color-mix(in srgb, var(--project-color, var(--accent)) 18%, transparent);
  color: var(--project-color, var(--accent));
}

.project-card-menu {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}

.project-card:hover .project-card-menu { opacity: 1; }

.project-card h3 {
  font-size: 16px;
  margin-bottom: 3px;
}

.project-card .project-meta {
  font-size: 12.5px;
  color: var(--text-muted);
}

.project-stats-row {
  display: flex;
  gap: 18px;
  font-size: 13px;
}

.project-stats-row .stat-num {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.project-stats-row .stat-label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ----- Progress bar ----- */
.progress-track {
  width: 100%;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--project-color, var(--accent)), var(--accent-strong));
  transition: width 0.6s var(--ease-spring);
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: shimmer 2.2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-caption {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ----- Empty state ----- */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 90px 20px;
  color: var(--text-muted);
  gap: 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.empty-state h3 {
  color: var(--text-primary);
  font-size: 16px;
}

.empty-state p { font-size: 13.5px; max-width: 320px; }

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 11, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.97);
  opacity: 0;
  transition: transform 0.25s var(--ease-spring), opacity 0.2s var(--ease);
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 17px;
}

.modal-body {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 18px 22px;
  border-top: 1px solid var(--border);
}

.modal.modal-danger .modal-header { border-color: var(--danger-dim); }

/* ----- Form fields ----- */
.field { display: flex; flex-direction: column; gap: 7px; }

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input[type="text"],
.field input[type="date"],
.field input[type="number"],
.field textarea,
.field select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.field textarea { resize: vertical; min-height: 70px; }

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

/* Color swatch picker */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s var(--ease), border-color 0.15s var(--ease);
}

.color-swatch:hover { transform: scale(1.1); }

.color-swatch.selected {
  border-color: var(--text-primary);
  transform: scale(1.12);
}

/* ----- Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-high { background: var(--danger-dim); color: var(--priority-high); }
.badge-medium { background: var(--warning-dim); color: var(--priority-medium); }
.badge-low { background: var(--success-dim); color: var(--priority-low); }

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ----- Toast notifications ----- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  min-width: 240px;
  animation: toast-in 0.3s var(--ease-spring);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }

.toast.toast-out {
  animation: toast-out 0.25s var(--ease) forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(24px); }
}

/* ----- Misc ----- */
.icon-btn-danger:hover { color: var(--danger); border-color: var(--danger-dim); }

.spin { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fade-in 0.35s var(--ease); }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
