
html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', Arial, sans-serif;
  background: #f6f8fb;
  overflow-x: hidden;
  overflow-y: auto; /* allow full-page scroll on small screens */
}

/* Dark theme overrides (toggled by JS adding `body.dark`) */
body.dark {
  background: #0f1418;
  color: #e6eef8;
}
body.dark .top-bar { background: rgba(18,22,26,0.95); box-shadow: 0 8px 30px rgba(0,0,0,0.6); }
body.dark .sidebar { background: linear-gradient(135deg, #1e2328 80%, #161a1f 100%); color: #e8eef5; box-shadow: 2px 0 10px rgba(0,0,0,0.4); }
body.dark .content-area { background: #0d1014; }
body.dark .filters-card, body.dark .upload-card, body.dark .timetable-preview { background: #1e2328; border-color: #2f353d; color: #e8eef5; }
body.dark .sidebar-title { color: #6ba5ff; }
body.dark .sidebar-desc { color: #9eaec0; }
body.dark .sidebar-desc li { color: #9eaec0; }
body.dark .dropdown-row label { color: #c5d0e0; font-weight: 500; }
body.dark select { background: #2a3038; color: #e8eef5; border-color: #3f4650; }
body.dark select option { background: #2a3038; color: #e8eef5; }
body.dark .file-feedback { color: #6ba5ff; }
body.dark .file-success { color: #7eb8ff; }
body.dark .file-success-name { color: #9eaec0; }
body.dark .empty-main { color: #8b99ad; }
body.dark .upload-label, body.dark .primary-download, body.dark button { background: #174bbd; color: #fff; }
body.dark .upload-label:hover, body.dark .primary-download:hover, body.dark button:hover { background: #2563eb; }

/* Top fixed bar */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247,248,250,0.98);
  box-shadow: 0 8px 30px rgba(22,38,78,0.08);
  z-index: 9999;
  pointer-events: auto;
}
.top-bar .content-title { text-align: center; }
.top-bar .main-title { font-size: 2.8rem; color: #2563eb; margin: 0; font-weight: 800; }
.top-bar .tagline { color: #6f88b6; margin-top: 6px; font-weight: 500; }
.top-bar .dark-toggle-row { position: absolute; right: 24px; }

/* Main two-column layout */
.main-flex {
  display: flex;
  gap: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  box-sizing: border-box;
}

/* Left sidebar (above top-bar) */
.sidebar {
  flex: 0 0 340px;
  background: linear-gradient(135deg, #fff 80%, #f7f8fa 100%);
  padding: 120px 16px 16px 16px;
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 10000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: flex-basis 0.2s ease, padding 0.2s ease;
}
.sidebar > * { width: 100%; }
.sidebar-title { font-size: 1.15rem; color: #2563eb; font-weight: 700; margin: 0 0 8px 0; text-align: center; }
.sidebar-desc {
  color: #4f6fa6;
  margin: 0 0 8px 0;
  padding: 0;
  list-style-position: inside;
  text-align: center;
}

/* Right content area */
.content-area {
  flex: 1 1 0%;
  min-width: 0;
  margin-left: 340px;
  padding: 136px 24px 24px 24px;
  box-sizing: border-box;
  overflow-y: auto;
}

/* Timetable placeholder and preview */
.timetable-placeholder {
  color: #7a8bb7;
  font-size: 1.15rem;
  text-align: center;
  padding: 80px 0;
  min-height: 300px;
}
.timetable-preview {
  padding: 18px;
  display: none;
}

/* Timetable cell spacing: add consistent padding and readable line-height without changing layout */
#timetable table td {
  padding: 8px 10px;
  vertical-align: top;
  line-height: 1.35;
}

#timetable table td > * {
  display: block;
  margin: 2px 0;
}

/* Controls and cards */
.filters-card, .upload-card {
  background: #fff;
  border: 1.5px solid #e9eef8;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 6px 20px rgba(22,38,78,0.03);
}
.filters-card { max-width: 520px; margin: 0 auto; }
.upload-card { align-items: center; max-width: 280px; display: flex; flex-direction: column; }

.filters-label { font-size: 1.02rem; color: #2563eb; font-weight: 600; margin-bottom: 8px; }
.filters-divider { height: 1.5px; background: #eaeef6; margin: 12px 0; }

#selectors { 
  width: 100%; 
  max-width: 280px; 
  margin: 0 auto;
  box-sizing: border-box;
}

.dropdown-row { 
  display: flex; 
  flex-direction: column;
  gap: 16px; 
  align-items: stretch; 
}
.dropdown-row label { font-size: 1.02rem; color: #222; font-weight: 500; }
.dropdown-row select { 
  padding: 8px 14px; 
  border-radius: 8px; 
  border: 1.5px solid #d1d5db; 
  background: #f8fafc;
  width: 100%;
  box-sizing: border-box;
}

.upload-label {
  display: block;
  background: #2563eb;
  color: #fff;
  border-radius: 10px;
  padding: 14px 18px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: center;
  box-sizing: border-box;
}
.upload-label:hover { background: #174bbd; }

.primary-download {
  font-size: 1.12rem;
  font-weight: 700;
  padding: 14px 0;
  background: #183a6d;
  color: #fff;
  border-radius: 10px;
  width: 100%;
}

/* Small controls */
.dark-toggle-row { display: flex; align-items: center; gap: 8px; }
.switch { position: relative; display: inline-block; width: 54px; height: 30px; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: #e9eef8; border-radius: 30px; }
.slider:before { content: ""; position: absolute; left: 4px; top: 3px; width: 24px; height: 24px; background: #fff; border-radius: 50%; }
.switch input:checked + .slider { background: #2563eb; }
.switch input:checked + .slider:before { transform: translateX(24px); }

/* Utility */
.empty-illustration { font-size: 3.2rem; margin-bottom: 8px; }
.empty-main { font-size: 1.15rem; color: #4f6fa6; }
.file-feedback { font-size: 0.98rem; color: #2563eb; margin-top: 12px; word-wrap: break-word; overflow-wrap: break-word; }
.file-success { display: block; }
.file-success-name { display: block; font-size: 0.85rem; margin-top: 4px; }
.file-success-time { font-size: 0.85rem; }

/* Responsive adjustments */
@media (min-width: 1201px) {
  .sidebar {
    padding-top: 120px;
  }
}

@media (min-width: 901px) and (max-width: 1200px) {
  .sidebar { 
    flex: 0 0 300px;
    width: 300px;
  }
  .content-area { margin-left: 300px; }
}

@media (max-width: 1024px) {
  .top-bar { height: 104px; padding: 10px 16px; }
  .top-bar .main-title { font-size: 2.4rem; }
  .top-bar .tagline { font-size: 0.95rem; }
  .content-area { padding-top: 128px; }
}

@media (max-width: 900px) {
  .main-flex { flex-direction: column; padding: 130px 14px 18px; }
  .sidebar {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    height: auto;
    z-index: 10;
    flex: 1 1 auto;
    padding: 24px 16px 20px;
    max-width: 100%;
    width: 100%;
    overflow-y: visible;
  }
  .content-area { 
    margin-left: 0;
    padding-top: 136px; 
  }
  .top-bar { height: 118px; }
}

@media (max-width: 720px) {
  .top-bar { height: 110px; padding: 12px; }
  .top-bar .main-title { font-size: 2.1rem; }
  .top-bar .tagline { font-size: 0.9rem; }
  .sidebar { gap: 16px; }
  .dropdown-row { gap: 12px; }
  .dropdown-row label { width: 100%; font-size: 0.98rem; }
  .dropdown-row select { width: 100%; }
  .primary-download { width: 100%; }
}

@media (max-width: 540px) {
  .top-bar { 
    height: auto; 
    padding: 14px 12px 14px;
    flex-direction: column;
  }
  .top-bar .content-title { width: 100%; }
  .top-bar .main-title { font-size: 1.8rem; }
  .tagline { font-size: 0.9rem; margin-bottom: 0; }
  .top-bar .dark-toggle-row { 
    position: static;
    right: auto;
    margin-top: 12px;
    justify-content: center;
  }
  .main-flex { padding: 150px 10px 16px; }
  .content-area { 
    margin-left: 0;
    padding: 12px; 
    padding-top: 150px; 
  }
  .sidebar { padding: 20px 14px; }
  .upload-label { width: 100%; text-align: center; }
  .upload-card { max-width: 100%; }
  .dropdown-row { flex-direction: column; align-items: stretch; }
  .filters-card { padding: 16px; }
  .upload-card { padding: 16px; }
  #timetable table { font-size: 0.95rem; }
  #timetable tbody td { padding: 6px; }
  #exportToolbar { margin-top: 8px; }
}

@media (max-width: 400px) {
  .main-flex { gap: 12px; }
  .sidebar-title { font-size: 1rem; }
  .upload-label { font-size: 0.98rem; padding: 12px 16px; }
  .primary-download { font-size: 1rem; padding: 12px; position: sticky; bottom: 0; left: 0; right: 0; border-radius: 0 0 12px 12px; }
  .content-area { padding-top: 120px; }
}

/* Timetable area with improved typography and spacing */
#timetable { overflow-x: auto; }
#timetable table { width: 100%; border-collapse: collapse; }

/* Tighter cell spacing for better readability */
#timetable tbody td {
  line-height: 1.2;
  padding: 6px 8px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.06);
}

/* Day headers with breathing room */
#timetable thead th {
  padding: 10px 0;
}

/* Meta information styling (instructors, rooms) */
.slot-meta {
  font-size: 12px;
  opacity: 0.8;
  display: block;
  margin-top: 2px;
}
