* {
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: #f5f6fa;
  display: flex;
  flex-direction: column;
}

/* ── TITLE BAR ─────────────────────────────────────────────────────────── */
#titleBar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 10px 16px;
  position: relative;
  height: 46px;
  flex-shrink: 0;
}

#pageTitle {
  font-size: 22px;
  font-weight: bold;
  outline: none;
  cursor: text;
  text-align: center;
  flex: 1;
}

#unsavedDot {
  display: none;
  color: #e05555;
  font-size: 14px;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

/* ── LAYOUT ────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* ── TOOL RAIL ──────────────────────────────────────────────────────────  */
.tool-rail {
  width: 46px;
  background: #2c2c2c;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 0;
  gap: 2px;
  flex-shrink: 0;
  overflow-y: auto;
}

.rail-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 17px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}

.rail-btn:hover {
  background: #444;
  color: #fff
}

.rail-btn.active {
  background: #4a90d9;
  color: #fff
}

.rail-sep {
  width: 28px;
  height: 1px;
  background: #444;
  margin: 4px 0
}

.side-panel {
  width: 0;
  overflow: hidden;
  background: #fff;
  border-right: 1px solid #ddd;
  transition: width .2s ease;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.side-panel.open {
  width: 250px
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  font-weight: bold;
  font-size: 13px;
  flex-shrink: 0;
}

.panel-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: #777;
  padding: 0 2px
}

.panel-close:hover {
  color: #333
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px
}

.panel-section label {
  font-size: 11px;
  color: #666;
  display: block;
  margin: 8px 0 3px
}

.panel-section label:first-child {
  margin-top: 0
}

.panel-section input[type=number],
.panel-section input[type=text],
.panel-section select,
.panel-section textarea {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 12px;
  margin-bottom: 2px;
}

.panel-section textarea {
  min-height: 100px;
  resize: vertical
}

.panel-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px
}

/* toggle rail button highlighted */
#railToggle {
  font-size: 13px;
  color: #aaa
}

#railToggle:hover {
  color: #fff
}

/* ── BUTTONS ────────────────────────────────────────────────────────────  */
.btn {
  padding: 5px 9px;
  background: #555;
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px
}

.btn:hover {
  background: #333
}

.btn-blue {
  background: #4a90d9 !important
}

.btn-blue:hover {
  background: #2f78c5 !important
}

.btn-red {
  background: #e05555 !important;
  color: #fff
}

.btn-red:hover {
  background: #c0392b !important
}

.btn-sm {
  padding: 3px 8px;
  font-size: 11px
}

.btn-full {
  width: 100%;
  display: block;
  text-align: center;
}

/* ── FONT PREVIEW ───────────────────────────────────────────────────────  */
.font-preview {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.fp-sans {
  font-family: "Arial", sans-serif;
  font-size: 13px;
  padding: 6px 8px;
  background: #f9f9f9;
  border-radius: 3px;
  border: 1px solid #eee
}

.fp-serif {
  font-family: "Georgia", serif;
  font-size: 13px;
  padding: 6px 8px;
  background: #f9f9f9;
  border-radius: 3px;
  border: 1px solid #eee
}

.fp-nastaliq {
  font-family: "Noto Nastaliq Urdu", serif;
  font-size: 16px;
  padding: 6px 8px;
  background: #f9f9f9;
  border-radius: 3px;
  border: 1px solid #eee;
  direction: rtl
}

/* ── MAIN AREA ──────────────────────────────────────────────────────────  */
.tt-main-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 40px;
  background: #fafafa;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* ── INTRO SCREEN ────────────────────────────────────────────────────────  */
.intro-screen {
  text-align: center;
  margin: 15px auto 40px auto;
  max-width: 750px;
  background: #fff;
  padding: 20px 50px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  color: #333;
  flex-shrink: 0;
}

.intro-icon {
  font-size: 48px;
  color: #4a90d9;
  margin-bottom: 20px;
  line-height: 1;
}

.intro-icon span {
  font-size: 48px;
  width: 48px;
  height: 48px;
}

.intro-screen h2 {
  margin-bottom: 8px;
  color: #2c3e50;
  font-size: 26px;
  font-weight: bold;
}

.intro-subtitle {
  color: #666;
  font-size: 15px;
  margin-bottom: 30px;
}

.intro-benefits {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 35px;
  background: #f8f9fa;
  padding: 24px;
  border-radius: 8px;
  border: 1px solid #eef0f2;
}

.benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.benefit-item span.dashicons {
  font-size: 24px;
  width: 24px;
  height: 24px;
  color: #4a90d9;
  background: rgba(74, 144, 217, 0.1);
  padding: 8px;
  border-radius: 50%;
  border: 1px solid rgba(74, 144, 217, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.benefit-item strong {
  display: block;
  font-size: 15px;
  color: #2c3e50;
  margin-bottom: 4px;
}

.benefit-item p {
  color: #666;
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.intro-instructions {
  text-align: left;
  margin-bottom: 35px;
  padding-left: 10px;
}

.intro-instructions h4 {
  color: #2c3e50;
  font-size: 15px;
  margin-bottom: 12px;
}

.intro-instructions ul {
  color: #555;
  font-size: 13px;
  line-height: 1.6;
  padding-left: 20px;
}

.intro-instructions b {
  color: #222;
}

.intro-btn {
  font-size: 16px;
  padding: 12px 32px;
  font-weight: 600;
  border-radius: 30px;
  box-shadow: 0 4px 12px rgba(74, 144, 217, 0.3);
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.intro-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(74, 144, 217, 0.4);
}

#gridWrap {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

/* ── CELL ───────────────────────────────────────────────────────────────  */
.cell {
  position: absolute;
  background: #fff;
  border: 1px solid #bbb;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: grab;
  user-select: none;
  transition: box-shadow .12s;
}

.cell:hover {
  z-index: 50
}

.cell.dragging {
  opacity: .5;
  cursor: grabbing;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .3)
}

.cell.drag-over {
  box-shadow: 0 0 0 3px #f0a500 !important
}

.cell.duplicate {
  background: rgba(255, 193, 7, .22) !important;
  border-color: #ffc107
}

.cell.hdr {
  background: #727171;
  color: #fff
}

/* ── CONTEXT MENU (cell / row / col) ────────────────────────────────────  */
#ctxMenu {
  position: fixed;
  display: none;
  z-index: 9000;
  background: lightgrey;
  border: 0.5px solid var(--color-border-secondary);
  border-radius: var(--border-radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .25);
  min-width: 200px;
  overflow: hidden;
  padding: 4px 0;
}

#ctxMenu.show {
  display: block
}

.ctx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  font-size: 14px;
  cursor: pointer;
  color: var(--color-text-primary);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .1s;
}

