/* =========================================================================
   Project & Task Manager — base styles (no external dependencies)
   ========================================================================= */

:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e5ea;
  --color-text: #1f2430;
  --color-text-muted: #6b7280;
  --color-primary: #2f5fd9;
  --color-primary-dark: #2347ad;
  --color-danger: #d9362f;
  --color-danger-dark: #b32a24;
  --color-success: #1e8e5a;
  --color-warning: #b9790a;
  --sidebar-bg: #1c2333;
  --sidebar-bg-active: #2a3450;
  --sidebar-text: #c7cedd;
  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

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

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

/* ---------- App shell / layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  padding: 0 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-bottom: 10px;
}
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-nav a {
  color: var(--sidebar-text);
  padding: 10px 20px;
  font-size: .92rem;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar-nav a.active { background: var(--sidebar-bg-active); color: #fff; font-weight: 600; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-title { font-size: 1.15rem; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.user-name { color: var(--color-text); font-weight: 500; }
.logout-link { color: var(--color-text-muted); }

.content { padding: 24px; flex: 1; }

.auth-content {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* ---------- Cards / panels ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-box { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px; }
.stat-box .stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-box .stat-label { color: var(--color-text-muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; }

.auth-card { width: 360px; }

/* ---------- Flash messages ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: .9rem; }
.flash-success { background: #e6f4ec; color: var(--color-success); border: 1px solid #b9e3ca; }
.flash-error   { background: #fbe9e8; color: var(--color-danger); border: 1px solid #f3c4c1; }
.flash-info    { background: #e8eefc; color: var(--color-primary-dark); border: 1px solid #c4d4f7; }
.flash-warning { background: #fdf3e0; color: var(--color-warning); border: 1px solid #f4dca7; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; margin-bottom: 4px; font-size: .85rem; }
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 180px; }

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=file], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .92rem;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(47,95,217,.12);
}
.help-text { color: var(--color-text-muted); font-size: .8rem; margin-top: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: #f1f3f5; }
.btn-danger { background: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-dark); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-link { background: none; border: none; color: var(--color-primary); padding: 0; font-weight: 500; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--color-border); vertical-align: top; }
th { color: var(--color-text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfc; }
.table-empty { padding: 24px; text-align: center; color: var(--color-text-muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-todo, .status-active           { background: #e8eefc; color: #2347ad; }
.status-in_progress, .status-on_hold,
.status-paused, .status-not_completed  { background: #fdf3e0; color: #946207; }
.status-blocked                        { background: #fbe9e8; color: #a32a24; }
.status-done, .status-completed        { background: #e6f4ec; color: #1e8e5a; }
.status-archived, .status-cancelled    { background: #ececec; color: #555; }

.priority-low      { background: #ececec; color: #555; }
.priority-medium    { background: #e8eefc; color: #2347ad; }
.priority-high      { background: #fdf3e0; color: #946207; }
.priority-urgent    { background: #fbe9e8; color: #a32a24; }

.role-admin  { background: #eee0fb; color: #6b21a8; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;}
.role-member { background: #e2e8f0; color: #334155; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600;}

.lifecycle-active      { background: #e6f4ec; color: #1e8e5a; }
.lifecycle-deprecated  { background: #fdf3e0; color: #946207; }
.lifecycle-end_of_life { background: #fbe9e8; color: #a32a24; }
.lifecycle-retired     { background: #ececec; color: #555; }

.support-vendor    { background: #e8eefc; color: #2347ad; }
.support-internal  { background: #eee0fb; color: #6b21a8; }
.support-community { background: #fdf3e0; color: #946207; }
.support-none      { background: #ececec; color: #555; }

.status-open      { background: #e8eefc; color: #2347ad; }
.status-fixed     { background: #e6f4ec; color: #1e8e5a; }
.status-wont_fix  { background: #ececec; color: #555; }

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 600;
  color: #fff;
  margin: 0 4px 4px 0;
}
.tag-chip form { display: inline; }
.tag-chip button {
  background: none; border: none; color: #fff; opacity: .8; cursor: pointer; font-size: .85rem; line-height: 1; padding: 0;
}
.tag-chip button:hover { opacity: 1; }

.overdue { color: var(--color-danger); font-weight: 600; }

/* ---------- Misc ---------- */
.muted { color: var(--color-text-muted); }
.text-sm { font-size: .82rem; }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 18px 0; }
.breadcrumb { font-size: .85rem; color: var(--color-text-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--color-text-muted); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }

.comment { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 10px; }
.comment-meta { font-size: .78rem; color: var(--color-text-muted); margin-bottom: 4px; }

.subtask-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--color-border); }
.subtask-row:last-child { border-bottom: none; }

.attachment-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--color-border); }
.attachment-row:last-child { border-bottom: none; }

.pagination { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: .82rem; }
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }

code.kv { background: #f1f3f5; padding: 1px 5px; border-radius: 4px; font-size: .82rem; }

/* ---------- Timeline / Gantt views ---------- */
.gantt-wrap { overflow-x: auto; padding-bottom: 6px; }
.gantt { position: relative; }
.gantt-header { display: flex; border-bottom: 2px solid var(--color-border); margin-bottom: 4px; }
.gantt-month {
  flex-shrink: 0;
  padding: 4px 8px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  white-space: nowrap;
  overflow: hidden;
}
.gantt-body { position: relative; }
.gantt-today {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-danger);
  z-index: 2;
}
.gantt-today-label {
  position: absolute;
  top: -16px;
  left: 4px;
  font-size: .68rem;
  color: var(--color-danger);
  font-weight: 600;
  white-space: nowrap;
}
.gantt-row { position: relative; height: 30px; border-bottom: 1px solid #f0f1f3; }
.gantt-row:last-child { border-bottom: none; }
.gantt-row.swimlane-title-row {
  height: auto;
  min-height: 34px;
  padding: 6px 0;
  background: #f8f9fb;
  border-bottom: 1px solid var(--color-border);
}
.gantt-row.gantt-empty-row { display: flex; align-items: center; }
.gantt-row-label {
  position: absolute;
  left: 0;
  top: 6px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--color-text);
  z-index: 3;
  pointer-events: none;
}
.gantt-bar {
  position: absolute;
  top: 4px;
  height: 22px;
  border-radius: 4px;
  padding: 0 8px;
  font-size: .76rem;
  font-weight: 600;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  text-decoration: none;
  z-index: 1;
}
.gantt-bar:hover { opacity: .88; text-decoration: none; color: #fff; }
.gantt-bar.gantt-task        { background: var(--color-primary); }
.gantt-bar.gantt-maintenance { background: #946207; }
.gantt-bar.gantt-target      { background: #c7cedd; color: #1f2430; }
.gantt-bar.status-done, .gantt-bar.status-completed { background: var(--color-success); }
.gantt-bar.status-blocked    { background: var(--color-danger); }
.gantt-bar.status-cancelled, .gantt-bar.status-wont_fix { background: #8a8f98; }

.swimlane { margin-bottom: 26px; }
.swimlane:last-child { margin-bottom: 0; }
.swimlane-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.swimlane-header h4 { margin: 0; font-size: .95rem; }
.swimlane-header h4 a { color: var(--color-text); }

@media (max-width: 800px) {
  .sidebar { width: 64px; }
  .sidebar-brand { font-size: 0; padding: 0 0 14px; text-align: center; }
  .sidebar-brand::before { content: "PTM"; font-size: 1rem; color: #fff; }
  .sidebar-nav a { text-align: center; padding: 12px 4px; font-size: 0; }
  .sidebar-nav a::first-letter { font-size: .95rem; }
}
