/* ==========================================================
   Design tokens
   Theme: "drafting table" — a planning tool should feel like a
   technical instrument, not a marketing page. Ink-blue structure,
   a single teal working accent, mono type for anything numeric.
   ========================================================== */
:root {
  --ink-900: #101826;
  --ink-800: #16223a;
  --ink-700: #1d3557;
  --ink-600: #2c4472;

  --paper-0: #ffffff;
  --paper-50: #f7f8fa;
  --paper-100: #eef1f5;
  --paper-200: #dfe4ea;

  --line: #d7dce3;
  --text-body: #202836;
  --text-muted: #626d80;

  --accent: #0d9488;      /* teal — the one working accent color */
  --accent-dim: #e3f4f2;
  --danger: #c62828;
  --danger-dim: #fbe9e9;

  --radius-sm: 4px;
  --radius-md: 8px;
  --shadow-modal: 0 20px 60px rgba(16, 24, 38, 0.35);

  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: var(--font-ui);
  color: var(--text-body);
  background: var(--paper-50);
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 60px;
  flex-shrink: 0;
  background: var(--ink-800);
  color: var(--paper-0);
  border-bottom: 3px solid var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.brand-mark {
  color: var(--accent);
  font-size: 20px;
}
.brand-name {
  font-size: 16px;
}

.view-switch {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.08);
  padding: 4px;
  border-radius: var(--radius-md);
}
.view-switch__btn {
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.75);
  padding: 7px 16px;
  font: 500 13px var(--font-ui);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-switch__btn:hover { color: #fff; }
.view-switch__btn.is-active {
  background: var(--accent);
  color: #fff;
}

.topbar-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.75);
}
.topbar-select select {
  font: 500 12px var(--font-ui);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.topbar-select select option { color: var(--text-body); }

.topbar .btn { margin-left: auto; }

/* ---------------- Buttons ---------------- */
.btn {
  font: 500 13px var(--font-ui);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--primary:hover { filter: brightness(1.08); }
.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-body);
}
.btn--ghost:hover { background: var(--paper-100); }
.btn--danger {
  background: var(--danger-dim);
  color: var(--danger);
}
.btn--danger:hover { filter: brightness(0.97); }

/* ---------------- Workspace / views ---------------- */
.workspace {
  flex: 1;
  overflow: auto;
  padding: 22px;
  /* faint drafting-grid texture under the working area */
  background-image:
    linear-gradient(var(--paper-200) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper-200) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--paper-50);
}

.view-panel { display: none; }
.view-panel.is-active { display: block; }

#calendar {
  background: var(--paper-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  max-width: 1200px;
  margin: 0 auto;
}

/* FullCalendar tone-down to match the tool's palette */
.fc {
  font-family: var(--font-ui);
  --fc-border-color: var(--line);
  --fc-today-bg-color: var(--accent-dim);
  --fc-button-bg-color: var(--ink-700);
  --fc-button-border-color: var(--ink-700);
  --fc-button-hover-bg-color: var(--ink-600);
  --fc-button-active-bg-color: var(--ink-900);
}
.fc .fc-toolbar-title { font-weight: 600; font-size: 18px; color: var(--ink-800); }
.fc-event { cursor: grab; border: none; }
.fc-event:active { cursor: grabbing; }

/* ---------------- Daily tasks panel ---------------- */
.day-tasks-panel {
  max-width: 1200px;
  margin: 0 auto 14px;
  background: var(--paper-0);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}
.day-tasks-panel__title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.day-tasks-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.day-tasks-list__empty {
  font-size: 13px;
  color: var(--text-muted);
}
.day-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.day-task:hover { background: var(--paper-100); }
.day-task input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; }
.day-task__dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.day-task__title { font-size: 13px; flex: 1; }
.day-task__code {
  font: 500 10px var(--font-mono);
  color: var(--text-muted);
  background: var(--paper-100);
  padding: 2px 6px;
  border-radius: 999px;
}

/* Completed-item treatments, shared by calendar events, gantt bars, and the task list */
.is-completed-highlight { opacity: 0.55; filter: saturate(0.6); }
.is-completed-strike .fc-event-title,
.is-completed-strike .day-task__title { text-decoration: line-through; color: var(--text-muted); }
.day-task.is-completed-highlight .day-task__title { color: var(--text-muted); }

.event-code-badge {
  font: 600 10px var(--font-mono);
  background: rgba(255,255,255,0.35);
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 5px;
}

/* ---------------- Gantt view ---------------- */
.gantt-toolbar {
  display: flex;
  justify-content: flex-end;
  max-width: 1200px;
  margin: 0 auto 12px;
}
.gantt-toolbar__modes { display: flex; gap: 4px; }
.chip {
  border: 1px solid var(--line);
  background: var(--paper-0);
  color: var(--text-muted);
  font: 500 12px var(--font-ui);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.chip.is-active {
  background: var(--ink-700);
  border-color: var(--ink-700);
  color: #fff;
}

.gantt-target {
  background: var(--paper-0);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: auto;
}
.gantt .bar { fill: var(--accent); }
.gantt .bar-progress { fill: var(--ink-700); }
.gantt .today-highlight { fill: var(--accent-dim); }
.gantt .bar-wrapper.gantt-completed-highlight .bar { fill: var(--paper-200); }
.gantt .bar-wrapper.gantt-completed-highlight .bar-progress { fill: #9aa5b1; }
.gantt .bar-wrapper.gantt-completed-strike .bar-label { text-decoration: line-through; }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 40px;
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 38, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--paper-0);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal__header h2 { margin: 0; font-size: 16px; color: var(--ink-800); }
.modal__close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.modal__close:hover { color: var(--text-body); }

.modal__body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; min-width: 0; }
.field__label { font-weight: 500; color: var(--ink-800); }
.field__hint { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 6px; }

.field input[type="text"],
.field input[type="number"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  font: 400 14px var(--font-ui);
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper-50);
  color: var(--text-body);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  background: var(--paper-0);
}
.field textarea { resize: vertical; font-family: var(--font-ui); }

.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field--checkbox input { width: 16px; height: 16px; }

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
}
.modal__footer-right { display: flex; gap: 10px; margin-left: auto; }

/* Numeric / time inputs read as data */
#fProgress, #fStart, #fEnd, #fCompletion { font-family: var(--font-mono); }

@media (max-width: 600px) {
  .field-row { flex-direction: column; }
  .topbar { gap: 12px; padding: 0 12px; }
  .brand-name { display: none; }
}
