/* ─── Reset & base ───────────────────────────────────────────────────────── */

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

:root {
  --bg:         #0a0a14;
  --surface:    #12121e;
  --surface2:   #1a1a2e;
  --surface3:   #1f1f35;
  --border:     #252540;
  --border2:    #2e2e52;
  --text:       #e0e0f0;
  --text-muted: #7070a0;
  --text-dim:   #44445a;
  --accent:     #818cf8;
  --accent-dim: #4f46e5;
  --accent-bg:  #818cf812;
  --success:    #34d399;
  --warning:    #fbbf24;
  --error:      #f87171;

  --sidebar-w:  220px;
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --shadow:     0 0 0 1px var(--border), 0 4px 32px rgba(0,0,0,0.4);
}

html { color-scheme: dark; scroll-behavior: smooth; }

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

/* ─── Utilities ──────────────────────────────────────────────────────────── */

.hidden { display: none !important; }
.gradient-text {
  background: linear-gradient(135deg, var(--accent) 0%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── AUTH PAGE ──────────────────────────────────────────────────────────── */

#page-auth { display: flex; flex-direction: column; min-height: 100dvh; }

.nav {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
  background: rgba(10,10,20,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.nav-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 24px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 700; font-size: 15px; color: var(--text);
}
.logo-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #c084fc 100%);
  flex-shrink: 0;
}

.hero { flex: 1; padding: 80px 0 96px; }
.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.hero-grid { display: grid; grid-template-columns: 1fr 420px; gap: 64px; align-items: center; }
.hero-content { max-width: 520px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border: 1px solid var(--border2); border-radius: 99px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  letter-spacing: 0.5px; text-transform: uppercase; margin-bottom: 24px;
  background: var(--accent-bg);
}
.hero-title {
  font-size: clamp(40px, 5vw, 60px); font-weight: 800;
  line-height: 1.1; letter-spacing: -2px; margin-bottom: 20px; color: #f0f0ff;
}
.hero-desc { font-size: 17px; color: var(--text-muted); line-height: 1.65; margin-bottom: 32px; max-width: 420px; }
.hero-features { display: flex; flex-direction: column; gap: 10px; }
.feature-item { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted); }
.feature-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

.auth-panel { position: relative; }
.auth-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow);
}
.auth-header { margin-bottom: 28px; }
.auth-header h2 { font-size: 20px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; margin-bottom: 6px; }
.auth-header p { font-size: 14px; color: var(--text-muted); line-height: 1.5; }
.auth-header strong { color: var(--text); }

.footer {
  border-top: 1px solid var(--border); padding: 20px 0;
}
.footer .container { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.footer-sep { color: var(--border2); }

/* ─── APP SHELL ──────────────────────────────────────────────────────────── */

#page-app {
  display: flex;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-top { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 24px; }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px; font-weight: 700; font-size: 15px; color: var(--text);
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text-muted); font-size: 14px; font-family: inherit;
  font-weight: 500; cursor: pointer; text-align: left;
  transition: background 0.15s, color 0.15s;
}
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { background: var(--accent-bg); color: var(--accent); }
.sidebar-item svg { flex-shrink: 0; opacity: 0.8; }

.sidebar-bottom { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), #7c3aed);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.user-email { font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-logout {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border: none; border-radius: var(--radius-sm);
  background: none; color: var(--text-dim); font-size: 13px; font-family: inherit;
  cursor: pointer; transition: background 0.15s, color 0.15s; text-align: left;
}
.sidebar-logout:hover { background: var(--surface2); color: var(--error); }

.app-main { margin-left: var(--sidebar-w); flex: 1; min-height: 100dvh; }
.app-view { padding: 32px 40px; max-width: 960px; }

.view-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 28px;
}
.view-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.view-subtitle { font-size: 14px; color: var(--text-muted); margin-top: 3px; }

/* ─── Tasks ──────────────────────────────────────────────────────────────── */

