/* styles.css */
:root{
  --bg:#f6f7fb;
  --panel:#ffffff;
  --panel2:#fbfcff;
  --text:#121522;
  --muted:#5b6477;
  --accent:#2f6fed;
  --border:rgba(18,21,34,.10);
}

*{ box-sizing:border-box; }
html{
  margin:0;
  padding:0;
  height:100%;
  overflow:hidden;
}
body{
  margin:0;
  padding:0;
  height:100vh;
  max-height:100vh;
  overflow:hidden;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;
  background:var(--bg);
  color:var(--text);
  display:flex;
  flex-direction:column;
}
.topbar{ flex-shrink:0; }
code{
  background:rgba(47,111,237,.10);
  padding:2px 6px;
  border-radius:6px;
}

.topbar{
  display:flex;
  gap:12px;
  align-items:center;
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  background:rgba(246,247,251,.92);
  backdrop-filter: blur(10px);
  z-index:100;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  letter-spacing:.2px;
}
.brand-title-desktop{
  display:inline;
}
.brand-title-mobile{
  display:none;
}

.brand-logo{
  height:38px;
  width:auto;
  display:block;
}

.tag-filter-wrap{ position:relative; flex-shrink:0; }
.tag-filter-btn{ padding:8px 12px; border-radius:8px; border:1px solid var(--border); background:var(--panel); color:var(--text); font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap; }
.tag-filter-btn:hover{ border-color:var(--accent); background:rgba(47,111,237,.06); }
.tag-filter-dropdown{ position:absolute; top:100%; left:0; margin-top:4px; min-width:280px; background:var(--panel); border:1px solid var(--border); border-radius:8px; box-shadow:0 6px 20px rgba(0,0,0,.12); z-index:110; overflow:hidden; }
.tag-filter-dropdown button{ display:block; width:100%; padding:10px 14px; border:none; background:0; color:var(--text); font-size:13px; text-align:left; cursor:pointer; }
.tag-filter-dropdown button:hover{ background:rgba(47,111,237,.08); }
.tag-filter-dropdown button[aria-selected="true"]{ background:rgba(47,111,237,.12); font-weight:600; }
.topbar-right{
  display:flex;
  align-items:center;
  gap:10px;
  flex:1;
}
.search{
  flex:1;
  min-width:260px;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
}

.sidebar-toggle{
  display:none;
  border:1px solid var(--border);
  background:var(--panel);
  color:var(--text);
  padding:10px 14px;
  border-radius:999px;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
  align-items:center;
  gap:6px;
}
.sidebar-toggle-icon{
  display:inline-block;
  transition:transform .15s ease;
}
.sidebar-toggle[aria-expanded="true"] .sidebar-toggle-icon{
  transform:rotate(180deg);
}

.layout{
  display:grid;
  grid-template-columns: 320px 1fr;
  flex:1;
  min-height:0;
  overflow:hidden;
  align-items:stretch;
}

.sidebar{
  border-right:1px solid var(--border);
  padding:14px;
  background:linear-gradient(180deg,var(--panel),rgba(255,255,255,.6));
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}
.sidebar > *:last-child{ margin-bottom:0; }

.side-group{ margin-bottom:14px; }

.side-heading{
  font-size:18px;
  font-weight:900;
  color:var(--text);
  margin:6px 4px 12px;
}

.templates-spacer{ height:14px; }

.templates-box{
  border:2px solid rgba(47,111,237,.25);
  background:rgba(47,111,237,.04);
  border-radius:14px;
  padding:12px;
}

.nav{ display:flex; flex-direction:column; gap:6px; }

.category{
  margin:10px 0 6px;
  padding:10px 10px;
  border-radius:12px;
  background:rgba(18,21,34,.03);
  border:1px solid var(--border);
  font-weight:750;
  font-size:13px;
}

