/* MJ Mind — Secure Task Management System */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242838;
  --border: #2e3348;
  --text: #e4e6ef;
  --text2: #9498b0;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
  --green: #34d399;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #f87171;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

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

/* ─── Login ─── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d27 50%, #0f1117 100%);
  min-height: 100vh;
}
.login-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.login-header h1 { font-size: 1.5rem; }
.login-subtitle { color: var(--text2); font-size: 0.9rem; }
.login-form .form-group { margin-bottom: 1.25rem; }

/* ─── Navbar ─── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1200px; margin: 0 auto; padding: 0.75rem 1rem;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; text-decoration: none; color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.nav-links a { text-decoration: none; color: var(--text2); padding: 0.25rem 0.5rem; border-radius: 6px; }
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface2); }
.nav-user { color: var(--text2); font-size: 0.85rem; padding: 0 0.5rem; }
.nav-logout { color: var(--red) !important; }

/* ─── Container ─── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem; }

/* ─── Page Header ─── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h2 { font-size: 1.3rem; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text);
  font-size: 0.9rem; cursor: pointer; text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { background: var(--border); border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--green); border-color: var(--green); color: #000; font-weight: 600; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ─── Forms ─── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 0.3rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 0.95rem; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent);
}
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* ─── Alerts ─── */
.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: rgba(248,113,113,0.15); border: 1px solid var(--red); color: var(--red); }
.alert-warning { background: rgba(251,191,36,0.15); border: 1px solid var(--yellow); color: var(--yellow); }
.alert-success { background: rgba(52,211,153,0.15); border: 1px solid var(--green); color: var(--green); }

/* ─── Stats Bar ─── */
.stats-bar {
  display: flex; gap: 1rem; flex-wrap: wrap;
  padding: 0.75rem 1rem; background: var(--surface); border-radius: var(--radius);
  margin-bottom: 1rem; font-size: 0.85rem;
}
.stat { color: var(--text2); }
.stat strong { color: var(--text); }
.stat.progress strong { color: var(--yellow); }
.stat.review strong { color: var(--orange); }
.stat.done strong { color: var(--green); }

/* ─── Filter Tabs ─── */
.filter-tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-tab {
  padding: 0.4rem 0.85rem; border-radius: 8px; font-size: 0.85rem;
  text-decoration: none; color: var(--text2); background: var(--surface);
  transition: all 0.15s;
}
.filter-tab:hover { color: var(--text); background: var(--surface2); }
.filter-tab.active { background: var(--accent); color: #fff; }

/* ─── Task Tree ─── */
.task-tree { }
.task-item {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem 1rem; background: var(--surface); border-radius: 8px;
  margin-bottom: 0.35rem; transition: background 0.15s;
  border: 1px solid transparent;
}
.task-item:hover { border-color: var(--border); background: var(--surface2); }
.task-check { padding-top: 0.2rem; }
.task-checkbox { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.task-body { flex: 1; min-width: 0; }
.task-title {
  font-size: 0.95rem; text-decoration: none; color: var(--text); font-weight: 500;
  display: block; margin-bottom: 0.15rem;
}
.task-title.done { text-decoration: line-through; color: var(--text2); }
.task-title:hover { color: var(--accent); }
.task-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.75rem; flex-wrap: wrap; }
.depth-indicator { color: var(--text2); font-size: 0.8rem; }

/* ─── Status Badges ─── */
.status-badge {
  display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.status-open { background: rgba(108,140,255,0.15); color: var(--accent); }
.status-in_progress { background: rgba(251,191,36,0.15); color: var(--yellow); }
.status-pending_review { background: rgba(251,146,60,0.15); color: var(--orange); }
.status-completed { background: rgba(52,211,153,0.15); color: var(--green); }
.status-archived { background: rgba(148,152,176,0.15); color: var(--text2); }

/* ─── Badge ─── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--red); color: #fff; font-size: 0.7rem; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 4px;
}
.badge-lg { font-size: 0.85rem; padding: 0.25rem 0.75rem; border-radius: 12px; }

/* ─── Priority ─── */
.priority-1 { color: var(--yellow); }
.priority-2 { color: var(--orange); }
.priority-3 { color: var(--red); }

/* ─── Progress Bar Mini ─── */
.progress-bar-mini {
  display: inline-block; width: 40px; height: 4px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}
.progress-bar-mini span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }

/* ─── Child Count ─── */
.child-count { color: var(--text2); font-size: 0.75rem; }

/* ─── Empty State ─── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text2); }
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }

/* ─── Modal ─── */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
}
.modal-content h3 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.form-modal .form-row { gap: 0.75rem; }

