/* ── Lesson Plan Modal ── */
.lp-modal-overlay {
  position: fixed; inset: 0; z-index: 200000;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.lp-modal-overlay.show { display: flex; }
.lp-modal-box {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 24px; width: 95%; max-width: 1100px;
  max-height: 90vh; display: flex; flex-direction: column;
  overflow: hidden; box-shadow: 0 25px 60px rgba(0,0,0,0.6);
}
.lp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.lp-header h2 {
  margin: 0; font-size: 1.2rem; font-weight: 700;
  color: #e2e8f0; display: flex; align-items: center; gap: 10px;
}
.lp-header h2 i { color: #6366f1; }
.lp-close-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05); color: #94a3b8;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: 1rem;
  transition: all 0.2s;
}
.lp-close-btn:hover { background: rgba(239,68,68,0.15); color: #ef4444; }

/* ── Tabs ── */
.lp-tabs {
  display: flex; gap: 4px; padding: 12px 24px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}
.lp-tab {
  padding: 10px 20px; border: none; border-radius: 10px 10px 0 0;
  background: transparent; color: #64748b; cursor: pointer;
  font-size: 0.82rem; font-weight: 600; transition: all 0.2s;
  display: flex; align-items: center; gap: 8px;
}
.lp-tab:hover { color: #94a3b8; background: rgba(255,255,255,0.03); }
.lp-tab.active { color: #e2e8f0; background: rgba(99,102,241,0.1); }
.lp-content {
  flex: 1; overflow-y: auto; padding: 24px;
}
.lp-tab-panel { display: none; }
.lp-tab-panel.show { display: block; }

/* ── 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: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 18px; cursor: pointer;
  transition: all 0.25s;
}
.lp-saved-card:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(99,102,241,0.3);
  transform: translateY(-2px);
}
.lp-saved-card h4 { margin: 0 0 6px; font-size: 0.95rem; color: #e2e8f0; }
.lp-saved-card .lp-saved-meta {
  font-size: 0.75rem; color: #64748b; 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: #64748b;
}
.lp-empty i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }

/* ── Mode Selector ── */
.lp-mode-selector {
  display: flex; gap: 8px; margin-bottom: 24px;
  background: rgba(255,255,255,0.04);
  border-radius: 14px; padding: 6px;
  border: 1px solid rgba(255,255,255,0.06);
}
.lp-mode-btn {
  flex: 1; padding: 10px 16px; border: none; border-radius: 10px;
  background: transparent; color: #64748b; cursor: pointer;
  font-size: 0.82rem; font-weight: 600; transition: all 0.25s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.lp-mode-btn:hover { color: #94a3b8; }
.lp-mode-btn.active {
  background: rgba(99,102,241,0.15); color: #818cf8;
  box-shadow: 0 2px 8px rgba(99,102,241,0.15);
}

/* ── Tiling Cards Grid ── */
.lp-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.lp-tile-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; overflow: hidden;
  transition: all 0.25s;
  display: flex; flex-direction: column;
}
.lp-tile-card:hover {
  border-color: rgba(99,102,241,0.2);
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.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 rgba(255,255,255,0.05);
  cursor: pointer; user-select: none;
}
.lp-tile-header h3 {
  margin: 0; font-size: 0.82rem; font-weight: 700;
  color: #818cf8; display: flex; align-items: center; gap: 8px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.lp-tile-header .lp-collapse-icon {
  color: #475569; 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: #64748b; font-weight: 600;
  display: block; margin-bottom: 6px; text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lp-input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05); color: #e2e8f0;
  font-size: 0.85rem; transition: border-color 0.2s;
  box-sizing: border-box; font-family: inherit;
}
.lp-input:focus { outline: none; border-color: #6366f1; }
.lp-textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05); color: #e2e8f0;
  font-size: 0.85rem; transition: border-color 0.2s;
  box-sizing: border-box; font-family: inherit; resize: vertical;
  min-height: 60px;
}
.lp-textarea:focus { outline: none; border-color: #6366f1; }
select.lp-input option { background: #1e293b; color: #e2e8f0; }

/* ── 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: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  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: none;
  background: rgba(239,68,68,0.1); color: #ef4444; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s;
}
.lp-section-remove:hover { background: rgba(239,68,68,0.2); }
.lp-add-section-btn {
  padding: 8px 14px; border-radius: 8px; border: 1px dashed rgba(255,255,255,0.1);
  background: transparent; color: #64748b; cursor: pointer;
  font-size: 0.78rem; transition: all 0.2s; display: flex;
  align-items: center; gap: 6px; width: 100%; justify-content: center;
}
.lp-add-section-btn:hover { border-color: #6366f1; color: #818cf8; }

/* ─── 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: none;
  background: rgba(239,68,68,0.1); color: #ef4444; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.65rem; transition: all 0.2s;
}
.lp-obj-remove:hover { background: rgba(239,68,68,0.2); }
.lp-add-obj-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px dashed rgba(255,255,255,0.1);
  background: transparent; color: #64748b; cursor: pointer;
  font-size: 0.72rem; transition: all 0.2s; display: flex;
  align-items: center; gap: 6px; justify-content: center; margin-top: 4px;
}
.lp-add-obj-btn:hover { border-color: #6366f1; color: #818cf8; }

/* ─── 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: none;
  background: rgba(239,68,68,0.1); color: #ef4444; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.65rem; transition: all 0.2s;
}
.lp-mat-remove:hover { background: rgba(239,68,68,0.2); }
.lp-add-mat-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px dashed rgba(255,255,255,0.1);
  background: transparent; color: #64748b; cursor: pointer;
  font-size: 0.72rem; transition: all 0.2s; display: flex;
  align-items: center; gap: 6px; justify-content: center; margin-top: 4px;
}
.lp-add-mat-btn:hover { border-color: #6366f1; color: #818cf8; }

/* ─── Generate Button ─── */
.lp-generate-btn {
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; font-size: 0.95rem; font-weight: 700; cursor: pointer;
  transition: all 0.25s; display: flex; align-items: center;
  justify-content: center; gap: 10px; margin-top: 20px;
}
.lp-generate-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(99,102,241,0.3); }
.lp-generate-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── Preview ─── */
#lpPreviewOverlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(16px);
  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 8px 30px rgba(0,0,0,0.4);
  border-radius: 4px;
  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 #6366f1;
}
.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: #6366f1; margin: 0 0 6px;
  border-left: 4px solid #6366f1; 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: 10px; border: none;
  cursor: pointer; font-size: 0.78rem; font-weight: 600;
  transition: all 0.2s; display: flex; align-items: center; gap: 6px;
}
.lp-toolbar-btn.success {
  background: rgba(16,185,129,0.15); color: #34d399;
  border: 1px solid rgba(16,185,129,0.2);
}
.lp-toolbar-btn.success:hover { background: rgba(16,185,129,0.25); }
.lp-toolbar-btn.primary {
  background: rgba(99,102,241,0.15); color: #818cf8;
  border: 1px solid rgba(99,102,241,0.2);
}
.lp-toolbar-btn.primary:hover { background: rgba(99,102,241,0.25); }
.lp-toolbar-btn.danger {
  background: rgba(239,68,68,0.15); color: #ef4444;
  border: 1px solid rgba(239,68,68,0.2);
}
.lp-toolbar-btn.danger:hover { background: rgba(239,68,68,0.25); }

/* ─── Source Lessons ─── */
.lp-lesson-row:hover { background: rgba(255,255,255,0.06) !important; }
.lp-lesson-row input[type="checkbox"]:checked + label { color: #818cf8; }

/* ─── 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: 14px 20px;
  background: rgba(15,23,42,0.95); border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}

@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; }
}