.nav a{
  display:block;
  text-decoration:none;
  color:var(--text);
  padding:10px 10px;
  border-radius:10px;
  border:1px solid transparent;
}
.nav a:hover{ background:rgba(18,21,34,.04); }
.nav a.active{
  border-color:rgba(47,111,237,.35);
  background:rgba(47,111,237,.10);
}

.content{
  padding:18px;
  overflow-y: auto;
  min-height: 0;
}

/* Expandable guide with subsections in sidebar */
.nav-guide-with-subs{ margin-bottom:4px; }
.nav-guide-trigger{
  display:block;
  padding:10px 10px;
  text-align:left;
  line-height:1.4;
}
.nav-guide-trigger::before{
  content:"";
  display:inline-block;
  width:0;
  height:0;
  border-left:5px solid transparent;
  border-right:5px solid transparent;
  border-top:6px solid var(--muted);
  margin-right:8px;
  vertical-align:middle;
  transform:translateY(-2px);
  transition:transform .15s ease;
}
.nav-guide-with-subs.expanded .nav-guide-trigger::before{
  transform:rotate(-90deg) translateY(-2px);
}
.nav-subsections{
  display:none;
  flex-direction:column;
  gap:2px;
  margin-left:14px;
  margin-top:4px;
  padding-left:8px;
  border-left:2px solid var(--border);
}
.nav-guide-with-subs.expanded .nav-subsections{ display:flex; }
.nav-subsection{
  font-size:13px;
  padding:6px 10px;
}

.page-header{
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:linear-gradient(180deg,var(--panel2),rgba(255,255,255,.7));
}
.page-header h1{
  margin:0;
  padding:0;
  line-height:1.15;
}
.page-header p{ margin:6px 0 0; }

.muted{ color:var(--muted); }

.page-body{
  margin-top:14px;
  border:1px solid var(--border);
  border-radius:14px;
  background:var(--panel);
  padding:14px;
}

.card{
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(18,21,34,.02);
  padding:14px;
  margin:12px 0;
}
.card h2{ margin:0 0 10px; font-size:18px; }

.card.templates-surface{
  border:2px solid rgba(47,111,237,.25);
  background:rgba(47,111,237,.03);
}

/* Default list styles */
ol{ padding-left:18px; margin:0; }
li{ margin:10px 0; }

/* ---------------- Guide steps (NOT templates) ---------------- */
/* Bigger, more readable steps + more space between step numbers */
.card ol{
  font-size:16px;
  line-height:1.65;
}
.card ol > li{
  margin:0 0 22px;
}
.card ol > li:last-child{
  margin-bottom:0;
}

/* Keep nested lists inside guides readable */
.card ol ul,
.card ol ol{
  margin:8px 0 0 18px;
}
.card ol ul li,
.card ol ol li{
  margin:6px 0;
}

/* Communication & Enquiries: separate checklist section (session-only) */
.checklist-section .checklist-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.checklist-section .checklist-row{
  display:flex;
  align-items:flex-start;
  gap:10px;
  cursor:pointer;
  font-size:15px;
  line-height:1.4;
}
.checklist-section .checklist-cb{
  flex-shrink:0;
  margin-top:3px;
  cursor:pointer;
  width:18px;
  height:18px;
}
.checklist-section .checklist-label{
  color:var(--text);
}

.video-chapter-buttons{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom:14px; }
.video-chapter-btn{ padding:8px 14px; border:1px solid var(--border); border-radius:10px; background:var(--panel); color:var(--text); font-size:13px; cursor:pointer; }
.video-chapter-btn:hover{ border-color:var(--accent); background:rgba(47,111,237,.06); }

