/* Product Planner — layout and components.
   Cascade: Design/styles.css → mero-product.theme.css → site.css → planner.css
   Rule: только var(--…), никаких хардкод-цветов. */

/* ── Nav: planner-specific bits (app controls live in the shared nav) ──────── */

.nav-divider {
  width: 1px;
  align-self: stretch;
  margin: 14px 4px;
  background: var(--line);
}

/* ── App shell ───────────────────────────────────────────────────────────── */

.p-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: calc(100dvh - 64px);
  overflow: hidden;
  background: var(--board);
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.p-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.p-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.p-list-nav {
  list-style: none;
  margin: 0;
  padding: 8px 0;
  overflow-y: auto;
  flex: 1;
}

.p-list-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
}

.p-list-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .12s, color .12s;
  line-height: 1.3;
}

.p-list-btn:hover {
  background: var(--surface-tint);
  color: var(--text-strong);
}

.p-list-item.active .p-list-btn {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}

.p-list-del {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity .12s, color .12s;
}

.p-list-item:hover .p-list-del { opacity: 1; }
.p-list-del:hover { color: var(--text-strong); }

/* ── Board ───────────────────────────────────────────────────────────────── */

.p-board {
  overflow-y: auto;
}

.p-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 15px;
  text-align: center;
  padding: 24px;
}

/* The .p-empty `display:flex` above beats the UA `[hidden]{display:none}`,
   so the empty state must opt back into hiding explicitly. Without this it
   stays rendered at height:100% and pushes the real board content offscreen. */
.p-empty[hidden] { display: none; }

.btn-link {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: inherit;
  font-family: inherit;
  text-decoration: underline;
  padding: 0;
}

.p-board-content {
  padding: 32px 40px 80px;
  max-width: 760px;
}

/* ── Board header ────────────────────────────────────────────────────────── */

.p-board-header {
  margin-bottom: 32px;
}

.p-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.p-cl-title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-h3);
  font-weight: 800;
  line-height: var(--lh-h3);
  letter-spacing: var(--ls-h3);
  color: var(--text-strong);
  outline: none;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin: -2px -6px;
  word-break: break-word;
  transition: background .1s;
}

.p-cl-title:focus { background: var(--surface-tint); }

.p-cl-title:empty::before {
  content: 'Назва чеклиста…';
  color: var(--text-muted);
  font-weight: 400;
}

.p-del-btn { flex-shrink: 0; }

/* ── Progress ────────────────────────────────────────────────────────────── */

.p-progress-wrap {
  height: 6px;
  background: var(--line-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 7px;
}

.p-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width .25s;
  width: 0%;
}

.p-progress-label {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Sections ────────────────────────────────────────────────────────────── */

.p-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px 12px;
  margin-bottom: 16px;
}

.p-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.p-section-title {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--text-strong);
  outline: none;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
  word-break: break-word;
  transition: background .1s;
}

.p-section-title:focus { background: var(--surface-tint); }

.p-section-title:empty::before {
  content: 'Назва секції…';
  color: var(--text-muted);
  font-weight: 400;
}

.p-section-del {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px 5px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity .12s, color .12s;
}

.p-section:hover .p-section-del { opacity: 1; }
.p-section-del:hover { color: var(--text-strong); }

/* ── Items ───────────────────────────────────────────────────────────────── */

.p-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.p-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.p-item:last-child { border-bottom: none; }

.p-item-cb {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.p-item-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-body);
  outline: none;
  border-radius: 4px;
  padding: 1px 3px;
  margin: -1px -3px;
  word-break: break-word;
  white-space: pre-wrap;
  transition: background .1s;
}

.p-item-text:focus {
  background: var(--surface-tint);
  color: var(--text-strong);
}

.p-item-text:empty::before {
  content: 'Пункт…';
  color: var(--text-muted);
}

.p-item.done .p-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.p-item-del {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .12s, color .12s;
}

.p-item:hover .p-item-del { opacity: 1; }
.p-item-del:hover { color: var(--text-strong); }

.p-add-item {
  margin-top: 10px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color .12s;
}

.p-add-item:hover { color: var(--accent-ink); }

/* ── Add section ─────────────────────────────────────────────────────────── */

.p-add-section { margin-top: 4px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */

.p-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-size: 14px;
  color: var(--text-strong);
  box-shadow: var(--shadow-pop);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.p-toast.visible {
  opacity: 1;
  pointer-events: auto;
}

.p-toast.warn {
  border-color: var(--cream-deep);
  background: var(--surface-cream);
  color: var(--cream-ink);
}

.p-toast.error {
  border-color: var(--cream-deep);
  background: var(--surface-cream);
  color: var(--cream-ink);
}

.p-toast.ok {
  border-color: var(--success);
  color: var(--success);
}

/* ── Mobile sidebar toggle ───────────────────────────────────────────────── */

.p-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--panel);
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-pop);
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Mobile overlay ──────────────────────────────────────────────────────── */

.p-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--midnight);
  opacity: 0.35;
  z-index: 70;
}

.p-overlay.active { display: block; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 760px) {
  .p-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .p-sidebar {
    position: fixed;
    top: 64px;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform .2s ease;
    border-right: 1px solid var(--line-strong);
    box-shadow: var(--shadow-pop);
  }

  .p-sidebar.open {
    transform: translateX(0);
  }

  .p-board {
    min-height: calc(100dvh - 64px);
    overflow: visible;
  }

  .p-board-content {
    padding: 20px 16px 100px;
  }

  .p-sidebar-toggle {
    display: flex;
  }

  /* Keep the shared nav from overflowing on phones: drop power-user controls. */
  .nav-divider,
  #export-btn,
  label[for="import-input"] {
    display: none;
  }
}
