/* ================= BODY & SKY ================= */
body {
  font-family: Arial, sans-serif;
  overflow-x: hidden;
  position: relative;
  background: var(--sky-gradient, linear-gradient(to bottom, #87ceeb, #f0f8ff));
  transition: background 1s linear;
}

h2 {
  text-align: center;
  margin-bottom: 15px;
}

.table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 80vh;
  -webkit-overflow-scrolling: touch;
}

table {
  table-layout: fixed;
  width: 90%;
  margin: 0 auto;
  border-collapse: collapse;
  color: #000;
  font-family: Arial, sans-serif;
  background-color: #f3edb0;
  backdrop-filter: blur(4px);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

th, td {
  padding: 12px 10px;
  font-size: 12px;
  border: 1px solid #000080;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 150px;
}

/* ===== SPLIT CELL STYLES ===== */
.split-cell {
  padding: 0 !important;
  vertical-align: top;
}

.split-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 60px;
}

.sub-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid #000080;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 30px;
}

.sub-cell:last-child {
  border-bottom: none;
}

.sub-cell:hover {
  transform: scale(1.02);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.subject-code {
  font-weight: bold;
  font-size: 11px;
  margin-bottom: 2px;
}

.section-info {
  font-size: 10px;
  color: #333;
}

/* Status colors for sub-cells */
.sub-cell.status-green {
  background-color: #0cde3d !important;
}

.sub-cell.status-red {
  background-color: #e20c0c !important;
}

.sub-cell.status-gray {
  background-color: #adb6c6 !important;
}

/* ===== WEEK HEADER ===== */
.week-header {
  background-color: #f0f0f0;
  cursor: pointer;
  user-select: none;
  font-weight: bold;
}

.week-header:hover {
  background-color: #e0e0e0;
}

.week-header td {
  background-color: transparent;
  font-weight: bold;
  font-size: 16px;
  padding: 8px;
  border: none !important;
}

.week-header td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.week-header .arrow {
  display: inline-block;
  transition: transform 0.25s ease;
  color: black;
  font-size: 16px;
}

.week-header.open .arrow {
  transform: rotate(180deg);
}

.day-row.collapsed {
  display: none;
}

/* ===== STICKY HEADERS ===== */
thead th {
  position: sticky;
  top: 0;
  background-color: #99ccff;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.day-row td:nth-child(2),
thead th:nth-child(2) {
  position: sticky;
  left: 80px;
  background-color: #99ccff;
  font-weight: bold;
  z-index: 4;
}

.day-row:hover { 
  background-color: #e6f2ff; 
  transition: background 0.2s ease-in-out; 
}

/* --- Popup and Overlay Styles --- */
.overlay {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.4);
}

.popup {
  display: none;
  position: fixed;
  z-index: 1001;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 500px;
  padding: 20px;
  background-color: #fefefe;
  border: 1px solid #888;
  border-radius: 8px;
  box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}

.popup h3 {
  margin-top: 0;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

#popup-close {
  background-color: #e74c3c;
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 5px;
  cursor: pointer;
  float: right;
  font-size: 16px;
  margin-top: 10px;
}

#popup-close:hover {
  background-color: #c0392b;
}

#popup-edit-btn {
  background-color: #f39c12;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  width: 100%;
  margin-top: 10px;
}

#popup-edit-btn:hover {
  background-color: #e67e22;
}

/* --- Status Indicator Styles --- */
td.status-green {
  background-color: #0cde3d !important;
  border-color: #c3e6cb !important;
}

td.status-red {
  background-color: #e20c0c !important;
  border-color: #f5c6cb !important;
}

td.status-gray {
  background-color: #adb6c6 !important;
  border-color: #d6d8db !important;
}

.status-button-container {
  display: flex;
  justify-content: space-around;
  margin-bottom: 20px;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  background-color: #f9f9f9;
}

.status-btn {
  flex-grow: 1;
  margin: 0 5px;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}

.status-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.status-btn[data-status="green"] { background-color: #28a745; }
.status-btn[data-status="red"] { background-color: #dc3545; }
.status-btn[data-status="gray"] { background-color: #6c757d; }

.status-btn.active {
  border-color: #333;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
  transform: translateY(0);
}

#class-details-form .form-group {
  margin-bottom: 15px;
}

#class-details-form label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
}

#class-details-form textarea {
  width: 100%;
  padding: 8px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
}

