/* Lesson preview editor spacing improvements */
#lessonPlanEditor,
#mfpEditor,
#passageEditor,
#handoutEditor,
#slidesEditor {
  font-size: 0.95rem;
  line-height: 1.8;
  margin-bottom: 20px;
  padding: 18px 20px;
  background: #f7f7f7;
  border-radius: 10px;
  border: 1.5px solid #e4e8ef;
  color: #222;
  word-break: break-word;
  min-height: 80px;
}

/* Extra spacing for headings and bold text inside editors */
#lessonPlanEditor b,
#mfpEditor b,
#passageEditor b,
#handoutEditor b,
#slidesEditor b {
  font-weight: 700;
  color: #151a26;
}
#lessonPlanEditor h2, #lessonPlanEditor h3,
#mfpEditor h2, #mfpEditor h3,
#passageEditor h2, #passageEditor h3,
#handoutEditor h2, #handoutEditor h3,
#slidesEditor h2, #slidesEditor h3 {
  margin-top: 24px;
  margin-bottom: 14px;
  font-size: 1.2em;
  color: #176bff;
}

/* Reset & base styles */
body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--light-grey);
  color: #151a26;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 700px;
  margin: 60px auto 60px auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 40px rgba(23,107,255,0.07);
  padding: 28px 32px 40px 32px;
}

.main-box {
  box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.1);
}

.header {
  text-align: center;
  margin-bottom: 18px;
}
.header h1 {
  margin: 0 0 6px 0;
  font-size: 2.3rem;
  color: #176bff;
  letter-spacing: -1px;
}
.header p {
  color: #6b7384;
  font-size: 1.12rem;
  margin: 0 0 8px 0;
}

.form-container {
  margin-top: 0;
}

.section {
  margin: 20px 0 12px 0;
  padding: 20px 20px 8px 20px;
  background: #ffffff;
  border-radius: 13px;
}

