/* ================= CSS VARIABLES & CORE ================= */
:root { 
  --primary: #2575fc;
  --primary-light: #eff6ff;
  --dark: #1a1a1a;
  --light: #f8f9fa;
  --border: #e9ecef;
  --accent: #00b894;
  --bg: #f0f2f5;
  
  /* Original Table Layout Variables */
  --table-fs: 10.2pt;
  --w-wk: 11.1mm; --w-ls: 10.6mm; --w-st: 19.9mm; --w-sb: 17.2mm; --w-ou: 40.8mm;
  --w-ex: 66.1mm; --w-iq: 17.8mm; --w-rs: 17.8mm; --w-as: 17.8mm; --w-rf: 17.8mm;
}

*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, -apple-system, sans-serif; background: var(--bg); margin: 0; padding: 0; color: #333; -webkit-font-smoothing: antialiased; }

/* ================= NEW LAYOUT: NAVBAR & WIZARD ================= */
.navbar { background: white; padding: 15px 5%; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 10px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 1000; }
.logo { font-size: 20px; font-weight: 800; color: var(--primary); }
.menu a { margin-left: 20px; color: #666; cursor: pointer; font-size: 14px; font-weight: 600; text-decoration: none; transition: color 0.2s; }
.menu a:hover { color: var(--primary); }

.main-wrapper { max-width: 1000px; margin: 40px auto; padding: 0 20px; transition: 0.3s; }

/* WIZARD CARD */
.wizard-card { background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.08); padding: 40px; min-height: 500px; transition: 0.3s; }
@media (max-width: 768px) { .wizard-card { padding: 20px; } }

