/* ==============================================================
   LESSON PLAN GENERATOR STYLES
   Clean, light, full-page interface (not a dark pop-up)
   ============================================================== */

#lessonPlanModal,
#lpPreviewOverlay {
  --lp-bg: #ffffff;
  --lp-bg-soft: #f8fafc;
  --lp-bg-sunken: #f1f5f9;
  --lp-border: #e2e8f0;
  --lp-border-strong: #cbd5e1;
  --lp-text: #1e293b;
  --lp-text-soft: #475569;
  --lp-text-muted: #64748b;
  --lp-text-faint: #94a3b8;
  --lp-accent: #4f46e5;
  --lp-accent-soft: #eef2ff;
  --lp-accent-border: #c7d2fe;
  --lp-danger: #dc2626;
  --lp-success: #059669;
  --lp-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}

/* ── Page Shell ── */
.lp-modal-overlay {
  position: fixed; inset: 0; z-index: 200000;
  background: var(--lp-bg-sunken);
  display: none; flex-direction: column;
  padding: 0;
}
.lp-modal-overlay.show { display: flex; }
.lp-modal-box {
  background: var(--lp-bg-sunken);
  border: none;
  border-radius: 0; width: 100%; max-width: none;
  height: 100%; max-height: none; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: none;
  animation: lpPageIn 0.22s ease;
}
@keyframes lpPageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
.lp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; border-bottom: 1px solid var(--lp-border);
  background: var(--lp-bg);
  flex-shrink: 0;
}
.lp-header h2 {
  margin: 0; font-size: 1.05rem; font-weight: 700;
  color: var(--lp-text); display: flex; align-items: center; gap: 10px;
  letter-spacing: -0.2px;
}
.lp-header h2 i { color: var(--lp-accent); }
.lp-close-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--lp-border);
  background: var(--lp-bg-soft); color: var(--lp-text-muted);
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 0.95rem;
  transition: all 0.15s;
}
.lp-close-btn:hover { background: #fef2f2; color: var(--lp-danger); border-color: #fecaca; }

/* ── Tabs ── */
.lp-tabs {
  display: flex; gap: 4px; padding: 0 32px;
  border-bottom: 1px solid var(--lp-border);
  background: var(--lp-bg);
  flex-shrink: 0;
}
.lp-tab {
  padding: 14px 16px; border: none; border-radius: 0;
  background: transparent; color: var(--lp-text-muted); cursor: pointer;
  font-size: 0.85rem; font-weight: 600; transition: all 0.15s;
  display: flex; align-items: center; gap: 7px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.lp-tab:hover { color: var(--lp-text); }
.lp-tab.active { color: var(--lp-accent); border-bottom-color: var(--lp-accent); background: transparent; }
.lp-content {
  flex: 1; overflow-y: auto; padding: 32px;
}
.lp-tab-panel { display: none; }
.lp-tab-panel.show { display: block; max-width: 960px; margin: 0 auto; }

/* ── Saved Plans View ── */
.lp-saved-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; margin-top: 16px;
}
.lp-saved-card {
  background: var(--lp-bg);
  border: 1px solid var(--lp-border);
  border-radius: 12px; padding: 18px; cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--lp-shadow);
}
.lp-saved-card:hover {
  border-color: var(--lp-accent-border);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}
.lp-saved-card h4 { margin: 0 0 6px; font-size: 0.95rem; color: var(--lp-text); }
.lp-saved-card .lp-saved-meta {
  font-size: 0.75rem; color: var(--lp-text-muted); display: flex; gap: 12px; flex-wrap: wrap;
}
.lp-saved-card .lp-saved-actions {
  display: flex; gap: 8px; margin-top: 12px;
}
.lp-empty {
  text-align: center; padding: 40px 20px; color: var(--lp-text-muted);
}
.lp-empty i { font-size: 2.5rem; margin-bottom: 12px; color: var(--lp-border-strong); }