.video-embed {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  border-radius: 14px;
  overflow: hidden;
  background: #000;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}


.step-media{
  display:block;             /* force onto new line (fix: not after text) */
  width:fit-content;         /* shrink to image width when smaller */
  max-width:800px;           /* cap large screenshots */
  margin-top:12px;
  margin-bottom:48px;
  border:1px solid var(--border);
  border-radius:14px;
  overflow:hidden;
  background:#fff;
  text-align:left;           /* keep internal alignment normal */
}

/* Keep it left aligned even if a parent ever gets centered */
.card ol > li > .step-media{
  margin-left:0;
  margin-right:auto;
}

.step-media img{
  display:block;
  width:auto;                /* keep natural size if smaller */
  max-width:100%;            /* shrink if bigger than container */
  height:auto;               /* keep proportions */
}

/* Expandable images: magnifying glass cursor on hover */
.step-media img[data-enlargeable]{
  cursor:zoom-in;
}

.step-media .cap{
  padding:10px;
  font-size:12px;
  color:var(--muted);
  border-top:1px solid var(--border);
}


/* Password overlay: full viewport, box centered in the middle */
.password-overlay{
  display:flex;
  align-items:center;
  justify-content:center;
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:rgba(0,0,0,.5);
  z-index:1000;
}
.password-box{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:14px;
  padding:24px;
  min-width:280px;
  box-shadow:0 12px 40px rgba(0,0,0,.2);
}
.password-box h2{ margin:0 0 14px; font-size:20px; }
.password-box input{ width:100%; padding:10px 12px; border-radius:10px; border:1px solid var(--border); font-size:14px; box-sizing:border-box; margin-bottom:10px; }
.password-box .btn{ margin-top:8px; width:100%; padding:10px; font-size:14px; }
.password-error{ display:none; color:#b91c1c; font-size:13px; font-weight:600; margin-bottom:10px; }

.actions{ display:flex; gap:8px; flex-wrap:wrap; margin-top:10px; }
.btn{
  cursor:pointer;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:9px 10px;
  border-radius:10px;
  font-size:12px;
}
.btn.primary{
  border-color:rgba(47,111,237,.35);
  background:rgba(47,111,237,.10);
}
.btn:hover{ border-color:rgba(47,111,237,.35); }

.template-tabs{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:0 0 12px;
}
.tab{
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-size:13px;
}
.tab.active{
  border-color:rgba(47,111,237,.35);
  background:rgba(47,111,237,.10);
}

.template-subject{ margin:6px 0 12px; }

.small{ font-size:14px; color:var(--muted); }

/* Template preview spacing (tuned) */
.template{
  background:#fff;
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
  font-size:16px;
  line-height:1.45;

  /* Disable highlighting/selecting ONLY inside the email template preview box */
  -webkit-user-select:none;
  user-select:none;
  cursor:default;
}

/* Allow selecting/copying links */
.template a{
  -webkit-user-select:text;
  user-select:text;
  cursor:pointer;
}

/* Base text spacing */
.template{
  line-height:1.45;
}

.template p{
  margin:0 0 10px;
}
.template p:last-child{
  margin-bottom:0;
}

/* Lists – tight but readable */
.template ul,
.template ol{
  margin:4px 0 12px 18px;
  padding:0;
}

.template li{
  margin:0;
}

/* Ensure content AFTER lists does not collapse */
.template ul + p,
.template ol + p{
  margin-top:12px;
}

/* Numbered steps spacing */
.template ol > li{
  margin-bottom:12px;
}
.template ol > li:last-child{
  margin-bottom:0;
}

/* Line breaks */
.template br{
  line-height:1.25;
}

/* Hide Outlook spacer paragraphs in website preview */
.template p[style*="mso-line-height-rule"]{
  margin:0 !important;
  line-height:0 !important;
  font-size:0 !important;
  height:0 !important;
  overflow:hidden !important;
}

/* -------- PACE-specific tuning -------- */

.template.pace p{
  margin:0 0 8px;
}

.template.pace p + ol,
.template.pace p + ul{
  margin-top:2px !important;
}

.template.pace ol,
.template.pace ul{
  margin-bottom:16px !important;
}

/* Nested lists inside PACE steps */
.template.pace ol > li{
  margin-bottom:8px;
}

.template.pace ol > li > ul{
  margin:6px 0 12px 18px;
}

.template.pace ol > li > ul > li{
  margin:0 0 4px;
}

.template.pace ol > li > ul > li:last-child{
  margin-bottom:0;
}

/* ---- Fix: spacing after table-wrapped bullet lists (Outlook-friendly HTML) ---- */

/* Give the table block itself some breathing room */
.template table{
  margin:0 0 12px !important;
  border-collapse:collapse;
}

/* If a paragraph comes right after the table, add top space */
.template table + p{
  margin-top:12px !important;
}

/* If a list is inside a table cell and has inline margin:0, override it for website preview */
.template table ul,
.template table ol{
  margin:4px 0 12px 18px !important;
  padding:0 !important;
}

/* Also handle the case where the next element is another block (rare) */
.template table + div,
.template table + section{
  margin-top:12px !important;
}

/* Attachments block inside template panel */
.attachments{
  margin-top:12px;
  padding-top:10px;
  border-top:1px solid var(--border);
}
.attachments-title{
  font-weight:800;
  font-size:13px;
  margin:0 0 8px;
}
.attachments-buttons{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}
a.dl-btn{
  display:inline-block;
  text-decoration:none;
  border:1px solid rgba(47,111,237,.35);
  background:rgba(47,111,237,.10);
  color:var(--text);
  padding:9px 10px;
  border-radius:10px;
  font-size:12px;
}
a.dl-btn:hover{
  border-color:rgba(47,111,237,.55);
}

/* Image lightbox: hidden when closed so it doesn't take space or show a bar */
.image-lightbox{
  display:none;
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:rgba(0,0,0,.85);
  z-index:1000;
  align-items:center;
  justify-content:center;
  padding:20px;
  cursor:pointer;
}
.image-lightbox.active{
  display:flex;
}
.image-lightbox-content{
  position:relative;
  max-width:85vw;
  max-height:90vh;
  cursor:default;
  display:flex;
  align-items:center;
  justify-content:center;
}
.image-lightbox-content img{
  display:block;
  max-width:85vw;
  max-height:90vh;
  width:auto;
  height:auto;
  object-fit:contain;
  border-radius:8px;
  box-shadow:0 4px 20px rgba(0,0,0,.5);
}
.image-lightbox-close{
  position:fixed;
  width:40px;
  height:40px;
  background:rgba(255,255,255,.95);
  border:2px solid rgba(0,0,0,.1);
  border-radius:50%;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  font-weight:700;
  color:var(--text);
  z-index:1002;
  pointer-events:auto;
  box-shadow:0 2px 8px rgba(0,0,0,.15);
}
.image-lightbox-close::before{
  content:"\2715";
  font-size:20px;
  font-weight:700;
}

.footer{
  display:none;
}

@media (max-width: 900px){
  .layout{ grid-template-columns: 1fr; }
  .topbar{
    flex-wrap:wrap;
    align-items:flex-start;
  }
  .brand{
    flex:1 1 auto;
  }
  .brand-title-desktop{
    display:none;
  }
  .brand-title-mobile{
    display:inline;
  }
  .topbar-right{
    flex:1 1 100%;
  }
  .search{
    min-width:0;
    flex:1 1 100%;
  }
  .sidebar-toggle{
    display:flex;
  }
  .tools-group{
    display:none;
  }
  .sidebar{
    border-right:none;
    border-bottom:1px solid var(--border);
    max-height:0;
    padding-top:0;
    padding-bottom:0;
    opacity:0;
    pointer-events:none;
    transition:max-height .2s ease, opacity .2s ease, padding-top .2s ease, padding-bottom .2s ease;
  }
  .sidebar.sidebar-open{
    max-height:70vh;
    opacity:1;
    pointer-events:auto;
    padding-top:14px;
    padding-bottom:14px;
  }
}
