/* ============================================================
   TO-DO LIST OS — Design System
   iOS-native glassmorphism, dark mode, safe areas
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-deep: #07070e;
  --bg-surface: #0f0f1e;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-border: rgba(255, 255, 255, 0.10);
  --bg-card-hover: rgba(255, 255, 255, 0.09);
  --bg-header: rgba(15, 15, 30, 0.72);

  --text-primary: #f5f5f7;
  --text-secondary: rgba(245, 245, 247, 0.55);
  --text-tertiary: rgba(245, 245, 247, 0.35);

  --accent-blue: #5e9eff;
  --accent-violet: #bf5af2;
  --accent-gradient: linear-gradient(135deg, #5e9eff, #bf5af2);

  --ios-green: #30d158;
  --ios-red: #ff453a;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;

  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
  --safe-right: env(safe-area-inset-right);

  --font-system: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', system-ui, sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-system);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

/* Ambient background glow */
body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -20%;
  width: 70%;
  height: 70%;
  background: radial-gradient(circle, rgba(94, 158, 255, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -20%;
  right: -20%;
  width: 60%;
  height: 60%;
  background: radial-gradient(circle, rgba(191, 90, 242, 0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* --- Header --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: calc(var(--safe-top) + 12px) 20px 14px;
  background: var(--bg-header);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 500px;
  margin: 0 auto;
}

.header-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-subtitle {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.header-stats {
  display: flex;
  gap: 12px;
  align-items: center;
}

.stat-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

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

.stat-badge.validated .dot { background: var(--ios-green); box-shadow: 0 0 6px var(--ios-green); }
.stat-badge.archived .dot { background: var(--ios-red); box-shadow: 0 0 6px var(--ios-red); }

/* --- Main Content --- */
.app-content {
  position: relative;
  z-index: 1;
  padding: calc(var(--safe-top) + 90px) 16px calc(var(--safe-bottom) + 100px);
  max-width: 500px;
  margin: 0 auto;
}

.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* --- Task Cards --- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.task-card-wrapper {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: opacity 0.3s ease;
}

/* Swipe action backgrounds */
.swipe-action {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  display: flex;
  align-items: center;
  padding: 0 24px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  border-radius: var(--radius-md);
  opacity: 0;
  transition: opacity 0.15s ease;
}

.swipe-action.left {
  justify-content: flex-end;
  background: linear-gradient(90deg, transparent 30%, var(--ios-red));
  color: white;
}

.swipe-action.right {
  justify-content: flex-start;
  background: linear-gradient(-90deg, transparent 30%, var(--ios-green));
  color: white;
}

.swipe-action .action-icon {
  font-size: 1.4rem;
}

.task-card {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: grab;
  touch-action: pan-y;
  will-change: transform;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.3s ease,
              background 0.2s ease;
}

.task-card:active {
  cursor: grabbing;
}

.task-card.swiping {
  transition: none;
}

.task-card.returning {
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.task-card.lifted {
  transform: scale(1.04);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5),
              0 0 0 1px rgba(255, 255, 255, 0.12);
  z-index: 50;
  background: rgba(255, 255, 255, 0.10);
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.2s ease;
}

.task-card.dragging {
  transition: none;
  z-index: 50;
}

/* Priority indicator */
.task-priority {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.task-priority.high {
  background: linear-gradient(180deg, #ff6b6b, #ff453a);
  box-shadow: 0 0 8px rgba(255, 69, 58, 0.3);
}

.task-priority.medium {
  background: linear-gradient(180deg, #ffd60a, #ff9f0a);
  box-shadow: 0 0 8px rgba(255, 159, 10, 0.3);
}

.task-priority.low {
  background: linear-gradient(180deg, #5e9eff, #64d2ff);
  box-shadow: 0 0 8px rgba(94, 158, 255, 0.2);
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-meta .tag {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 600;
  background: rgba(94, 158, 255, 0.12);
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.task-handle {
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0.25;
  padding: 4px;
  flex-shrink: 0;
}

.task-handle span {
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
}

/* Card dismiss animation */
.task-card-wrapper.dismissed-right {
  animation: dismissRight 0.4s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

.task-card-wrapper.dismissed-left {
  animation: dismissLeft 0.4s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

@keyframes dismissRight {
  to {
    transform: translateX(120%);
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding: 0;
  }
}

@keyframes dismissLeft {
  to {
    transform: translateX(-120%);
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    padding: 0;
  }
}

/* Drag placeholder */
.drag-placeholder {
  border: 2px dashed rgba(94, 158, 255, 0.25);
  border-radius: var(--radius-md);
  background: rgba(94, 158, 255, 0.04);
  transition: height 0.2s ease;
}

/* --- Bottom Bar --- */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 20px calc(var(--safe-bottom) + 12px);
  background: var(--bg-header);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.bottom-bar-content {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  gap: 16px;
}

.bottom-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-tertiary);
  font-weight: 500;
}

.hint-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hint-icon.green { color: var(--ios-green); }
.hint-icon.red { color: var(--ios-red); }
.hint-icon.blue { color: var(--accent-blue); }

/* --- Empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state .emoji {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 260px;
}

/* Reset button */
.reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(94, 158, 255, 0.3);
  background: rgba(94, 158, 255, 0.08);
  color: var(--accent-blue);
  font-family: var(--font-system);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reset-btn:active {
  transform: scale(0.96);
  background: rgba(94, 158, 255, 0.15);
}

/* --- Toast notification --- */
.toast {
  position: fixed;
  top: calc(var(--safe-top) + 80px);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.8rem;
  font-weight: 600;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 200;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: rgba(48, 209, 88, 0.2);
  color: var(--ios-green);
}

.toast.error {
  background: rgba(255, 69, 58, 0.2);
  color: var(--ios-red);
}

.toast.info {
  background: rgba(94, 158, 255, 0.2);
  color: var(--accent-blue);
}

/* --- Animations & Utils --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.task-card-wrapper {
  animation: fadeInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.task-card-wrapper:nth-child(1) { animation-delay: 0.05s; }
.task-card-wrapper:nth-child(2) { animation-delay: 0.10s; }
.task-card-wrapper:nth-child(3) { animation-delay: 0.15s; }
.task-card-wrapper:nth-child(4) { animation-delay: 0.20s; }
.task-card-wrapper:nth-child(5) { animation-delay: 0.25s; }
.task-card-wrapper:nth-child(6) { animation-delay: 0.30s; }
.task-card-wrapper:nth-child(7) { animation-delay: 0.35s; }
.task-card-wrapper:nth-child(8) { animation-delay: 0.40s; }

/* Prevent overscroll on iOS */
@supports (-webkit-touch-callout: none) {
  body {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 0; }
