/* ============================================================
   TASKS.CSS — Trang Công việc + Chi tiết Dự án (Sprint 3)
   ============================================================ */


/* ---- Trang Công việc layout ---- */
.tasks-page {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tasks-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
}

/* ---- View toggle ---- */
.view-toggle {
  display: flex;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #6b7280;
  transition: background .15s, color .15s;
}
.view-btn:hover  { background: #f3f4f6; color: #374151; }
.view-btn.active { background: #2563eb; color: #fff; }

/* ---- Filter bar ---- */
.task-filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

/* ---- Tasks table ---- */
.tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.tasks-table thead th {
  background: #f8fafc;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.tasks-table thead th.sortable { cursor: pointer; user-select: none; }
.tasks-table thead th.sortable:hover { background: #f1f5f9; }
.tasks-table thead th.active-sort { background: #eff6ff; color: #2563eb; }

.tasks-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background .12s;
}
.tasks-table tbody tr:hover { background: #f8fafc; }

.tasks-table tbody td {
  padding: 10px 12px;
  color: #374151;
  vertical-align: middle;
}

.col-task-id  { font-family: monospace; font-size: 12px; color: #6b7280; }
.col-task-name { font-weight: 500; max-width: 220px; }
.col-project  { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4b5563; }

/* ---- Status + Priority badges ---- */
.task-status-badge,
.task-priority-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

/* ---- Overdue ---- */
.tasks-table .overdue { color: #dc2626; font-weight: 600; }

/* ---- Empty / Error states ---- */
.tasks-table .empty-cell { text-align: center; padding: 40px; }

/* ---- Skeleton ---- */
.skeleton-cell {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: 4px;
  height: 14px;
}
@keyframes skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-row td { padding: 12px; }

/* ---- Actions ---- */
.action-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  transition: background .12s;
}
.action-btn:hover      { background: #f3f4f6; }
.action-btn.delete-btn:hover { background: #fee2e2; }


/* ============================================================
   TRANG CHI TIẾT DỰ ÁN
   ============================================================ */

.project-detail {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---- Header ---- */
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

.btn-back {
  padding: 6px 14px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  transition: background .15s;
  flex-shrink: 0;
}
.btn-back:hover { background: #e5e7eb; }

.detail-header-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}
.detail-project-id   { font-size: 12px; color: #6b7280; font-family: monospace; }
.detail-project-name { font-size: 18px; font-weight: 700; color: #1e293b; margin: 0; }

/* ---- Tabs bar ---- */
.detail-tabs-bar {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 2px solid #e5e7eb;
}

.tab-btn {
  padding: 12px 18px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: #6b7280;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: #374151; }
.tab-btn.active { color: #2563eb; border-bottom-color: #2563eb; }

/* ---- Tab content ---- */
.detail-tab-content {
  background: #fff;
  border-radius: 0 0 10px 10px;
  padding: 20px;
  min-height: 400px;
}

.tab-pane        { display: block; }
.tab-pane.hidden { display: none; }

/* ---- Loading / Error states ---- */
.tab-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: #6b7280;
  font-size: 15px;
}
.tab-error {
  padding: 20px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
}

/* ---- Tab section header ---- */
.tab-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.tab-section-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  padding: 1px 7px;
  font-weight: 700;
}

/* ---- Nút nhỏ ---- */
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}


/* ============================================================
   TAB 1: TỔNG QUAN
   ============================================================ */

.overview-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.overview-card {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
}

.overview-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: #374151;
  margin: 0 0 16px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.overview-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.overview-card-header h3 { margin: 0; }

/* ---- Phase timeline ---- */
.phase-timeline {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.phase-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  background: #e5e7eb;
  color: #6b7280;
  border: 2px solid #d1d5db;
  transition: all .2s;
}
.phase-step.passed {
  background: #dbeafe;
  color: #2563eb;
  border-color: #93c5fd;
}
.phase-step.active {
  background: #2563eb;
  color: #fff;
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(37,99,235,.2);
}
.phase-arrow { color: #9ca3af; font-size: 14px; }

/* ---- Progress section ---- */
.progress-section {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-bar-large {
  flex: 1;
  height: 12px;
  background: #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar-large .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  border-radius: 6px;
  transition: width .4s ease;
}
.progress-text-large {
  font-size: 14px;
  font-weight: 700;
  color: #2563eb;
  min-width: 38px;
  text-align: right;
}

/* ---- Info grid ---- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.info-row.full-width { grid-column: 1 / -1; }

.info-label {
  font-size: 11.5px;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.info-value {
  font-size: 14px;
  color: #1e293b;
  font-weight: 500;
}


/* ============================================================
   TAB 2: CÔNG VIỆC (grouped by phase)
   ============================================================ */

.phase-groups {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phase-group {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.phase-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
  transition: background .12s;
}
.phase-group-header:hover { background: #f1f5f9; }

.phase-label {
  font-weight: 700;
  color: #2563eb;
  font-size: 13px;
  background: #dbeafe;
  padding: 2px 10px;
  border-radius: 12px;
}
.phase-stats { font-size: 12px; color: #6b7280; flex: 1; }
.phase-toggle { color: #9ca3af; font-size: 12px; }

.phase-group-body { transition: max-height .25s ease; }
.phase-group-body.collapsed { display: none; }

.phase-tasks-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.phase-tasks-table thead th {
  padding: 8px 12px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  font-size: 11.5px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.phase-tasks-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  color: #374151;
}
.phase-tasks-table tbody tr:last-child td { border-bottom: none; }
.phase-tasks-table .overdue { color: #dc2626; font-weight: 600; }

/* Inline status select trong tab tasks */
.inline-status-select {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: #374151;
  background: #fff;
  cursor: pointer;
}
.inline-status-select:focus { outline: none; border-color: #2563eb; }


/* ============================================================
   TAB 3: THÀNH VIÊN
   ============================================================ */

.members-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.members-table thead th {
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  font-size: 12px;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.members-table tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.members-table tbody tr:hover { background: #f8fafc; }

.member-role-select {
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12.5px;
  background: #fff;
  cursor: pointer;
}


/* ============================================================
   TAB 4: LỊCH SỬ
   ============================================================ */

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.log-table thead th {
  padding: 9px 12px;
  background: #f8fafc;
  border-bottom: 2px solid #e5e7eb;
  font-weight: 600;
  font-size: 12px;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.log-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.log-table tbody tr:hover { background: #f8fafc; }

.log-old    { color: #6b7280; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.log-arrow  { color: #9ca3af; text-align: center; font-weight: bold; }
.log-new    { color: #1e293b; font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.log-time   { white-space: nowrap; color: #6b7280; font-size: 12px; }


/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  .tasks-toolbar { flex-direction: column; align-items: stretch; }
  .task-filter-bar { flex-direction: column; }
  .view-toggle { align-self: flex-start; }

  .detail-header { flex-wrap: wrap; }
  .detail-tabs-bar { overflow-x: auto; }
  .tab-btn { padding: 10px 12px; font-size: 12.5px; white-space: nowrap; }

  .info-grid { grid-template-columns: 1fr; }
  .overview-section { grid-template-columns: 1fr; }

  .tasks-table, .members-table, .log-table { font-size: 12px; }
  .tasks-table thead th, .members-table thead th, .log-table thead th { padding: 8px; }
  .tasks-table tbody td, .members-table tbody td, .log-table tbody td  { padding: 8px; }
}