#class-details-form button[type="submit"] {
  background-color: #2ecc71;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  width: 100%;
}

#class-details-form button[type="submit"]:hover {
  background-color: #27ae60;
}

.section-edit-btn {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  margin-top: 10px;
}

.section-edit-btn:hover {
  background-color: #2980b9;
}

/* ========================================= WEEK COLORING ================================================*/

.week-15 td:not(.split-cell), 
.week-14 td:not(.split-cell), 
.week-13 td:not(.split-cell),
.week-12 td:not(.split-cell), 
.week-11 td:not(.split-cell),
.week-10 td:not(.split-cell), 
.week-9 td:not(.split-cell),
.week-8 td:not(.split-cell), 
.week-7 td:not(.split-cell), 
.week-6 td:not(.split-cell), 
.week-5 td:not(.split-cell), 
.week-4 td:not(.split-cell), 
.week-3 td:not(.split-cell), 
.week-2 td:not(.split-cell),
.week-1 td:not(.split-cell) { 
  background-color: #352e2c;
  color: #000; 
}
/*
.week-1 td:not(.split-cell) {
  background-color: #3ee60b;
  color: #000;
}
*/
.week-15 td.split-cell, 
.week-14 td.split-cell,
.week-13 td.split-cell,
.week-12 td.split-cell, 
.week-11 td.split-cell,
.week-10 td.split-cell, 
.week-9 td.split-cell, 
.week-8 td.split-cell, 
.week-7 td.split-cell, 
.week-6 td.split-cell, 
.week-5 td.split-cell, 
.week-4 td.split-cell, 
.week-3 td.split-cell, 
.week-2 td.split-cell,
.week-1 td:not(.split-cell)  {
  background-color: #eb440d; 
}

.week-1 td.split-cell {
  background-color: #3ee60b;
}

.week-15 .sub-cell.status-green, 
.week-14 .sub-cell.status-green, 
.week-13 .sub-cell.status-green,
.week-12 .sub-cell.status-green,
.week-11 .sub-cell.status-green,
.week-10 .sub-cell.status-green,
.week-9 .sub-cell.status-green,
.week-8 .sub-cell.status-green,
.week-7 .sub-cell.status-green,
.week-6 .sub-cell.status-green,
.week-5 .sub-cell.status-green,
.week-4 .sub-cell.status-green,
.week-3 .sub-cell.status-green,
.week-2 .sub-cell.status-green,
.week-1 .sub-cell.status-green {
  background-color: #0cde3d !important;
}

.week-15 .sub-cell.status-red, 
.week-14 .sub-cell.status-red, 
.week-13 .sub-cell.status-red,
.week-12 .sub-cell.status-red,
.week-11 .sub-cell.status-red,
.week-10 .sub-cell.status-red,
.week-9 .sub-cell.status-red,
.week-8 .sub-cell.status-red,
.week-7 .sub-cell.status-red,
.week-6 .sub-cell.status-red,
.week-5 .sub-cell.status-red,
.week-4 .sub-cell.status-red,
.week-3 .sub-cell.status-red,
.week-2 .sub-cell.status-red,
.week-1 .sub-cell.status-red {
  background-color: #e20c0c !important; 
}

.week-15 .sub-cell.status-gray, 
.week-14 .sub-cell.status-gray, 
.week-13 .sub-cell.status-gray,
.week-12 .sub-cell.status-gray,
.week-11 .sub-cell.status-gray,
.week-10 .sub-cell.status-gray,
.week-9 .sub-cell.status-gray,
.week-8 .sub-cell.status-gray,
.week-7 .sub-cell.status-gray,
.week-6 .sub-cell.status-gray,
.week-5 .sub-cell.status-gray,
.week-4 .sub-cell.status-gray,
.week-3 .sub-cell.status-gray,
.week-2 .sub-cell.status-gray,
.week-1 .sub-cell.status-gray {
  background-color: #7e8796 !important; 
}

/* ========================================= WEEK COLORING ================================================*/

@media screen and (max-width: 768px) {
  table { min-width: 750px; }
  th, td { padding: 8px 10px; font-size: 12px; max-width: 120px; }
  .week-header td { font-size: 14px; }
}