.status-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px; width: fit-content;
}
.status-tab {
  padding: 6px 14px; border: none; border-radius: 6px;
  background: none; color: var(--text-muted); font-size: 13px; font-family: inherit;
  font-weight: 500; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.status-tab:hover { color: var(--text); }
.status-tab.active { background: var(--surface2); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 64px 24px; text-align: center; color: var(--text-dim); font-size: 14px;
}

.task-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  transition: border-color 0.15s;
}
.task-card:hover { border-color: var(--border2); }

.task-status-btn {
  flex-shrink: 0; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border2); background: none; cursor: pointer;
  margin-top: 2px; transition: border-color 0.15s, background 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.task-status-btn:hover { border-color: var(--accent); }
.task-status-btn.in_progress { border-color: var(--warning); background: rgba(251,191,36,0.15); }
.task-status-btn.done { border-color: var(--success); background: rgba(52,211,153,0.15); }
.task-status-btn.done::after {
  content: ''; display: block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
}

.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.task-card[data-status="done"] .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 10px; }

.task-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
}
.status-badge.todo { background: rgba(112,112,160,0.15); color: var(--text-muted); }
.status-badge.in_progress { background: rgba(251,191,36,0.12); color: var(--warning); }
.status-badge.done { background: rgba(52,211,153,0.12); color: var(--success); }

.assignee-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 4px; background: var(--surface3);
  border: 1px solid var(--border); border-radius: 99px; font-size: 12px; color: var(--text-muted);
}
.assignee-chip .chip-avatar {
  width: 16px; height: 16px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), #7c3aed);
  font-size: 9px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
}

.task-actions { display: flex; gap: 4px; flex-shrink: 0; }
.task-action-btn {
  width: 28px; height: 28px; border: none; border-radius: 6px;
  background: none; color: var(--text-dim); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.task-action-btn:hover { background: var(--surface3); color: var(--text); }
.task-action-btn.delete:hover { color: var(--error); }

/* ─── Modal ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 480px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.modal-close {
  width: 28px; height: 28px; border: none; border-radius: 6px;
  background: none; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--surface3); color: var(--text); }

#task-form { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ─── Shared form elements ───────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.field input, .field textarea, .field select {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s; outline: none; -webkit-appearance: none;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(129,140,248,0.12);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-dim); }
.field textarea { resize: vertical; min-height: 72px; line-height: 1.5; }
.field select { cursor: pointer; }
.field select option { background: var(--surface2); }

#code-input { font-size: 28px; font-weight: 700; letter-spacing: 8px; text-align: center; padding: 14px; }

.error-msg {
  font-size: 13px; color: var(--error);
  background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-sm); padding: 10px 14px; line-height: 1.4;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; border: none;
  transition: opacity 0.15s, transform 0.1s; text-decoration: none; white-space: nowrap; position: relative;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--accent-dim) 0%, #7c3aed 100%); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-full { width: 100%; margin-top: 4px; }
.btn-label { transition: opacity 0.15s; }
.btn-spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
}
.btn.loading .btn-label { opacity: 0; position: absolute; }
.btn.loading .btn-spinner { display: block !important; }

.link-btn {
  display: block; width: 100%; margin-top: 14px; background: none; border: none;
  color: var(--text-muted); font-size: 13px; font-family: inherit; cursor: pointer;
  text-align: center; text-decoration: underline; text-decoration-color: var(--border2);
  padding: 4px; transition: color 0.15s;
}
.link-btn:hover { color: var(--text); }

/* ─── Animations ─────────────────────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.task-card { animation: fadeIn 0.2s ease; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .hero { padding: 48px 0 64px; }
  .hero-grid { grid-template-columns: 1fr; gap: 40px; }
  .hero-title { font-size: 40px; letter-spacing: -1.5px; }
  .hero-desc { font-size: 15px; }
  .auth-card { padding: 24px; }

  .sidebar { transform: translateX(-100%); }
  .app-main { margin-left: 0; }
  .app-view { padding: 20px; }
  .field-row { grid-template-columns: 1fr; }
}
