/* Trang 5 (Lập kế hoạch): giao diện đồng bộ Trang 2-4 (2026-10-17).
 * Chỉ đổi khung biên tập (danh sách slide, đầu thẻ slide, nút, chip chọn). Nội dung slide xem trước
 * giữ màu thương hiệu phòng khám như file xuất. Màu chủ đạo = màu bước 4 "Lập kế hoạch" (xanh lá #059669).
 * Nhiều kiểu cũ viết thẳng trong index.html / slide_editor.js nên phải dùng !important. */

body[data-step="5"] { --p5: #059669; --p5d: #047857; --p5s: #e5f8ef; --p5line: #dfe8e9; --p5ink: #142b38; --p5muted: #607580; --p5bar: 54px; }

/* ---------------------------------------------------------------- thanh trên: nút Xuất PPTX */
.p2-header .btn-tool-export.p5-export {
  height: 38px; border-radius: 11px; padding: 0 16px; gap: 7px; border: none; cursor: pointer;
  font: 800 13.5px 'Be Vietnam Pro', system-ui, sans-serif; color: #fff;
  background: linear-gradient(135deg,#059669,#047857); box-shadow: 0 8px 20px -6px rgba(5,150,105,.55);
  display: inline-flex; align-items: center; white-space: nowrap;
}
.p2-header .btn-tool-export.p5-export:hover { filter: brightness(1.07); }

/* ---------------------------------------------------------------- khung */
body[data-step="5"] #slideEditorContainer { margin: 10px 0 24px !important; font-family: 'Be Vietnam Pro', system-ui, sans-serif; color: var(--p5ink); }
body[data-step="5"] .slide-editor-layout { gap: 10px; padding: 0 6px; flex-direction: column; align-items: stretch; }

/* danh sách slide: dải ngang dính dưới thanh trên (2026-11-06, trước là cột trái 178px).
 * Không xuống dòng; thừa thì cuộn ngang, có ‹ › và mờ 2 đầu; tự cuộn theo slide đang xem (js/p5_thanh_slide.js) */
body[data-step="5"] .slide-nav-sidebar {
  width: auto; min-width: 0; flex: 0 0 auto; padding: 4px; border-radius: 12px; position: sticky; top: calc(var(--hdr-h, 52px) + 6px);
  z-index: 30; border: 1px solid var(--p5line); box-shadow: 0 4px 12px -8px rgba(18,61,64,.25); background: #fff;
  display: flex; align-items: center; gap: 2px; max-height: none; overflow: visible;
}
/* che khe trên dải để nội dung cuộn không lọt qua giữa thanh trên và dải */
body[data-step="5"] .slide-nav-sidebar::before { content: ''; position: absolute; left: -7px; right: -7px; top: -8px; height: 8px; background: #f5f8f8; }
body[data-step="5"] .slide-nav-sidebar .slide-nav-title { display: none !important; }
body[data-step="5"] .slide-nav-list {
  flex: 1 1 auto; min-width: 0; flex-direction: row; flex-wrap: nowrap; gap: 3px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; scroll-behavior: smooth; padding: 2px;
}
body[data-step="5"] .slide-nav-list::-webkit-scrollbar { display: none; }
/* mờ dần ở đầu còn slide khuất */
body[data-step="5"] .slide-nav-list.p5-mo-trai { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 36px); mask-image: linear-gradient(90deg, transparent 0, #000 36px); }
body[data-step="5"] .slide-nav-list.p5-mo-phai { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent 100%); mask-image: linear-gradient(90deg, #000 calc(100% - 36px), transparent 100%); }
body[data-step="5"] .slide-nav-list.p5-mo-trai.p5-mo-phai { -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 36px, #000 calc(100% - 36px), transparent 100%); }
body[data-step="5"] .p5-mui { flex: 0 0 auto; width: 30px; height: 32px; border: none; border-radius: 9px; background: #f3f7f7; color: var(--p5d);
  font: 800 18px/1 'Be Vietnam Pro', system-ui, sans-serif; cursor: pointer; display: grid; place-items: center; transition: opacity .15s; }
body[data-step="5"] .p5-mui:hover { background: var(--p5s); }
body[data-step="5"] .p5-mui:disabled { opacity: .25; cursor: default; background: transparent; }

body[data-step="5"] .btn-slide-nav { width: auto; flex: 0 0 auto; white-space: nowrap; font-size: 12.5px; font-weight: 600; padding: 6px 10px; min-height: 32px;
  border-radius: 9px; color: #38505b; gap: 5px; font-family: inherit; }
body[data-step="5"] .btn-slide-nav:hover { background: #f3f7f7; color: var(--p5d); }
body[data-step="5"] .btn-slide-nav.active { background: var(--p5s); color: var(--p5d); font-weight: 800; box-shadow: inset 0 0 0 1.5px var(--p5); }
body[data-step="5"] .btn-slide-nav .nav-label { overflow: visible; }
body[data-step="5"] .btn-slide-nav .p5-so { font-weight: 800; color: var(--p5muted); }
body[data-step="5"] .btn-slide-nav.active .p5-so { color: var(--p5d); }
body[data-step="5"] .btn-slide-nav .btn-del-slide-nav { display: none; opacity: 1 !important; color: #94a3b8 !important; margin: 0 !important; order: 9; }
body[data-step="5"] .btn-slide-nav:hover .btn-del-slide-nav { display: inline-flex; }
body[data-step="5"] .btn-slide-nav .btn-del-slide-nav:hover { color: #dc2626 !important; }
body[data-step="5"] .slide-nav-list .nav-divider { flex: 0 0 1px; width: 1px; height: 22px; margin: 0 4px; align-self: center; }
body[data-step="5"] .btn-back-photos { background: #fff; border: 1px solid var(--p5line); color: var(--p5muted); }
body[data-step="5"] .btn-back-photos:hover { border-color: #9cc9c4; background: #f0fdfa; color: #0f766e; }
/* màn hẹp: chỉ còn số, rê chuột / chạm giữ thấy tên (title) */
@media (max-width: 1279px) {
  body[data-step="5"] .btn-slide-nav[data-slide] .p5-ten { display: none; }
  body[data-step="5"] .btn-slide-nav[data-slide] { padding: 6px 9px; min-width: 34px; justify-content: center; }
  body[data-step="5"] .btn-slide-nav[data-slide] .p5-so { color: inherit; }
}

/* thẻ slide */
body[data-step="5"] .slide-section-card { border-radius: 16px; border: 1px solid var(--p5line); box-shadow: 0 1px 2px rgba(18,61,64,.04);
  padding: 12px 14px 14px; scroll-margin-top: calc(var(--hdr-h, 52px) + var(--p5bar) + 10px); }
body[data-step="5"] .slide-header-bar { padding: 2px 2px 0; border: none; box-shadow: none; background: transparent; }
body[data-step="5"] .slide-title-text { font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 15.5px; font-weight: 800; color: var(--p5ink); letter-spacing: -.01em; display: flex; align-items: center; }
body[data-step="5"] .btn-del-slide-section { background: #fff !important; color: #94a3b8 !important; border: 1px solid var(--p5line) !important; border-radius: 8px !important;
  width: 26px; height: 26px; padding: 0 !important; display: inline-grid; place-items: center; font-size: 11px !important; }
body[data-step="5"] .btn-del-slide-section:hover { background: #fef2f2 !important; color: #dc2626 !important; border-color: #fca5a5 !important; }
body[data-step="5"] .btn-preview-slide { background: #fff; color: var(--p5d); border: 1.5px solid #a7e3cb; box-shadow: none; border-radius: 10px;
  padding: 7px 14px; font: 700 12.5px 'Be Vietnam Pro', system-ui, sans-serif; display: inline-flex; align-items: center; gap: 6px; }
body[data-step="5"] .btn-preview-slide:hover { background: var(--p5s); border-color: var(--p5); transform: none; filter: none; }

/* 2 cột: hình slide + phần điền */
body[data-step="5"] .slide-visual-panel { border-radius: 12px; border-color: #e6eeef; box-shadow: none; top: calc(var(--hdr-h, 52px) + var(--p5bar) + 6px); }
body[data-step="5"] .slide-criteria-panel { border-radius: 12px; border-color: #e6eeef; box-shadow: none; }
body[data-step="5"] .criterion-card { border-color: #e6eeef; border-radius: 9px; }
body[data-step="5"] .criterion-card:hover { border-color: #a7e3cb; background: #fbfefd; }

/* chip chọn / chip răng: màu xanh dương cũ → màu bước (JS gắn kiểu thẳng nên cần !important) */
body[data-step="5"] .opt-chip.selected,
body[data-step="5"] .btn-tooth-chip.selected,
body[data-step="5"] .btn-inline-fdi-tooth.selected {
  background: var(--p5) !important; border-color: var(--p5) !important; color: #fff !important; box-shadow: 0 1px 3px rgba(5,150,105,.25) !important;
}
body[data-step="5"] .opt-chip:not(.selected):hover { border-color: var(--p5) !important; color: var(--p5d) !important; }
body[data-step="5"] .slide-criteria-panel input:focus,
body[data-step="5"] .slide-criteria-panel textarea:focus,
body[data-step="5"] .slide-criteria-panel select:focus { outline: none; border-color: var(--p5) !important; box-shadow: 0 0 0 3px rgba(5,150,105,.14); }

/* Ô ghi chú nhiều dòng: luôn cao theo nội dung (slide_editor.js p5AutoGrow), không hiện thanh cuộn */
body[data-step="5"] #slideEditorContainer textarea { overflow-y: hidden; }

/* ---------------------------------------------------------------- slide 7: tương quan R3 / R6 (2 cột Phải | Trái) */
.p5-pair-card { background: #fff; border: 1px solid #e6eeef; border-radius: 9px; padding: 6px 8px 4px; margin-bottom: 3px; }
.p5-pair-title { font-weight: 700; color: #0f172a; font-size: 0.82rem; margin: 0 0 4px; }
.p5-pair { display: grid; grid-template-columns: 1fr 1fr; }
/* Sơ đồ cả cung cắn chéo / cắn hở slide 7 (js/slide_editor.js archMap): khoảng cách giữa R3 và R4, dấu thập ở giữa */
.p5-arch { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) 14px repeat(3, minmax(0, 1fr)) 8px repeat(3, minmax(0, 1fr)) 14px repeat(4, minmax(0, 1fr)); grid-template-rows: auto 27px 2px 27px; column-gap: 2px; row-gap: 3px; padding: 5px 6px 6px; margin-bottom: 4px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 6px; }
.p5-arch-cap { grid-row: 1; text-align: center; font-size: 0.68rem; font-weight: 700; color: #64748b; }
.p5-arch-cap.ant { color: #0369a1; }
.p5-arch-h { grid-row: 3; grid-column: 1 / -1; background: #0284c7; }
.p5-arch-v { grid-row: 2 / 5; grid-column: 9; justify-self: center; width: 2px; background: #0284c7; }
.p5-pair > .criterion-card.p5-side { border: none !important; box-shadow: none !important; margin: 0 !important; border-radius: 6px !important;
  padding: 3px 8px 4px 2px !important; min-width: 0; }
.p5-pair > .criterion-card.p5-side + .p5-side { padding: 3px 2px 4px 10px !important; border-left: 1.5px solid #cfdcdf !important; border-radius: 0 6px 6px 0 !important; }
.p5-pair > .p5-side label > span { font-size: 0.78rem !important; color: #38505b !important; }

/* ---------------------------------------------------------------- slide tự tạo của bác sĩ */
.p5-custom-photos { display: grid; gap: 8px; }
.p5-custom-photos.l1 { grid-template-columns: 1fr; }
.p5-custom-photos.l2 { grid-template-columns: 1fr 1fr; }
.p5-custom-photos.l3 { grid-template-columns: 1fr 1fr 1fr; }
.p5-custom-photos.l4 { grid-template-columns: 1fr 1fr; }
.p5-custom-frame { position: relative; aspect-ratio: 4 / 3; border: 1.5px dashed #b9cfd2; border-radius: 10px; background: #f6fafa; overflow: hidden;
  display: grid; place-items: center; cursor: pointer; color: #6b8189; font-size: 12px; font-weight: 600; text-align: center; padding: 0; font-family: inherit; }
.p5-custom-photos.l1 .p5-custom-frame { aspect-ratio: 16 / 9; }
.p5-custom-frame:hover { border-color: var(--p5, #059669); color: var(--p5d, #047857); background: #f0fbf6; }
.p5-custom-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.p5-custom-frame.has-img { border-style: solid; border-color: #dbe4e6; }
.p5-custom-frame .p5-frame-x { position: absolute; top: 5px; right: 5px; width: 22px; height: 22px; border-radius: 7px; border: none; background: rgba(15,23,42,.6);
  color: #fff; font-size: 11px; cursor: pointer; display: none; }
.p5-custom-frame.has-img:hover .p5-frame-x { display: block; }
.p5-custom-title { font-size: 1.15rem; font-weight: 800; text-transform: uppercase; margin: 0 0 2px; font-family: 'Times New Roman', Times, serif; }
.p5-custom-sub { font-size: .85rem; color: #64748b; margin: 0 0 8px; font-family: 'Times New Roman', Times, serif; }
.p5-custom-notes { margin-top: 8px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: .86rem; white-space: pre-wrap;
  font-family: 'Times New Roman', Times, serif; color: #0f172a; min-height: 34px; }
.p5-custom-notes:empty::before { content: 'Ghi chú sẽ hiện ở đây'; color: #94a3b8; font-style: italic; }

/* hộp chọn ảnh của ca cho khung ảnh */
.p5-picker-bg { position: fixed; inset: 0; z-index: 10080; background: rgba(15,23,42,.45); display: grid; place-items: center; padding: 16px; }
.p5-picker { width: min(860px, 100%); max-height: 86vh; background: #fff; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif; box-shadow: 0 24px 60px -12px rgba(15,23,42,.4); }
.p5-picker header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #e6eeef; }
.p5-picker header b { font-size: 15px; color: #142b38; }
.p5-picker header button { border: none; background: #f3f7f7; width: 30px; height: 30px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.p5-picker-grid { padding: 14px 18px 18px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.p5-picker-grid button { border: 1.5px solid #e1eaeb; border-radius: 10px; background: #f8fbfb; padding: 0; cursor: pointer; overflow: hidden; text-align: left; font-family: inherit; }
.p5-picker-grid button:hover { border-color: #059669; }
.p5-picker-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff; display: block; }
.p5-picker-grid span { display: block; font-size: 11.5px; font-weight: 600; color: #38505b; padding: 5px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p5-picker-empty { padding: 30px; text-align: center; color: #607580; font-size: 13px; }

/* Màn cảm ứng không có rê chuột: nút xoá luôn thấy, không bấm nhầm vào nút vô hình */
@media (pointer: coarse) {
  body[data-step="5"] .btn-slide-nav.active .btn-del-slide-nav { display: inline-flex; }
  .p5-custom-frame.has-img .p5-frame-x { display: block; width: 30px; height: 30px; }
}