/* Task Manager web app — styled to match deadline_dashboard.html */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
  color: #333;
  min-height: 100vh;
}

.container { max-width: 1400px; margin: 0 auto; }
.hidden { display: none !important; }

.flash {
  background: #FEE2E2;
  color: #991B1B;
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-weight: 500;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

/* ---------- header card ---------- */
.header {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  margin-bottom: 30px;
}
.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}
.header h1 { color: #00356B; font-size: 36px; margin-bottom: 10px; }
.header .subtitle { color: #666; font-size: 16px; }
.logout-btn {
  background: #F3F4F6;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #6B7280;
  transition: all 0.2s;
}
.logout-btn:hover { background: #E5E7EB; color: #374151; }

/* ---------- stats grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}
.stat-card {
  background: white;
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.08);
  text-align: center;
  transition: all 0.3s;
}
.stat-card:hover { transform: translateY(-5px); box-shadow: 0 8px 25px rgba(0,0,0,0.15); }
.stat-number { font-size: 42px; font-weight: bold; margin-bottom: 8px; }
.stat-label { color: #666; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; }
.stat-card.active .stat-number      { color: #3B82F6; }
.stat-card.overdue .stat-number     { color: #EF4444; }
.stat-card.urgent .stat-number      { color: #F59E0B; }
.stat-card.blocked .stat-number     { color: #8B5CF6; }
.stat-card.unscheduled .stat-number { color: #F97316; }
.stat-card.completed .stat-number   { color: #10B981; }

/* ---------- task list card ---------- */
.tasks-section {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  margin-bottom: 30px;
}
.tasks-section h2 { color: #00356B; margin-bottom: 25px; font-size: 24px; }

.task-card {
  background: #F9FAFB;
  border-left: 4px solid #3B82F6;
  padding: 20px;
  margin-bottom: 15px;
  border-radius: 8px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.task-card:hover { transform: translateX(5px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.task-card.priority-high   { border-left-color: #EF4444; }
.task-card.priority-medium { border-left-color: #F59E0B; }
.task-card.priority-low    { border-left-color: #10B981; }
.task-card.priority-completed { border-left-color: #10B981; }
.task-card.blocked { border-left-color: #8B5CF6; background: #FAF5FF; }
.task-card.done { opacity: 0.55; border-left-color: #10B981; }
.task-card.done .task-title { text-decoration: line-through; }

.task-title {
  font-size: 16px;
  font-weight: 600;
  color: #1F2937;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.task-title-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.task-id { font-size: 11px; color: #9CA3AF; font-variant-numeric: tabular-nums; }
.copy-task-btn {
  padding: 3px 10px; border-radius: 6px; border: 1px solid #D1D5DB; background: #F9FAFB;
  color: #6B7280; font-size: 12px; cursor: pointer; transition: all 0.2s; opacity: 0; white-space: nowrap;
}
.task-card:hover .copy-task-btn { opacity: 1; }
.copy-task-btn:hover { background: #E5E7EB; color: #374151; border-color: #9CA3AF; }
.copy-task-btn.copied { background: #D1FAE5; color: #065F46; border-color: #6EE7B7; opacity: 1; }
/* touch devices have no hover — keep the button visible */
@media (hover: none) { .copy-task-btn { opacity: 1; } }
.task-notes { font-size: 13px; color: #6B7280; margin: 8px 0; }
.subtasks { margin: 10px 0 4px; padding-left: 18px; font-size: 13px; color: #6B7280; }
.subtasks li.done { text-decoration: line-through; opacity: 0.7; }

.task-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: #6B7280; }
.task-badge {
  background: #E5E7EB;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.task-badge.project { background: #DBEAFE; color: #1E40AF; }
.task-badge.type    { background: #E5E7EB; color: #374151; }
.task-badge.due     { background: #FEF3C7; color: #92400E; }
.task-badge.blocked { background: #EDE9FE; color: #6B21A8; }
.task-badge.done    { background: #D1FAE5; color: #065F46; }

.no-tasks { text-align: center; padding: 40px; color: #9CA3AF; font-style: italic; }

/* ---------- login ---------- */
.login-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; }
.login-card {
  background: white;
  padding: 40px;
  border-radius: 15px;
  width: 340px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login-card h1 { color: #00356B; font-size: 30px; }
.login-card .subtitle { color: #666; font-size: 15px; margin-top: -8px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #6B7280; font-weight: 500; }
.login-card input {
  padding: 14px 16px;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.3s;
}
.login-card input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.login-card button[type=submit] {
  margin-top: 6px;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.login-card button[type=submit]:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(102,126,234,0.4); }

/* ---------- chat widget ---------- */
#chat-toggle {
  position: fixed; bottom: 24px; right: 24px; width: 60px; height: 60px; border-radius: 50%;
  border: 0; background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%); color: #fff;
  font-size: 26px; cursor: pointer; box-shadow: 0 8px 25px rgba(234,88,12,0.45); z-index: 50;
  transition: transform 0.2s;
}
#chat-toggle:hover { transform: translateY(-3px) scale(1.05); }

.chat-panel {
  position: fixed; bottom: 24px; right: 24px; width: 440px; max-width: calc(100vw - 16px);
  height: 640px; max-height: calc(100vh - 16px); background: white; border-radius: 15px;
  box-shadow: 0 12px 50px rgba(0,0,0,0.3); display: flex; flex-direction: column; z-index: 60;
  overflow: hidden; resize: both; min-width: 300px; min-height: 360px;
}
.chat-head {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%); color: #fff; padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 16px;
  cursor: move; user-select: none; touch-action: none;
}
.chat-head .link-btn { background: none; border: 0; color: rgba(255,255,255,0.85); cursor: pointer; font-size: 14px; margin-left: 12px; }
.chat-head .link-btn:hover { color: #fff; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #F9FAFB; }
.msg { padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; max-width: 85%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: white; color: #1F2937; border: 1px solid #E5E7EB; border-bottom-left-radius: 4px; }
.msg.bot.thinking { opacity: .6; font-style: italic; }
/* markdown rendered inside assistant replies */
.msg.bot { white-space: normal; }
.msg.bot > :first-child { margin-top: 0; }
.msg.bot > :last-child { margin-bottom: 0; }
.msg.bot p { margin: 0 0 8px; }
.msg.bot ul, .msg.bot ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.bot li { margin: 2px 0; }
.msg.bot h3, .msg.bot h4, .msg.bot h5 { margin: 8px 0 4px; font-size: 14px; color: #00356B; }
.msg.bot strong { font-weight: 700; }
.msg.bot em { font-style: italic; }
.msg.bot a { color: #4f46e5; text-decoration: underline; }
.msg.bot code { background: #EEF2FF; color: #3730A3; padding: 1px 5px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.msg.bot pre { background: #1F2937; color: #F9FAFB; padding: 10px 12px; border-radius: 8px; overflow-x: auto; margin: 6px 0; }
.msg.bot pre code { background: none; color: inherit; padding: 0; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid #E5E7EB; background: white; align-items: flex-end; }
.chat-textarea {
  flex: 1; padding: 10px 14px; border: 2px solid #E5E7EB; border-radius: 10px; font-size: 14px;
  font-family: inherit; line-height: 1.4; resize: none; min-height: 48px; max-height: 160px;
  overflow-y: auto; transition: border-color 0.2s;
}
.chat-textarea:focus { outline: none; border-color: #667eea; }
.chat-input button {
  border: 0; border-radius: 10px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff; padding: 0 18px; height: 44px; cursor: pointer; font-weight: 600;
  align-self: flex-end; flex-shrink: 0;
}

/* ---------- search bar ---------- */
.search-container { margin-top: 20px; position: relative; }
.search-box {
  width: 100%;
  padding: 15px 50px 15px 20px;
  font-size: 16px;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  transition: all 0.3s;
  font-family: inherit;
}
.search-box:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.search-icon {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  color: #9CA3AF; font-size: 18px; pointer-events: none;
}

/* ---------- clickable stat cards ---------- */
.stat-card[data-category] { cursor: pointer; border: 2px solid transparent; }
.stat-card.selected { border-color: #667eea; box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3); }

/* ---------- timeline widget ---------- */
.timeline-widget {
  background: white;
  padding: 30px;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  overflow: hidden;
}
.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; gap: 16px; flex-wrap: wrap; }
.timeline-header h2 { color: #00356B; font-size: 24px; }
.timeline-nav { display: flex; gap: 10px; align-items: center; }
.timeline-nav-button {
  background: #F3F4F6; border: none; padding: 10px 16px; border-radius: 8px;
  cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; color: #374151;
}
.timeline-nav-button:hover { background: #E5E7EB; transform: translateY(-2px); }
.timeline-scroll-container { overflow-x: auto; overflow-y: hidden; padding: 10px 0; margin: 0 -10px; display: flex; }
.timeline-track { display: flex; gap: 15px; padding: 0 10px; margin: 0 auto; }
.timeline-day {
  min-width: 140px; background: #F9FAFB; border-radius: 12px; padding: 15px;
  cursor: pointer; transition: all 0.3s; border: 2px solid transparent;
  text-align: center; display: flex; flex-direction: column; align-items: center;
}
.timeline-day:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(0,0,0,0.15); border-color: #286DC0; }
.timeline-day.today { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
.timeline-day.today .timeline-date, .timeline-day.today .timeline-weekday { color: white; }
.timeline-day.selected { border-color: #00356B; background: #DBEAFE; }
.timeline-date { font-size: 14px; font-weight: bold; color: #00356B; margin-bottom: 6px; }
.timeline-weekday { font-size: 12px; color: #6B7280; margin-bottom: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.timeline-indicators { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.timeline-count { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 4px 8px; border-radius: 10px; font-weight: 600; }
.timeline-count.tasks { background: #FEE2E2; color: #991B1B; }
.timeline-day.today .timeline-count { background: rgba(255,255,255,0.3); color: white; }
.timeline-empty { color: #9CA3AF; font-size: 12px; font-style: italic; }
.timeline-day.today .timeline-empty { color: rgba(255,255,255,0.85); }
.scroll-hint { text-align: center; color: #9CA3AF; font-size: 13px; margin-top: 12px; }

/* ---------- tasks header + filter banner ---------- */
.tasks-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; flex-wrap: wrap; }
.tasks-head h2 { color: #00356B; font-size: 24px; margin: 0; }
.filter-banner {
  display: flex; align-items: center; gap: 12px; font-size: 14px; color: #4B5563;
  background: #EEF2FF; border: 1px solid #C7D2FE; padding: 8px 14px; border-radius: 10px;
}
.filter-banner button {
  background: #667eea; border: none; color: white; padding: 5px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.filter-banner button:hover { background: #5568d3; }

/* ---------- header actions + modal ---------- */
.header-actions { display: flex; gap: 10px; align-items: center; }
.header-actions form { margin: 0; }

.modal {
  position: fixed; inset: 0; background: rgba(17, 24, 39, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-card {
  background: white; padding: 30px; border-radius: 15px; width: 380px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-card h3 { color: #00356B; font-size: 22px; margin-bottom: 20px; }
.modal-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #6B7280; font-weight: 500; margin-bottom: 14px; }
.modal-card input {
  padding: 12px 14px; border: 2px solid #E5E7EB; border-radius: 10px; font-size: 15px; font-family: inherit; transition: all 0.2s;
}
.modal-card input:focus { outline: none; border-color: #667eea; box-shadow: 0 0 0 3px rgba(102,126,234,0.1); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.btn-primary {
  border: none; border-radius: 10px; padding: 11px 18px; font-weight: 600; cursor: pointer;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; transition: all 0.2s;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(102,126,234,0.35); }
.btn-secondary {
  border: none; border-radius: 10px; padding: 11px 18px; font-weight: 600; cursor: pointer;
  background: #F3F4F6; color: #374151; transition: all 0.2s;
}
.btn-secondary:hover { background: #E5E7EB; }
.pw-msg { font-size: 14px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; }
.pw-msg.error { background: #FEE2E2; color: #991B1B; }
.pw-msg.ok { background: #D1FAE5; color: #065F46; }

.logout-btn.danger { color: #991B1B; }
.logout-btn.danger:hover { background: #FEE2E2; }
.header-actions a.logout-btn, .header-actions a.btn-primary { text-decoration: none; display: inline-block; }
.task-badge.report { background: #EDE9FE; color: #5B21B6; text-decoration: none; }
.task-badge.report:hover { background: #DDD6FE; }

/* ---------- reports list ---------- */
.report-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px; border: 1px solid #E5E7EB; border-radius: 10px; margin-bottom: 12px; background: #F9FAFB;
}
.report-row-title { font-size: 16px; font-weight: 600; color: #00356B; text-decoration: none; }
.report-row-title:hover { text-decoration: underline; }
.report-row-meta { font-size: 13px; color: #6B7280; margin-top: 4px; }
.report-row-actions { display: flex; align-items: center; gap: 8px; }
.report-row-actions form { margin: 0; }

/* ---------- report form ---------- */
.report-form label { display: block; font-size: 14px; color: #374151; font-weight: 600; margin-bottom: 16px; }
.report-form input[type=text], .report-form textarea {
  width: 100%; margin-top: 6px; padding: 12px 14px; border: 2px solid #E5E7EB; border-radius: 10px;
  font-size: 15px; font-family: inherit;
}
.report-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; line-height: 1.5; resize: vertical; }
.report-form input:focus, .report-form textarea:focus { outline: none; border-color: #667eea; }
.md-hint { font-size: 12px; color: #6B7280; background: #F3F4F6; padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; line-height: 1.7; }
.md-hint code { background: #E5E7EB; padding: 1px 5px; border-radius: 4px; }
.link-tasks { border: 1px solid #E5E7EB; border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.link-tasks legend { font-weight: 600; color: #374151; padding: 0 6px; }
.link-tasks-grid { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; }
.link-task { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; color: #374151; margin: 0; }

/* ---------- task chips ---------- */
.task-chip {
  display: inline-block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; padding: 1px 7px; border-radius: 5px; background: #E5E7EB; color: #374151;
}
.task-chip.known { background: #D1FAE5; color: #065F46; }

/* ---------- report view (print) ---------- */
.report-body { background: #EEF0F4; padding: 0; }
.report-toolbar {
  max-width: 850px; margin: 0 auto; padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.report-toolbar a { color: #00356B; text-decoration: none; font-weight: 600; }
.report-toolbar > div { display: flex; gap: 10px; align-items: center; }
.report-paper {
  max-width: 850px; margin: 0 auto 40px; background: white; padding: 56px 64px;
  border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.12);
}
.report-title { color: #00356B; font-size: 32px; border-bottom: 3px solid #00356B; padding-bottom: 16px; }
.report-meta { color: #6B7280; font-size: 14px; margin: 14px 0 28px; }
.report-content { color: #1F2937; line-height: 1.6; font-size: 15px; }
.report-content h2 { color: #00356B; font-size: 22px; margin: 28px 0 12px; padding-bottom: 8px; border-bottom: 1px solid #E5E7EB; }
.report-content h3 { color: #00356B; font-size: 18px; margin: 22px 0 10px; }
.report-content h4 { color: #374151; font-size: 15px; margin: 18px 0 8px; }
.report-content h5, .report-content h6 { color: #374151; font-size: 14px; margin: 16px 0 6px; }
.report-content p { margin: 0 0 12px; }
.report-content ul, .report-content ol { margin: 0 0 14px; padding-left: 24px; }
.report-content li { margin: 4px 0; }
.report-content li > ul, .report-content li > ol,
.report-content ul ul, .report-content ul ol,
.report-content ol ul, .report-content ol ol { margin: 4px 0 4px; }
.report-content hr { border: 0; border-top: 1px solid #E5E7EB; margin: 24px 0; }
.report-content a { color: #4f46e5; }
.report-content code { background: #F3F4F6; padding: 1px 6px; border-radius: 4px; font-size: 13px; font-family: ui-monospace, Menlo, monospace; }
.report-content pre { background: #1F2937; color: #F9FAFB; padding: 14px 16px; border-radius: 8px; overflow-x: auto; }
.report-content pre code { background: none; color: inherit; }
.callout { padding: 16px 20px; border-radius: 8px; margin: 0 0 18px; }
.callout .callout-title { font-weight: 700; margin-bottom: 8px; }
.callout p:last-child { margin-bottom: 0; }
.callout-note { background: #EEF2FF; border-left: 4px solid #4f46e5; }
.callout-todo { background: #FEF2F2; border: 1px dashed #F87171; color: #991B1B; }
.callout-todo .callout-title { color: #991B1B; }
.callout-card { background: white; border: 1px solid #E5E7EB; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }

@media print {
  .no-print { display: none !important; }
  .report-body { background: white; }
  .report-paper { box-shadow: none; margin: 0; max-width: 100%; padding: 0; border-radius: 0; }
  .callout-card { box-shadow: none; }
  a { color: #1F2937; }
}

@media (max-width: 768px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .header h1 { font-size: 28px; }
  .timeline-scroll-container { justify-content: flex-start; }
  .report-paper { padding: 32px 24px; }
}