.ctx-item:hover,
.ctx-item:active {
  background: var(--color-background-secondary)
}

.ctx-item .ctx-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0
}

.ctx-item.danger {
  color: var(--color-text-danger)
}

.ctx-item.success {
  color: var(--color-text-success)
}

.ctx-sep {
  height: 0.5px;
  background: var(--color-border-tertiary);
  margin: 4px 0
}

/* legacy #tb hidden — menu now context-driven */
#tb {
  display: none !important
}

/* ── CELL CONTENT ───────────────────────────────────────────────────────  */
.cell-body {
  pointer-events: none;
  line-height: 1.4;
  padding: 4px
}

.c-subj {
  font-weight: bold;
  font-size: 12px
}

.c-tchr {
  font-style: italic;
  font-size: 11px;
  color: #555
}

.c-room {
  font-size: 10px;
  color: #888
}

.cell.hdr .c-tchr,
.cell.hdr .c-room {
  color: #ddd
}

.hdr-input {
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  width: 100%;
  height: 100%;
  font-weight: bold;
  font-size: 12px;
  color: #fff;
  pointer-events: all;
  cursor: text;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle
}

/* ── SAVED SLOTS ────────────────────────────────────────────────────────  */
.slot-save-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px
}

.slot-save-row input {
  flex: 1
}

.slot-empty {
  font-size: 12px;
  color: #999;
  padding: 4px 0
}

.slot-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
  gap: 6px
}

.slot-row:last-child {
  border-bottom: none
}

.slot-row.slot-active {
  background: #f0f7ff;
  border-radius: 4px;
  padding: 6px 4px
}

.slot-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0
}

.slot-name {
  font-size: 12px;
  font-weight: bold;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.slot-ts {
  font-size: 10px;
  color: #999
}

.slot-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0
}

/* ── MODAL ──────────────────────────────────────────────────────────────  */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 300;
  backdrop-filter: blur(2px);
}

#modal {
  display: none;
  position: fixed;
  z-index: 301;
  background: #fff;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .22);
  width: min(92vw, 380px);
  /* centre on desktop, bottom-sheet on mobile */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
}

@media(max-width:520px) {
  #modal {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    border-radius: 20px 20px 0 0;
  }
}

.modal-header {
  background: #4a90d9;
  padding: 18px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.modal-header-close {
  background: rgba(255, 255, 255, .2);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: #fff;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.modal-header-close:hover {
  background: rgba(255, 255, 255, .35)
}

.modal-body {
  padding: 20px
}

.modal-field {
  margin-bottom: 14px
}

.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #888;
  margin-bottom: 5px;
}

.modal-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  color: #222;
  outline: none;
  transition: border-color .15s;
}

.modal-field input:focus {
  border-color: #4a90d9
}

.modal-btns {
  display: flex;
  gap: 8px;
  padding: 0 20px 20px;
}