/* ─── Task Detail Grid ─── */
.task-detail-grid { display: grid; gap: 1.5rem; }
@media (min-width: 768px) { .task-detail-grid { grid-template-columns: 1fr 340px; } }
.task-detail-main { min-width: 0; }
.task-detail-side { }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.card h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.card-highlight { border-color: var(--green); }
.card-review { border-color: var(--orange); }

/* ─── Breadcrumb ─── */
.breadcrumb { font-size: 0.8rem; color: var(--text2); margin-bottom: 1rem; }
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ─── Task Description ─── */
.task-desc { color: var(--text2); font-size: 0.95rem; line-height: 1.6; }

/* ─── Info Table ─── */
.info-table { width: 100%; font-size: 0.85rem; }
.info-table td { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.info-table td:first-child { color: var(--text2); width: 40%; }

/* ─── Submission ─── */
.submission { padding: 0.75rem; background: var(--surface2); border-radius: 8px; margin-bottom: 0.75rem; }
.submission p { font-size: 0.9rem; margin-bottom: 0.5rem; }
.submission-photo { max-width: 100%; border-radius: 8px; cursor: pointer; margin-top: 0.5rem; }
.review-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* ─── Activity Log ─── */
.activity-log { max-height: 400px; overflow-y: auto; }
.activity-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.activity-item:last-child { border-bottom: none; }
.act-action { color: var(--accent); }
.act-field { color: var(--yellow); font-size: 0.75rem; }
.act-old { color: var(--red); font-size: 0.75rem; text-decoration: line-through; }
.act-arrow { color: var(--text2); font-size: 0.75rem; margin: 0 0.15rem; }
.act-value { color: var(--green); }
.act-time { font-size: 0.7rem; color: var(--text2); margin-top: 0.15rem; }

/* ─── Review List ─── */
.review-list { display: grid; gap: 0.75rem; }
.review-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  transition: border-color 0.15s;
}
.review-card:hover { border-color: var(--orange); }
.review-meta { display: flex; gap: 1rem; font-size: 0.8rem; color: var(--text2); margin-top: 0.3rem; }

/* ─── Table ─── */
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th, .table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.table th { color: var(--text2); font-weight: 600; }

/* ─── Range Slider ─── */
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ─── Help Text ─── */
.help-text { font-size: 0.85rem; color: var(--text2); line-height: 1.6; }

