@import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

body {
  font-family: 'Sarabun', 'TH Sarabun New', 'TH Sarabun PSK', 'Angsana New', sans-serif;
  font-size: 1.05rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ensure table text in Sarabun is crisp and clear */
table {
  font-size: 1rem;
}

table th {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

/* Table Scroll Container (Enables smooth vertical & horizontal freeze panes) */
.matrix-scroll-container {
  overflow: auto;
  max-height: calc(100vh - 210px);
  min-height: 480px;
  position: relative;
}

/* Base Sticky Header Rule for all table headers (Vertical Freeze Top) */
thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: #f8fafc !important;
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.08);
}

/* Dedicated sticky header styling for Tab 2 (Midterm & Final exam grading) */
#teacher-tab-midterm thead th {
  background-color: #eef2ff !important;
}

/* Sticky Table Columns for Matrix Freeze Panes */
.sticky-col-1 {
  position: sticky;
  left: 0;
  z-index: 10;
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  background-color: #ffffff;
}

.sticky-col-2 {
  position: sticky;
  left: 44px;
  z-index: 10;
  width: 96px;
  min-width: 96px;
  max-width: 96px;
  background-color: #ffffff;
}

.sticky-col-3 {
  position: sticky;
  left: 140px;
  z-index: 10;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  background-color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticky-col-4 {
  position: sticky;
  left: 340px;
  z-index: 10;
  width: 75px;
  min-width: 75px;
  max-width: 75px;
  background-color: #ffffff;
}

.sticky-col-5 {
  position: sticky;
  left: 415px;
  z-index: 15;
  width: 140px;
  min-width: 140px;
  max-width: 140px;
  background-color: #fffbeb !important;
  box-shadow: 4px 0 8px -2px rgba(0, 0, 0, 0.12);
  border-right: 2px solid #f59e0b;
}

/* Header sticky intersection cells (Top-Left Frozen Corner) */
thead .sticky-col-1 {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 30;
  background-color: #f8fafc !important;
}

thead .sticky-col-2 {
  position: sticky;
  top: 0;
  left: 44px;
  z-index: 30;
  background-color: #f8fafc !important;
}

thead .sticky-col-3 {
  position: sticky;
  top: 0;
  left: 140px;
  z-index: 30;
  background-color: #f8fafc !important;
}

thead .sticky-col-4 {
  position: sticky;
  top: 0;
  left: 340px;
  z-index: 30;
  background-color: #f8fafc !important;
}

thead .sticky-col-5 {
  position: sticky;
  top: 0;
  left: 415px;
  z-index: 35;
  background-color: #fef3c7 !important;
}

/* Row Hover for sticky cells */
tr:hover .sticky-col-1,
tr:hover .sticky-col-2,
tr:hover .sticky-col-3,
tr:hover .sticky-col-4 {
  background-color: #f1f5f9 !important;
}

tr:hover .sticky-col-5 {
  background-color: #fde68a !important;
}

/* Mobile Responsive Sticky Freeze Rules */
@media (max-width: 639px) {
  .matrix-scroll-container {
    max-height: calc(100vh - 180px);
    min-height: 380px;
  }

  .sticky-col-1,
  .sticky-col-2,
  .sticky-col-4 {
    position: static !important;
    box-shadow: none !important;
    border-right: none !important;
  }

  .sticky-col-3 {
    position: sticky !important;
    left: 0 !important;
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    z-index: 10 !important;
  }

  .sticky-col-5 {
    position: sticky !important;
    left: 160px !important;
    width: 110px !important;
    min-width: 110px !important;
    max-width: 110px !important;
    z-index: 15 !important;
  }

  thead .sticky-col-3 {
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    z-index: 30 !important;
  }

  thead .sticky-col-5 {
    position: sticky !important;
    top: 0 !important;
    left: 160px !important;
    z-index: 35 !important;
  }
}

/* Smooth Fade In animation */
.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Print Styles for A4 Classroom Report */
@media print {
  header, footer, nav, button, .no-print, .no-print-btn, #teacher-view-container > div:first-child, .flex.border-b {
    display: none !important;
  }
  
  body {
    background: white !important;
    color: black !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 12pt !important;
  }

  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  #teacher-view-container, #teacher-tab-stats {
    display: block !important;
  }

  #report-printable-area, #executive-report-modal-content {
    display: block !important;
  }

  #executive-teacher-report-modal {
    position: static !important;
    background: transparent !important;
    display: block !important;
  }

  #executive-teacher-report-modal > div {
    max-height: none !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .print-container {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }

  table {
    font-size: 11pt !important;
    width: 100% !important;
  }

  th, td {
    padding: 6px 8px !important;
  }

  .char-num-input {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    text-align: center !important;
    padding: 0 !important;
    font-weight: bold !important;
    -moz-appearance: textfield !important;
  }

  .char-num-input::-webkit-outer-spin-button,
  .char-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
  }
}

/* Number input spin button hiding for clean appearance */
.char-num-input::-webkit-outer-spin-button,
.char-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.char-num-input[type=number] {
  -moz-appearance: textfield;
}