/* PROGRESS BAR */
.progress-bar { display: flex; justify-content: space-between; margin-bottom: 30px; position: relative; padding: 0 20px; }
.step-item { display: flex; flex-direction: column; align-items: center; opacity: 0.4; transition: 0.3s; width: 25%; }
.step-item.active { opacity: 1; }
.circle { width: 35px; height: 35px; background: #ddd; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: white; margin-bottom: 8px; transition: 0.3s; }
.step-item.active .circle { background: var(--primary); box-shadow: 0 4px 10px rgba(37, 117, 252, 0.3); }
.step-item span { font-size: 12px; font-weight: 700; text-align: center; }

/* STEPS CONTENT */
.step-content { display: none; animation: fadeIn 0.4s ease-in-out; }
.step-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.step-header { text-align: center; margin-bottom: 30px; }
.step-header h2 { margin-bottom: 5px; color: var(--dark); font-weight: 800; font-size: 26px; }
.step-header p { color: #777; margin: 0; font-size: 15px; }

/* INLINE NOTIFICATIONS */
.inline-msg { display: none; padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; font-weight: 600; align-items: center; gap: 8px; }
.inline-msg.error { background: #fef2f2; color: #ef4444; border: 1px solid #fecaca; }
.inline-msg.info { background: #f0fdf4; color: #10b981; border: 1px solid #bbf7d0; }
.warning-box { display: none; background: #fffbeb; color: #b45309; border: 1px solid #fde68a; padding: 15px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; }
.warning-box p { margin: 0 0 12px 0; line-height: 1.5; }
.warning-actions { display: flex; gap: 10px; }

/* SCHOOL GRID (STEP 1) */
.school-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 15px; }
.school-card { border: 2px solid var(--border); border-radius: 10px; padding: 25px 15px; text-align: center; cursor: pointer; transition: 0.2s; background: #fff; }
.school-card:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,0.05); }
.icon-box { width: 50px; height: 50px; border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; color: white; }
.pp { background: #ff9f43; } .lpri { background: #1dd1a1; } .upri { background: #54a0ff; } .jnr { background: #5f27cd; } .snr { background: #ee5253; }
.school-card h3 { margin: 0 0 5px 0; font-size: 16px; color: #1e293b; }
.school-card p { margin: 0; font-size: 12px; color: #64748b; }

/* FORMS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media(max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.full-width { grid-column: 1 / -1; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; font-size: 13px; color: #334155; }
.form-group select, .form-group input { width: 100%; padding: 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; box-sizing: border-box; outline: none; transition: 0.2s; font-family: inherit; }
.form-group select:focus, .form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 117, 252, 0.1); }
.required-star { color: #ef4444; font-weight: bold; margin-left: 2px; }

/* BUTTONS */
.actions { margin-top: 30px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 20px; }
button { padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 14px; transition: 0.2s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: inherit; }
.btn-back { background: #e9ecef; color: #495057; }
.btn-back:hover { background: #dee2e6; color: #111; }
.btn-next { background: var(--primary); color: white; }
.btn-next:hover { background: #1a63d9; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,117,252,0.3); }
.btn-next:disabled { background: #94a3b8; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-highlight { background: var(--accent); color: white; }
.btn-highlight:hover { background: #00a884; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,184,148,0.3); }
.btn-download { background: #ef4444; color: white; }
.btn-download:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(239,68,68,0.3); }

/* ================= EDITOR & TOOLBAR (STEP 4) ================= */
#ui-bar { 
    background: #fff; padding: 10px 20px; border-bottom: 1px solid #cbd5e1; 
    position: sticky; top: 60px; z-index: 2000; display: flex; gap: 8px; align-items: center; 
    box-shadow: 0 4px 6px rgba(0,0,0,.07); overflow-x: auto; white-space: nowrap; 
    -webkit-overflow-scrolling: touch; margin: -40px -40px 20px -40px; border-radius: 12px 12px 0 0;
}
@media (max-width: 768px) { #ui-bar { margin: -20px -20px 20px -20px; } }
.btn { padding: 10px 14px; border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 600; transition: .2s; flex-shrink: 0; color: #334155; }
.btn:hover { background: #f1f5f9; color: #111; }
.btn-blue { background: #1e40af; color: #fff; border-color: #1e3a8a; }
.btn-blue:hover { background: #1e3a8a; color: #fff; }
.btn-sm { padding: 8px 14px; font-size: 12px; }

.fs-control { display: flex; align-items: center; gap: 5px; border-left: 1px solid #cbd5e1; padding-left: 10px; margin-left: 5px; flex-shrink: 0; }
.fs-control input { width: 60px; padding: 6px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 13px; text-align: center; }

#doc-area { width: 100%; min-height: 210mm; background: #fff; padding: 15mm; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.04); overflow-x: auto; position: relative; }
#doc-area.exporting { width: 286mm !important; padding: 0 !important; margin: 0 !important; box-shadow: none !important; border: none !important; overflow: visible; border-radius: 0; }
#doc-title { text-align: center; font-size: 16pt; font-weight: 800; margin: 10px 0 25px; line-height: 1.4; border: 1px dashed transparent; padding: 5px; border-radius: 4px; transition: 0.2s; white-space: pre-wrap; word-wrap: break-word; }
#doc-title:hover { border-color: #cbd5e1; background-color: #f8fafc; }
#doc-title:focus { outline: 2px solid var(--primary); background-color: #fff; border-color: transparent; }

table { width: 100%; border-collapse: collapse; font-size: var(--table-fs); table-layout: fixed; border: none; font-family: 'Times New Roman', Times, serif; }
th, td { border: 1px solid #000 !important; padding: 6px 5px; vertical-align: top; line-height: 1.25; word-wrap: break-word; background-clip: padding-box; color: #000; }
tr { page-break-inside: avoid; break-inside: avoid; }
th { background: #e2e8f0; font-weight: 700; text-align: left; border-bottom: 2px solid #000 !important; font-family: 'Inter', sans-serif; }
.c-week{ width:var(--w-wk); text-align:center; } .c-les{ width:var(--w-ls); text-align:center; } .c-strand{ width:var(--w-st); } .c-sub{ width:var(--w-sb); } .c-out{ width:var(--w-ou); } .c-exp{ width:var(--w-ex); } .c-inq{ width:var(--w-iq); } .c-res{ width:var(--w-rs); } .c-asm{ width:var(--w-as); } .c-ref{ width:var(--w-rf); }
.compact-list { margin: 0; padding-left: 14px; list-style-type: disc; text-align: left; }
.compact-list li { margin-bottom: 4px; }
.compact-list li:last-child { margin-bottom: 0; }
.row-blue { background: #f8fafc; } .row-white { background: #fff; }
.row-break-label { background: #fee2e2; text-align: center; font-weight: 800; vertical-align: middle; text-transform: uppercase; font-family: 'Inter', sans-serif; }
.editable { outline: none; min-height: 20px; } .editable:empty::before { content: " "; white-space: pre; } #doc-area.exporting .editable:empty::before { content: "\00a0"; }

/* ================= EDITOR FULLSCREEN MODE (STEP 4) ================= */
body.editor-mode .navbar,
body.editor-mode .progress-bar,
body.editor-mode #step4 .step-header { display: none !important; }
body.editor-mode .main-wrapper { margin: 0 auto; max-width: 1200px; padding: 0; }
body.editor-mode .wizard-card { padding: 0; box-shadow: none; background: transparent; border-radius: 0; }
body.editor-mode #ui-bar { top: 0; margin: 0 0 20px 0 !important; border-radius: 0 0 8px 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }

/* Modals */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 3000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); padding: 10px; }
.modal-box { background: #fff; padding: 25px; border-radius: 12px; width: 850px; max-width: 100%; max-height: 95vh; overflow-y: auto; display: flex; flex-direction: column; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1); }
.modal-box.large { width: 95%; height: 90vh; }
.modal-sm { width: 450px; }
.col-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.col-inp-grp { display: flex; flex-direction: column; }
.col-inp-grp label { font-size: 12px; font-weight: 700; margin-bottom: 4px; color: #64748b; }
.col-inp-grp input { padding: 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; outline: none; }
.col-inp-grp input:focus { border-color: var(--primary); }

/* Catalog Styles */
#catalog-content { padding: 5px; flex: 1; overflow-y: auto; }
.cat-strand { margin-bottom: 20px; }
.cat-strand-header { background: var(--primary); color: white; padding: 12px 16px; border-radius: 8px; font-weight: 700; font-size: 16px; margin-bottom: 10px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.cat-sub { margin-left: 4px; margin-bottom: 12px; border-left: 4px solid #6366f1; padding-left: 8px; }
.cat-sub-header { background: var(--primary-light); color: var(--primary); border-radius: 6px; margin-bottom: 8px; display: flex; align-items: stretch; border: 1px solid #c7d2fe; transition: 0.2s; user-select: none; }
.cat-sub-header:hover { border-color: var(--primary); }
.ss-select-area { flex: 1; padding: 10px 12px; cursor: pointer; font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.ss-select-hint { font-size: 11px; opacity: 0.8; font-weight: 400; text-transform: uppercase; letter-spacing: 0.5px; }
.ss-arrow { width: 44px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.3); border-left: 1px solid rgba(0,0,0,0.05); font-weight: bold; font-size: 14px; cursor: pointer; transition: background 0.2s; }
.ss-arrow:hover { background: rgba(255,255,255,0.6); }
.cat-lessons-grid { display: none; grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
.cat-lessons-grid.visible { display: grid; }
@media(min-width: 768px) { .cat-lessons-grid.visible { grid-template-columns: 1fr 1fr; } }
.cat-lesson-card { background: white; border: 1px solid #cbd5e1; border-radius: 8px; padding: 12px; cursor: pointer; transition: all 0.2s ease; position: relative; display: flex; flex-direction: column; gap: 6px; }
.cat-lesson-card:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.05); border-color: #94a3b8; }
.cat-lesson-card.selected { border: 2px solid var(--accent); background: #e6fcf5; box-shadow: 0 0 0 2px rgba(0,184,148,0.15); }
.cat-sub-header.selected { background: #e6fcf5 !important; border-color: var(--accent) !important; color: #008f72 !important; }
.cat-lesson-card.selected::after { content: '✓'; position: absolute; top: 8px; right: 8px; background: var(--accent); color: white; width: 20px; height: 20px; border-radius: 50%; text-align: center; line-height: 20px; font-size: 12px; font-weight: bold; }
.cat-l-title { font-weight: 600; font-size: 13px; line-height: 1.35; padding-right: 24px; color: #1e293b; }
.cat-l-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.cat-l-pg { font-size: 11px; color: #64748b; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }
.cat-l-slots { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; color: #475569; }
.cat-l-slots input { width: 40px; padding: 2px; text-align: center; border: 1px solid #cbd5e1; border-radius: 4px; background: #fff; font-weight: 700; outline: none; }
.catalog-toolbar { display: flex; gap: 10px; padding-bottom: 15px; border-bottom: 1px solid #e2e8f0; margin-bottom: 15px; position: sticky; top: 0; background: #fff; z-index: 10; }

/* Custom Reset Confirm Modal */
.reset-confirm-box { text-align: center; padding: 20px; }
.reset-confirm-box i { font-size: 40px; color: #ef4444; margin-bottom: 15px; }
.reset-confirm-box h3 { margin: 0 0 10px; color: #1e293b; font-size: 20px; }
.reset-confirm-box p { color: #64748b; font-size: 14px; margin-bottom: 25px; line-height: 1.5; }

/* Toast */
#toast { position: fixed; right: 20px; bottom: 20px; background: var(--primary); color: #fff; padding: 14px 24px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,.2); display: none; z-index: 4000; font-size: 14px; font-weight: 600; }
#toast.error { background: #ef4444; }
#toast.ok { background: var(--accent); }

/* Accessibility & Focus */
.subject-card:focus, .cat-lesson-card:focus, .ss-select-area:focus, .ss-arrow:focus, .editable:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.ss-select-area:focus { outline-offset: -2px; }

/* ================= PRINT STYLES ================= */
@media print {
  @page { size: A4 landscape; margin: 10mm 10mm 5mm 10mm; }
  html, body { height: auto !important; background: #fff !important; margin: 0 !important; padding: 0 !important; color: #000 !important; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .navbar, .progress-bar, .actions, #ui-bar, .overlay, #toast { display: none !important; }
  .main-wrapper { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .wizard-card { box-shadow: none !important; padding: 0 !important; border-radius: 0 !important; background: transparent !important; }
  .step-content:not(.active) { display: none !important; }
  
  #doc-area { margin: 0 !important; padding: 0 !important; border: none !important; box-shadow: none !important; width: 100% !important; max-width: none !important; overflow: visible !important; position: static !important; }
  table { width: 100% !important; table-layout: fixed !important; border-collapse: collapse !important; page-break-after: auto !important; }
  thead { display: table-row-group !important; }
  tfoot { display: table-row-group !important; }
  tr { page-break-inside: avoid !important; break-inside: avoid !important; page-break-after: auto !important; break-after: auto !important; }
  td, th { page-break-inside: avoid !important; break-inside: avoid !important; border: 1px solid #000 !important; color: #000 !important; word-wrap: break-word !important; vertical-align: top !important; }
  .editable { page-break-inside: avoid !important; break-inside: avoid !important; display: block !important; min-height: 0 !important; }
  #doc-title { margin: 0 0 15px 0 !important; padding: 0 !important; border: none !important; color: #000 !important; page-break-after: avoid !important; break-after: avoid !important; }
  .editable:empty::before { content: "" !important; }
}