/* ─── Condensed Task Item ─── */
.task-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.45rem 0.75rem; background: var(--surface); border-radius: 8px;
  margin-bottom: 0.25rem; border: 1px solid transparent;
  transition: all 0.15s; cursor: grab; min-height: 36px;
}
.task-item:hover { border-color: var(--border); background: var(--surface2); }
.task-item.dragging { opacity: 0.4; }
.task-item.drag-over { border-color: var(--accent) !important; background: rgba(108,140,255,0.1) !important; }
.task-grip { color: var(--text2); font-size: 0.8rem; cursor: grab; user-select: none; flex-shrink: 0; }
.task-checkbox { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.task-title {
  font-size: 0.88rem; text-decoration: none; color: var(--text); font-weight: 500;
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-title.done { text-decoration: line-through; color: var(--text2); }
.task-title:hover { color: var(--accent); }
.assignee-tag {
  font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 4px;
  background: var(--surface2); color: var(--text2); white-space: nowrap;
  flex-shrink: 0;
}
.child-badge { color: var(--text2); font-size: 0.7rem; margin-left: 0.2rem; }

/* Status dot */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.status-open { background: var(--accent); }
.status-dot.status-in_progress { background: var(--yellow); }
.status-dot.status-pending_review { background: var(--orange); }
.status-dot.status-completed { background: var(--green); }
.status-archived { background: var(--text2); }

/* Action buttons */
.task-actions { display: flex; gap: 0.15rem; flex-shrink: 0; opacity: 0; transition: opacity 0.15s; }
.task-item:hover .task-actions { opacity: 1; }
.action-btn {
  background: none; border: none; color: var(--text2); cursor: pointer;
  padding: 0.2rem 0.3rem; border-radius: 4px; font-size: 0.8rem; line-height: 1;
}
.action-btn:hover { background: var(--border); color: var(--text); }
.review-btn { color: var(--green); }

/* Floating Root drop zone — only visible during drag */
.root-dropzone {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 999;
  width: 56px; height: 56px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: var(--surface); border: 2px dashed var(--border);
  color: var(--text2); font-size: 1.5rem; cursor: pointer;
  transition: all 0.15s; box-shadow: var(--shadow);
}
.root-dropzone.drag-over { display: flex !important; border-color: var(--accent); background: rgba(108,140,255,0.15); color: var(--accent); transform: scale(1.1); }
body.dragging-active .root-dropzone { display: flex; }

/* ─── Review Form ─── */
.review-form .form-row { gap: 1.5rem; }
.review-form input[type="range"] { width: 100%; }
.review-score {
  text-align: center; padding: 0.5rem; background: var(--surface2);
  border-radius: 8px; margin-bottom: 1rem; font-size: 0.9rem;
}
.review-form small { display: block; color: var(--text2); font-size: 0.75rem; margin-top: 0.25rem; }

/* ─── Rewards Page ─── */
.rewards-header { text-align: center; margin-bottom: 2rem; }
.rewards-total { font-size: 2.5rem; font-weight: 700; color: var(--accent); }
.rewards-grid { display: grid; gap: 1rem; }
@media (min-width: 768px) { .rewards-grid { grid-template-columns: 1fr 1fr; } }
.reward-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
}
.reward-card h3 { margin-bottom: 0.5rem; }
.reward-points { font-size: 1.2rem; font-weight: 700; color: var(--green); }
.reward-month { font-size: 0.85rem; color: var(--text2); }
.redeem-btn { width: 100%; margin-top: 0.5rem; }

/* ─── Group Assignments ─── */
.group-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.group-task-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0; border-bottom: 1px solid var(--border); gap: 0.5rem;
}
.group-task-item:last-child { border-bottom: none; }
.group-task-info { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; flex: 1; }
.group-badge {
  display: inline-block; padding: 0.1rem 0.4rem; border-radius: 4px;
  background: rgba(108,140,255,0.15); color: var(--accent); font-size: 0.75rem; font-weight: 600;
}
.accept-btn { font-weight: 700; padding: 0.5rem 1rem; flex-shrink: 0; }

/* ─── Hashed tasks ─── */
.task-hashed { opacity: 0.5; cursor: default; }
.task-hashed .task-grip { visibility: hidden; }
.task-hashed .task-checkbox { display: none; }
.task-hashed .task-actions { display: none; }
.task-hashed .assignee-tag { display: none; }
.task-hashed .status-dot { display: none; }
.task-title.restricted { cursor: default; text-decoration: none; color: var(--text2); }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .nav-inner { flex-wrap: wrap; gap: 0.5rem; }
  .nav-links { flex-wrap: wrap; font-size: 0.8rem; }
  .form-row { flex-direction: column; gap: 0; }
  .stats-bar { font-size: 0.75rem; gap: 0.5rem; }
  .task-item { padding: 0.5rem 0.75rem; }
}