.modal-btns button {
  flex: 1;
  padding: 11px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: opacity .15s;
}

.modal-btns button:active {
  opacity: .8
}

#mSave {
  background: #4a90d9;
  color: #fff
}

#mSave:hover {
  background: #2f78c5
}

#mCancel {
  background: #f0f0f0;
  color: #555
}

#mCancel:hover {
  background: #e0e0e0
}

.ctx-group {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 2px 8px;
  border: 0.5px solid var(--color-border-tertiary);
  border-radius: var(--border-radius-md);
  overflow: hidden;
}

.ctx-group-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 6px;
  font-size: 13px;
  cursor: pointer;
  color: var(--color-text-primary);
  border: none;
  background: none;
  border-right: 0.5px solid var(--color-border-tertiary);
}

.ctx-group-btn:last-child {
  border-right: none
}

.ctx-group-btn:hover,
.ctx-group-btn:active {
  background: var(--color-background-secondary)
}

.ctx-group-btn.success {
  color: var(--color-text-success)
}

.ctx-group-btn.danger {
  color: var(--color-text-danger)
}

.ctx-group-label {
  font-size: 10px;
  color: var(--color-text-secondary);
  padding: 0 12px;
  margin-top: 6px;
  display: block;
}

.rz-handle {
  position: absolute;
  z-index: 100;
  cursor: pointer;
  border-radius: 3px;
  background: rgba(74, 144, 217, .18);
  border: 1px solid rgba(74, 144, 217, .35);
}

.rz-handle:hover {
  background: rgba(74, 144, 217, .4);
  border-color: rgba(74, 144, 217, .7)
}

/* .rz-col-handle {
  cursor: col-resize
}

.rz-row-handle {
  cursor: row-resize
} */

.rz-popup {
  position: absolute;
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 3px;
  background: #1a1a1a;
  border-radius: 5px;
  padding: 3px 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  white-space: nowrap;
}

.rz-btn {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  background: rgba(255, 255, 255, .25);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rz-btn:hover {
  background: rgba(255, 255, 255, .45)
}

.rz-label {
  font-size: 10px;
  color: #ccc;
  font-weight: bold;
  padding: 0 2px
}


.storage-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 7px 18px;
  border-radius: 20px;
  font-size: 12px;
  z-index: 9999;
  pointer-events: none;
  transition: opacity .4s;
  opacity: 0;
  white-space: nowrap;
}

.toast-error {
  background: #c0392b
}

/* TABLE REPORT CSS BY CHATGPT */

#rptBody {
  background: #f5f6f8;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

/* TEACHER CARD */
.rpt-teacher {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 6px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  overflow: hidden;
}

/* TEACHER NAME HEADER */
.rpt-teacher-name {
  background: #2f3e4e;
  color: #fff;
  font-weight: 600;
  padding: 8px 12px;
  font-size: 15px;
  letter-spacing: .2px;
}

/* TABLE */
.rpt-table {
  width: 100%;
  border-collapse: collapse;
}

.rpt-table thead {
  background: #eef1f4;
}

.rpt-table th {
  text-align: left;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid #dcdcdc;
  color: #333;
  font-size: 13px;
}

.rpt-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #ececec;
  vertical-align: middle;
}

/* ZEBRA ROWS */
.rpt-table tbody tr:nth-child(even) {
  background: #fafafa;
}

/* STATUS SYMBOL COLUMN */
.rpt-sym {
  width: 36px;
  text-align: center;
  font-weight: bold;
  font-size: 16px;
}

/* STATUS COLORS */
.rpt-green {
  color: #1a7f37;
}

.rpt-red {
  color: #c62828;
}

.rpt-neutral {
  color: #888;
}

/* TIME COLUMN */
.rpt-table td:nth-child(2) {
  font-family: monospace;
  font-size: 13px;
  color: #444;
}

/* SUBJECT */
.rpt-table td:nth-child(3) {
  font-weight: 500;
}

/* CLASS */
.rpt-table td:nth-child(4) {
  color: #555;
}

/* PAGE BREAKS */
.page-break-line {
  position: absolute;
  z-index: 80;
  cursor: ew-resize;
  background-image: linear-gradient(to bottom, transparent 30%, #555 30%);
  background-size: 2px 14px;
  background-position: center;
  background-repeat: repeat-y;
  background-color: rgba(220, 220, 220, 0.4);
  transition: background-color 0.2s, border 0.2s;
  border-left: 2px dashed #999;
  border-right: 2px dashed #999;
  transform: translateX(-10px);
  /* center over the gap */
}

.page-break-line:hover {
  background-color: rgba(200, 200, 200, 0.6);
}

.page-break-line.dragging {
  background-color: rgba(74, 144, 217, 0.5);
  border-left: 2px solid #4a90d9;
  border-right: 2px solid #4a90d9;
}