.section-title {
  display: flex;
  align-items: center;
  font-size: 1.42rem;
  font-weight: 700;
  color: #176bff;
  margin: 0 0 20px 0;
  letter-spacing: -0.5px;
}
.section-logo {
  display: flex;
  align-items: center;
  margin-right: 10px;
}
.section-logo svg {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 20px 22px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.form-group-wide {
  grid-column: 1 / 3;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #232c43;
  margin-bottom: 0;
}

.required-label .required {
  color: #ff3030;
  font-size: 1rem;
}

input[type="text"], input[type="number"], select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 13px 16px;
  border: 1.5px solid #c8d2eb;
  border-radius: 9px;
  background: #f6f9fe;
  outline: none;
  transition: border-color 0.18s;
  margin-bottom: 0;
  color: #435175;
}
input:focus, select:focus, textarea:focus {
  border-color: #176bff;
  background: #f6f9fe;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

select {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg fill="gray" height="16" viewBox="0 0 20 20" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M7.293 7.293a1 1 0 011.414 0L10 8.586l1.293-1.293a1 1 0 111.414 1.414l-2 2a1 1 0 01-1.414 0l-2-2a1 1 0 010-1.414z" /></svg>');
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 18px 18px;
  color: #151a26;
}

input::placeholder,
textarea::placeholder {
  color: #a2adc3;
  opacity: 1;
}

textarea {
  min-height: 54px;
  resize: vertical;
  font-size: 0.95rem;
  font-family: inherit;
  background: #f6f9fe;
}
.char-counter {
  color: #b7bdd1;
  font-size: 0.85rem;
  margin-top: 1px;
  align-self: flex-end;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 0 0 0 8px;
  margin: 22px 0 0 0;
  font: inherit;
  font-size: 1.27rem;
  font-weight: 700;
  color: #176bff;
  cursor: pointer;
  outline: none;
  user-select: none;
  transition: background 0.16s;
}
.collapse-toggle:hover,
.collapse-toggle:focus {
  background: #eef4ff;
  border-radius: 9px;
}
.toggle-icon {
  font-size: 1.25em;
  margin-left: auto;
  color: #176bff;
  transition: transform 0.19s cubic-bezier(.86,0,.07,1);
  transform: rotate(-90deg);
}
.collapse-toggle[aria-expanded="true"] .toggle-icon {
  transform: rotate(0deg);
}

.collapsible-content {
  display: none;
  margin-bottom: 0;
  animation: fadeInCollapsible 0.24s;
}
.collapsible-content.show {
  display: block;
}

@keyframes fadeInCollapsible {
  from { opacity: 0; transform: translateY(-8px);}
  to { opacity: 1; transform: none;}
}

.form-actions {
  margin: 32px 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

button.generate-btn, button.save-btn {
  font-size: 17px;
  padding: 13px 26px;
  border: none;
  border-radius: 9999px;
  background: var(--primary-blue);
  color: #fff;
  font-weight: 400;
  cursor: pointer;
  margin: 0 0 0 0;
  box-shadow: 0 2px 8px rgba(23,107,255,0.08);
  transition: background 0.16s, box-shadow 0.16s;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
button.generate-btn:disabled {
  background: #aecbfa;
  cursor: not-allowed;
}
button.generate-btn .spinner {
  border: 3px solid #fff;
  border-top: 3px solid #176bff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin {
  100% { transform: rotate(360deg);}
}
.generate-message {
  margin-top: 8px;
  color: #176bff;
  font-weight: 500;
  font-size: 1.09rem;
  text-align: center;
}

/* Simple loading panel (index.html) */
/* Backdrop for lesson generation modal */
#spinnerOverlay{
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
  justify-content: center;
  align-items: center;
}
.lp-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
.lp-load-card{
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  padding: 22px;
  color: #222;
}
.lp-load-title{margin:0 0 6px; font-size: 20px; font-weight: 700;}
.lp-load-step{margin:8px 0 8px; color:#435175; font-size: 14px;}
.lp-load-sub{margin:0 0 14px; color:#666; font-size: 14.5px;}
.lp-load-bar{width:100%; height:10px; background:#EEF2FF; border-radius:9999px; overflow:hidden; margin: 0 0 12px;}
.lp-load-fill{height:100%; width:0%; background:#176bff; transition: width .15s linear;}
.lp-load-stages{list-style:none; margin:0; padding:0; display:grid; gap:6px;}
.lp-load-stages li{display:flex; align-items:center; gap:8px; font-size:14px; color:#333; opacity:.6;}
.lp-load-stages li.active{opacity:1;}
.lp-load-stages .dot{width:10px; height:10px; border-radius:50%; background:#cbd5e1; display:inline-block;}
.lp-load-stages li.active .dot{background:#10B981;}
/* Completed stage shows a green check emoji instead of the dot */
.lp-load-stages li.done .dot{display:none;}
.lp-load-stages li.done::before{content:'✅'; font-size:16px; line-height:1;}

/* Accordion toggle for load stages */
.lp-steps-toggle{
  background: #eef4ff;
  color: #176bff;
  border: 1px solid #d7e3ff;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin: 6px 0 8px;
}
.lp-steps-toggle:hover{background:#e5efff;}

.lesson-plan-output {
  margin: 35px 0 0 0;
  background: #f6f9fe;
  border: 2px solid #c8d2eb;
  border-radius: 13px;
  padding: 38px 30px;
  min-height: 32px;
  font-size: 1.15rem;
  box-shadow: 0 2px 12px rgba(23,107,255,0.05);
  color: #111c33;
  word-break: break-word;
}

.lesson-plan-output .error {
  color: #e54747;
  font-weight: 600;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .container {
    max-width: 97vw;
    padding: 9px 2vw 32px 2vw;
  }
  .form-grid {
    grid-template-columns: 1fr;
    gap: 17px;
  }
  .form-group-wide {
    grid-column: 1 / 2;
  }
  .section {
    padding: 13px 6vw 6px 6vw;
  }
}

/* Center the preview/edit Quill editor boxes */
.preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-editor-block {
  max-width: 800px;
  width: 100%;
  margin-bottom: 20px;
}

/* Center the page title on preview page */
.preview-title {
  text-align: center;
  margin-top: 40px;
  margin-bottom: 35px;
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: #151a26;
}

.collapsible-toggle {
  width: 100%;
  background: #176bff;
  color: #fff;
  border: none;
  padding: 14px 20px;
  text-align: left;
  font-size: 1.22rem;
  font-weight: 700;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.18s;
}

.collapsible-toggle:after {
  content: "▼";
  float: right;
  margin-left: 10px;
  font-size: 1rem;
  transition: transform 0.3s;
}

.collapsible-toggle.active:after {
  transform: rotate(-180deg);
}

.collapsible-content {
  display: none;
  padding-top: 0;
  padding-bottom: 18px;
  animation: fadeInCollapsible 0.21s;
}

.collapsible-content.show {
  display: block;
}

@keyframes fadeInCollapsible {
  from { opacity: 0; transform: translateY(-8px);}
  to { opacity: 1; transform: none;}
}

/* ... All your existing styles up to ... */

/* ========== AI LESSON LAB PROMPT MANAGER FIXES BELOW ========== */

/* Prompt group container */
.prompt-group {
  width: 98%;
  margin: 0 auto 2rem auto;
  max-width: 680px;
  min-width: 280px;
  padding: 0;
  box-sizing: border-box;
  border: 1.5px solid #d1d5db;
  border-radius: 12px;
  background: #fafbfc;
}

/* Accordion header (group label) */
.accordion-header {
  background: #eef8fc;
  border: none;
  font-weight: bold;
  width: 100%;
  margin: 0 0 1rem 0;
  display: block;
  box-sizing: border-box;
  padding-left: 1.6rem;
  padding-right: 1.6rem;
  font-size: 1.2rem;
  border-radius: 9px;
  text-align: left;
}

/* Prompt file-list style buttons */
#prompt-list button {
  display: block !important;
  width: auto !important;
  min-width: 140px !important;
  max-width: 96% !important;
  margin: 2px 0 2px 0 !important;
  padding: 8px 18px !important;
  font-size: 1.08rem !important;
  border-radius: 6px !important;
  background: #f7f9fc !important;
  border: 1px solid #e0e4ea !important;
  font-weight: 500 !important;
  text-align: left !important;
  transition: background 0.13s !important;
  box-sizing: border-box !important;
  cursor: pointer;
}
#prompt-list button:hover {
  background: #eaf6fb !important;
  border: 1px solid #176bff !important;
}

/* Search and custom tag input boxes fit container, no overflow */
#search,
#custom-tag-input {
  width: 97% !important;
  max-width: 97% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  margin-bottom: 1rem !important;
  display: block;
}

/* Editor flex layout */
.inline-editor {
  flex-wrap: wrap;
  gap: 30px;
}
.editor-left, .editor-right {
  max-width: 100%;
}

/* Responsive for mobile/small screens */
@media (max-width: 850px) {
  .container {
    max-width: 99vw !important;
    padding: 12px 2vw 24px 2vw !important;
  }
  .inline-editor {
    flex-direction: column;
    gap: 12px;
  }
  #search,
  #custom-tag-input {
    min-width: 0 !important;
    width: 98vw !important;
    max-width: 98vw !important;
  }
  .editor-left, .editor-right {
    min-width: 0 !important;
    max-width: 99vw !important;
  }
  .prompt-group {
    max-width: 99vw !important;
    width: 99vw !important;
  }
}

/* ===== Lesson Pilot header & footer (LP-prefixed, isolated) ===== */


/* HEADER */
.lp-header{
  background: #fff;
  border-bottom: 1px solid var(--border-dark);
  margin-bottom: 15px;
}
.lp-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  height:var(--navbar-height);
  gap:0;
  position:relative;
}
/* Ensure nested containers don't reintroduce background */
.lp-header .lp-container,
.lp-footer .lp-container {
  background: transparent;
}
.lp-brand{display:flex;align-items:center;gap:10px;text-decoration:none;}
.lp-header .lp-logo{
  transform:translate(23px, 10px);
}
.lp-logo{height:49px;width:auto;display:block;}

.lp-navlinks{
  display:flex;
  align-items:center;
  gap:36px;
  position:absolute;
  left:50%;
  transform:translateX(calc(-50% - 99px)) translateY(10px);
}

/* nav link colors/states to kill purple visited */
.lp-link:link,
.lp-link:visited{
  color:rgba(0, 0, 0, 0.6);
  text-decoration:none;
  font-weight:500;
  font-size:17px;
}
.lp-link:hover{color:var(--primary-blue);}
.lp-link[aria-current="page"]{color:var(--primary-blue);}

.lp-btn{
  background:var(--primary-blue);
  color:#fff;
  text-decoration:none;
  font-family:'Inter', Arial, sans-serif;
  font-weight:400;
  font-size:17px;
  line-height:1.4em;
  text-align:left;
  padding:6px 23px;
  height:24px;
  width:232px;
  border-radius:9999px;       /* pill */
  box-shadow:var(--shadow-soft);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  transform:translate(-23px, 10px);
}
.lp-btn:hover{background:var(--hover-blue);}

@media (max-width:992px){
  .lp-nav{flex-wrap:wrap;height:auto;padding:12px 0;}
  .lp-navlinks{
    position:static;
    transform:none;
    order:3;
    width:100%;
    justify-content:center;
    margin-top:8px;
    gap:24px;
  }
}

/* FOOTER */
.lp-footer{background:#fff; position: relative;}
.lp-footer .lp-container{
  position: relative;
}
.lp-footer::before{
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-dark);
}
.lp-footer-grid{
  display:grid;
  grid-template-columns:1fr 1fr 1fr;
  gap:0;
  padding:44px 0 64px 0;
  align-items:start;
  position:relative;
  margin-left:17.5%;
}
.lp-footer-grid > div:first-child{
  margin-left:0;
}
.lp-footer-grid > div:nth-child(2){
  text-align:left;
}
.lp-footer-grid > div:last-child{
  margin-right:0;
  text-align:left;
}
.lp-foothead{
  margin:0 0 20px 0;
  color:var(--dark);
  font-size:16px;
  font-weight:600;
}
.lp-footlist{list-style:none;margin:0;padding:0;display:grid;gap:20px;}
.lp-footlink:link,
.lp-footlink:visited{
  color:var(--text-mid);
  text-decoration:none;
}
.lp-footlink:hover{color:var(--primary-blue);}

.lp-footer-bottom{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:32px 0;
}
.lp-footer-bottom small{
  color:var(--text-mid);
  font-size:17px;
  margin-left:17.5%;
}

.lp-socials{
  margin-right:17.5%;
}
.lp-socials a{
  margin-left:14px;
  color:var(--text-mid);
  text-decoration:none;
}
.lp-socials a:hover{color:var(--primary-blue);}

@media (max-width:768px){
  .lp-footer-grid{grid-template-columns:1fr;gap:24px;}
  .lp-footer-bottom{flex-direction:column;gap:12px;align-items:flex-start;}
}

/* Download cards (lessonpackdownload) */
.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  margin-bottom: 24px;
  background: var(--light-grey);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  border: none;
}

.download-icon {
  width: 24px;
  height: 24px;
  margin-right: 16px;
  flex-shrink: 0;
}

.download-icon img {
  width: 100%;
  height: 100%;
}

.download-content {
  flex: 1;
  margin-right: 16px;
  min-width: 0;
}

/* ===== Mobile fixes for lesson pages ===== */
@media (max-width: 768px) {
  .container {
    max-width: 100% !important;
    width: 100% !important;
    padding: 16px !important;
    margin: 12px auto !important;
  }

  /* Ensure equal left/right spacing on the white info card */
  .info-card {
    max-width: 100% !important;
    width: 100% !important;
    padding: 16px 14px !important; /* top/bottom 16px, left/right 14px */
    margin: 12px auto !important;
    box-sizing: border-box;
  }

  /* Ensure equal left/right spacing on each download card */
  .download-item {
    max-width: 100% !important;
    width: 100% !important;
    padding: 16px 14px !important; /* top/bottom 16px, left/right 14px */
    margin: 12px auto !important;
    box-sizing: border-box;
  }

  /* Ensure index form card has 15px vertical padding on mobile */
  .container.main-box {
    padding-top: 15px !important;
    padding-bottom: 15px !important;
  }

  .lesson-details {
    grid-template-columns: 1fr 1fr 1fr !important; /* Keep 3 columns for 3x2 grid */
    gap: 12px !important;
  }

  /* Ensure index form card has 15px vertical padding on mobile */
  .container.main-box {
    padding-top: 15px !important;
    padding-bottom: 15px !important;
  }

  .lesson-details {
    grid-template-columns: 1fr 1fr 1fr !important; /* Keep 3 columns for 3x2 grid */
    gap: 12px !important;
  }
}

/* ===== Extra mobile UX fixes for lessonpackdownload ===== */
@media (max-width: 768px) {
  /* Make each download card stack nicely */
  .download-item {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  /* Make download button full-width for easier tapping */
  .download-btn {
    width: 100% !important;
    max-width: 100% !important;
    min-width: auto !important;
  }

  /* Improve spacing inside lesson details */
  .lesson-details {
    grid-template-columns: 1fr 1fr 1fr !important; /* Keep 3 columns for 3x2 grid */
    row-gap: 8px;
  }

  /* Reduce size of title text slightly */
  .info-title {
    font-size: 18px !important;
  }
}

@media (max-width: 480px) {
  .lesson-details {
    grid-template-columns: 1fr 1fr !important; /* 2 columns on very small screens */
    gap: 8px !important;
  }
}