/* ==========================================================
   TaskFlow — Task Management System
   Clean, practical, professional UI
   ========================================================== */

:root {
  /* Colors */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-muted: #667085;
  --text-subtle: #98a2b3;

  --primary: #1f4e8c;
  --primary-hover: #173d6e;
  --primary-light: #e6efff;

  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #ca8a04;
  --warning-light: #fef9c3;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #0891b2;
  --info-light: #cffafe;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 10px 25px rgba(16, 24, 40, 0.10), 0 4px 6px rgba(16, 24, 40, 0.05);

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;

  --sidebar-width: 240px;
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================
   APP SHELL
   ========================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: #0f1f3a;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #1f4e8c);
  border-radius: var(--radius);
  color: white;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  letter-spacing: 0.5px;
}
.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.2px;
}
.brand-tag {
  font-size: 11px;
  color: #64748b;
}

.nav {
  flex: 1;
  padding: 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: #cbd5e1;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 2px;
  position: relative;
  transition: background 0.15s;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  text-decoration: none;
  color: #fff;
}
.nav-item.active {
  background: rgba(59,130,246,0.18);
  color: #fff;
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px; bottom: 6px;
  width: 3px;
  background: #3b82f6;
  border-radius: 2px;
}
.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  opacity: 0.85;
}
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #3b82f6, #1f4e8c);
  border-radius: 50%;
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: #94a3b8; }

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  max-width: 1400px;
}

/* ==========================================================
   PAGE HEADER
   ========================================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ==========================================================
   CARDS
   ========================================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--primary);
}
.stat-card.success::after { background: var(--success); }
.stat-card.warning::after { background: var(--warning); }
.stat-card.danger::after { background: var(--danger); }
.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-top: 6px;
  letter-spacing: -0.5px;
}
.stat-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================
   FORMS
   ========================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.form-grid .full { grid-column: 1 / -1; }

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-group .req { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 78, 140, 0.12);
}
textarea.form-control {
  min-height: 90px;
  resize: vertical;
}
select.form-control {
  cursor: pointer;
}
.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.input-with-action {
  display: flex;
  gap: 6px;
}
.input-with-action .form-control { flex: 1; }

/* ==========================================================
   BUTTONS
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--text-muted);
}
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: transparent;
}
.btn-ghost:hover { background: rgba(0,0,0,0.05); }
.btn-ghost.btn-block { color: #cbd5e1; }
.btn-ghost.btn-block:hover { background: rgba(255,255,255,0.06); color: white; }
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn-block { width: 100%; }
.btn-icon {
  padding: 6px 8px;
  font-size: 13px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================
   TABLES
   ========================================================== */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  background: var(--surface-2);
  text-align: left;
  padding: 11px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .text-muted { color: var(--text-muted); font-size: 12.5px; }
.data-table .actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.empty-state {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 36px;
  opacity: 0.5;
  margin-bottom: 10px;
}
.empty-state-title {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 4px;
}

/* ==========================================================
   BADGES
   ========================================================== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 12px;
  letter-spacing: 0.2px;
}
/* Priority */
.badge-low { background: var(--success-light); color: var(--success); }
.badge-medium { background: var(--warning-light); color: var(--warning); }
.badge-high { background: var(--danger-light); color: var(--danger); }
.badge-critical { background: #4c1d95; color: #ede9fe; }
/* Status */
.badge-open { background: #dbeafe; color: #1e40af; }
.badge-in_progress { background: #fef3c7; color: #92400e; }
.badge-review { background: #ede9fe; color: #5b21b6; }
.badge-completed { background: var(--success-light); color: var(--success); }
.badge-closed { background: #f3f4f6; color: #4b5563; }
/* Roles */
.badge-admin { background: #fce7f3; color: #9f1239; }
.badge-user { background: #e0e7ff; color: #3730a3; }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

/* Update types */
.badge-feature { background: var(--info-light); color: var(--info); }
.badge-fix { background: var(--success-light); color: var(--success); }
.badge-improvement { background: #ede9fe; color: #6d28d9; }
.badge-release { background: #fef3c7; color: #92400e; }

/* ==========================================================
   ALERTS
   ========================================================== */
.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert-success {
  background: var(--success-light);
  color: #166534;
  border-color: #bbf7d0;
}
.alert-error {
  background: var(--danger-light);
  color: #991b1b;
  border-color: #fecaca;
}
.alert-info {
  background: var(--info-light);
  color: #155e75;
  border-color: #a5f3fc;
}

/* ==========================================================
   LOGIN PAGE
   ========================================================== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1f3a 0%, #1e3a5f 100%);
  padding: 20px;
}
.login-container::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 20% 30%, rgba(59,130,246,0.15), transparent 50%),
                    radial-gradient(circle at 80% 70%, rgba(99,102,241,0.12), transparent 50%);
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 36px 38px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  position: relative;
  z-index: 1;
}
.login-brand {
  text-align: center;
  margin-bottom: 26px;
}
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #3b82f6, #1f4e8c);
  border-radius: 12px;
  color: white;
  font-weight: 700;
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.login-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.login-hint {
  margin-top: 18px;
  padding: 11px;
  background: var(--surface-2);
  border-radius: var(--radius);
  font-size: 11.5px;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  line-height: 1.6;
}
.login-hint strong { color: var(--text); }

/* ==========================================================
   MODAL / POPUP
   ========================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  width: 28px; height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.url-display {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  color: var(--primary);
  margin-bottom: 12px;
}

/* ==========================================================
   FILTERS / TOOLBAR
   ========================================================== */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar .form-control { width: auto; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 200px; }

/* ==========================================================
   TASK DETAIL
   ========================================================== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-meta {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.meta-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.meta-row:last-child { border-bottom: none; }
.meta-label {
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.4px;
  margin-bottom: 3px;
}
.meta-value { font-size: 13.5px; color: var(--text); }

/* Comments */
.comment-list { margin-top: 8px; }
.comment-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }
.comment-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}
.comment-author { font-weight: 600; font-size: 13px; }
.comment-time { font-size: 12px; color: var(--text-muted); }
.comment-body { font-size: 13.5px; color: var(--text); white-space: pre-wrap; }

/* ==========================================================
   ACTIVITY / TIMELINE
   ========================================================== */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 6px; bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding: 6px 0 14px;
}
.timeline-dot {
  position: absolute;
  left: -22px;
  top: 10px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.timeline-time { font-size: 11.5px; color: var(--text-muted); }
.timeline-text { font-size: 13.5px; }

/* Updates feed */
.update-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.update-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 12px;
}
.update-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.update-version {
  font-family: ui-monospace, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.update-title { font-size: 15px; font-weight: 600; }
.update-meta { font-size: 12px; color: var(--text-muted); }
.update-body {
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.6;
}

/* responsive */
@media (max-width: 800px) {
  .sidebar { width: 100%; position: relative; height: auto; }
  .main { margin-left: 0; padding: 16px; }
  .app-shell { flex-direction: column; }
}

/* utility */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.gap-8 { gap: 8px; }
.mb-0 { margin-bottom: 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12.5px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