/* ── Mode Selector ── */
.lp-mode-selector {
  display: flex; gap: 6px; margin-bottom: 24px;
  background: var(--lp-bg-soft);
  border-radius: 12px; padding: 5px;
  border: 1px solid var(--lp-border);
}
.lp-mode-btn {
  flex: 1; padding: 10px 16px; border: none; border-radius: 8px;
  background: transparent; color: var(--lp-text-muted); cursor: pointer;
  font-size: 0.82rem; font-weight: 600; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.lp-mode-btn:hover { color: var(--lp-text); }
.lp-mode-btn.active {
  background: var(--lp-bg); color: var(--lp-accent);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

/* ── Tiling Cards Grid ── */
.lp-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.lp-tile-card {
  background: var(--lp-bg);
  border: 1px solid var(--lp-border);
  border-radius: 12px; overflow: hidden;
  transition: all 0.15s;
  display: flex; flex-direction: column;
  box-shadow: var(--lp-shadow);
}
.lp-tile-card:hover {
  border-color: var(--lp-border-strong);
}
.lp-tile-card.full-width { grid-column: 1 / -1; }
.lp-tile-card.double-width { grid-column: span 2; }
.lp-tile-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--lp-border);
  cursor: pointer; user-select: none;
  background: var(--lp-bg-soft);
}
.lp-tile-header h3 {
  margin: 0; font-size: 0.78rem; font-weight: 700;
  color: var(--lp-accent); display: flex; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.lp-tile-header .lp-collapse-icon {
  color: var(--lp-text-faint); transition: transform 0.3s; font-size: 0.7rem;
}
.lp-tile-header.collapsed .lp-collapse-icon {
  transform: rotate(-90deg);
}
.lp-tile-body {
  padding: 16px; flex: 1;
}
.lp-tile-body.hidden { display: none; }
.lp-tile-body label {
  font-size: 0.72rem; color: var(--lp-text-muted); font-weight: 600;
  display: block; margin-bottom: 6px; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lp-input {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--lp-border-strong);
  background: var(--lp-bg); color: var(--lp-text);
  font-size: 0.88rem; transition: all 0.15s;
  box-sizing: border-box; font-family: inherit;
}
.lp-input:focus { outline: none; border-color: var(--lp-accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
.lp-input::placeholder { color: var(--lp-text-faint); }
.lp-textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--lp-border-strong);
  background: var(--lp-bg); color: var(--lp-text);
  font-size: 0.88rem; transition: all 0.15s;
  box-sizing: border-box; font-family: inherit; resize: vertical;
  min-height: 60px;
}
.lp-textarea:focus { outline: none; border-color: var(--lp-accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12); }
select.lp-input option { background: #ffffff; color: var(--lp-text); }

/* ── Lesson Structure Section Editor ── */
.lp-sections-list { display: flex; flex-direction: column; gap: 8px; }
.lp-section-item {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--lp-bg-soft);
  border: 1px solid var(--lp-border);
  border-radius: 10px; padding: 10px;
}
.lp-section-item .lp-section-title {
  flex: 2; min-width: 0;
}
.lp-section-item .lp-section-desc {
  flex: 3; min-width: 0;
}
.lp-section-item .lp-section-time {
  width: 60px; flex-shrink: 0;
}
.lp-section-remove {
  width: 28px; height: 28px; border-radius: 7px; border: 1px solid #fecaca;
  background: #fef2f2; color: var(--lp-danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.15s;
}
.lp-section-remove:hover { background: #fee2e2; }
.lp-add-section-btn {
  padding: 8px 14px; border-radius: 8px; border: 1px dashed var(--lp-border-strong);
  background: transparent; color: var(--lp-text-muted); cursor: pointer;
  font-size: 0.78rem; transition: all 0.15s; display: flex;
  align-items: center; gap: 6px; width: 100%; justify-content: center;
}
.lp-add-section-btn:hover { border-color: var(--lp-accent); color: var(--lp-accent); background: var(--lp-accent-soft); }

/* ─── Objectives List ─── */
.lp-objectives-list { display: flex; flex-direction: column; gap: 6px; }
.lp-obj-item {
  display: flex; gap: 8px; align-items: center;
}
.lp-obj-item input { flex: 1; }
.lp-obj-remove {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid #fecaca;
  background: #fef2f2; color: var(--lp-danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.65rem; transition: all 0.15s;
}
.lp-obj-remove:hover { background: #fee2e2; }
.lp-add-obj-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px dashed var(--lp-border-strong);
  background: transparent; color: var(--lp-text-muted); cursor: pointer;
  font-size: 0.72rem; transition: all 0.15s; display: flex;
  align-items: center; gap: 6px; justify-content: center; margin-top: 4px;
}
.lp-add-obj-btn:hover { border-color: var(--lp-accent); color: var(--lp-accent); background: var(--lp-accent-soft); }

/* ─── Materials ─── */
.lp-materials-list { display: flex; flex-direction: column; gap: 6px; }
.lp-mat-item {
  display: flex; gap: 8px; align-items: center;
}
.lp-mat-item input { flex: 1; }
.lp-mat-remove {
  width: 24px; height: 24px; border-radius: 6px; border: 1px solid #fecaca;
  background: #fef2f2; color: var(--lp-danger); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.65rem; transition: all 0.15s;
}
.lp-mat-remove:hover { background: #fee2e2; }
.lp-add-mat-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px dashed var(--lp-border-strong);
  background: transparent; color: var(--lp-text-muted); cursor: pointer;
  font-size: 0.72rem; transition: all 0.15s; display: flex;
  align-items: center; gap: 6px; justify-content: center; margin-top: 4px;
}
.lp-add-mat-btn:hover { border-color: var(--lp-accent); color: var(--lp-accent); background: var(--lp-accent-soft); }

/* ─── Generate Button ─── */
.lp-generate-btn {
  width: 100%; padding: 14px; border: none; border-radius: 10px;
  background: var(--lp-accent);
  color: white; font-size: 0.95rem; font-weight: 700; cursor: pointer;
  transition: all 0.15s; display: flex; align-items: center;
  justify-content: center; gap: 10px; margin-top: 20px;
  box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}
.lp-generate-btn:hover { background: #4338ca; box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3); }
.lp-generate-btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

/* ─── Preview ─── */
#lpPreviewOverlay {
  display: none;
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: #e2e8f0;
  z-index: 300000;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  overflow-y: auto;
}
#lpPreviewOverlay.show {
  display: flex;
}
.lp-preview-page {
  width: 210mm; min-height: 297mm;
  background: white; color: #1e293b;
  padding: 15mm 18mm;
  margin: 20px auto;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12), 0 1px 3px rgba(15, 23, 42, 0.08);
  border-radius: 2px;
  box-sizing: border-box;
  font-family: 'Outfit', 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.6;
  flex-shrink: 0;
}
.lp-preview-page h1 {
  font-size: 1.5rem; color: #0f172a; text-align: center;
  margin: 0 0 16px; padding-bottom: 12px;
  border-bottom: 3px solid #4f46e5;
}
.lp-preview-page .lp-preview-meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  margin-bottom: 20px; font-size: 0.85rem; color: #475569;
}
.lp-preview-page .lp-preview-meta span { display: flex; align-items: center; gap: 4px; }
.lp-preview-page .lp-preview-section {
  margin-bottom: 18px;
}
.lp-preview-page .lp-preview-section h2 {
  font-size: 1.1rem; color: #4f46e5; margin: 0 0 6px;
  border-left: 4px solid #4f46e5; padding-left: 10px;
}
.lp-preview-page .lp-preview-section p {
  margin: 4px 0; font-size: 0.9rem; color: #334155;
}
.lp-preview-page .lp-preview-section ul {
  margin: 4px 0; padding-left: 20px;
}
.lp-preview-page .lp-preview-section li {
  font-size: 0.9rem; color: #334155; margin-bottom: 2px;
}

/* ─── Toolbar Btn ─── */
.lp-toolbar-btn {
  padding: 8px 16px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; font-size: 0.78rem; font-weight: 600;
  transition: all 0.15s; display: flex; align-items: center; gap: 6px;
}
.lp-toolbar-btn.success {
  background: #ecfdf5; color: var(--lp-success);
  border-color: #a7f3d0;
}
.lp-toolbar-btn.success:hover { background: #d1fae5; }
.lp-toolbar-btn.primary {
  background: var(--lp-accent-soft); color: var(--lp-accent);
  border-color: var(--lp-accent-border);
}
.lp-toolbar-btn.primary:hover { background: #e0e7ff; }
.lp-toolbar-btn.danger {
  background: #fef2f2; color: var(--lp-danger);
  border-color: #fecaca;
}
.lp-toolbar-btn.danger:hover { background: #fee2e2; }

/* ─── Source Lessons ─── */
.lp-lesson-row:hover { background: var(--lp-bg-sunken) !important; }
.lp-lesson-row input[type="checkbox"]:checked + label { color: var(--lp-accent); }

/* ─── A4 Print Header (matching Worksheet style) ─── */
.lp-print-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 3px double #334155;
  margin-bottom: 16px;
}

.lp-print-school {
  text-align: center;
  flex: 1;
}

.lp-print-school h1 {
  font-size: 16pt;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 2px 0;
  letter-spacing: normal;
}

.lp-print-school h2 {
  font-size: 12pt;
  font-weight: 600;
  color: #475569;
  margin: 0 0 4px 0;
}

.lp-print-info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 10pt;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 14px;
  gap: 16px;
  flex-wrap: wrap;
}

.lp-print-info-row span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lp-print-info-line {
  display: inline-block;
  width: 80px;
  border-bottom: 1px solid #94a3b8;
}

/* ─── Preview Toolbar ─── */
.lp-preview-toolbar {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 12px 20px;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(8px);
  border: 1px solid var(--lp-border); border-radius: 12px;
  box-shadow: var(--lp-shadow);
  flex-shrink: 0; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}

@media (max-width: 768px) {
  .lp-header,
  .lp-tabs { padding-left: 16px; padding-right: 16px; }
  .lp-content { padding: 20px 16px; }
  .lp-tile-card.double-width { grid-column: span 1; }
}

@media print {
  @page { size: A4; margin: 15mm 18mm; }
  body * { visibility: hidden; }
  #lpPreviewOverlay {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 210mm !important;
    height: auto !important;
    background: none !important;
    backdrop-filter: none !important;
    display: block !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .lp-preview-page, .lp-preview-page * { visibility: visible; }
  .lp-preview-page {
    position: static !important;
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
    orphans: 3;
    widows: 3;
  }
  .lp-preview-page .lp-preview-section {
    page-break-inside: avoid;
  }
  .lp-preview-page .lp-print-header h1 { font-size: 16pt; margin: 0 0 2px 0; }
  .lp-preview-page .lp-print-header h2 { font-size: 12pt; margin: 0 0 4px 0; }
  .lp-preview-page .lp-print-info-row { font-size: 10pt; }
  .lp-preview-page .lp-preview-section h2 { font-size: 13pt; }
  .lp-preview-page p, .lp-preview-page li { font-size: 11pt; }
  .lp-preview-page .lp-print-info-line {
    display: inline-block;
    width: 80px;
    border-bottom: 1px solid #94a3b8;
  }
  .lp-preview-toolbar { display: none !important; }
}
