/* /tools/utilities/timetable-maker/assets/css/timetable-maker.css */

/* Tool Title and Subtitle */
.tool-header {
  margin: 28px 0 20px;
}

.tool-title {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 950;
  color: var(--text);
  margin: 0 0 8px;
}

.tool-subtitle {
  font-size: 1.05rem;
  color: var(--muted-strong);
  line-height: 1.5;
  margin: 0;
  max-width: 780px;
}

/* Tool Sections */
.tool-section {
  background: var(--surface, #ffffff);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
  padding: 24px;
  margin-bottom: 24px;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group label {
  font-size: 0.88rem;
  font-weight: 850;
  color: var(--text);
}

.setting-group select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line, #dfe5ef);
  background: var(--surface, #ffffff);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  outline: none;
}

.setting-group select:focus-visible {
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  padding-top: 18px;
}

/* Mobile Day Tabs */
.mobile-day-tabs {
  display: none;
  gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.day-tab {
  flex: 1 1 auto;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line, #dfe5ef);
  background: #ffffff;
  color: var(--muted-strong);
  font-weight: 800;
  font-size: 0.88rem;
  cursor: pointer;
  text-align: center;
  transition: all 160ms ease;
}

.day-tab:hover {
  background: #f8fafc;
}

.day-tab.active {
  background: var(--accent, #2563eb);
  color: #ffffff;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.18);
}

/* Timetable Grid */
.table-container {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--line, #dfe5ef);
}

#timetableGrid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  background: #ffffff;
}

#timetableGrid th,
#timetableGrid td {
  border: 1px solid var(--line, #dfe5ef);
  padding: 0;
  position: relative;
}

#timetableGrid th {
  background: #f8fafc;
  color: var(--text);
  font-weight: 850;
  font-size: 0.88rem;
  padding: 12px 6px;
  text-align: center;
}

#timetableGrid th.time-col-header {
  width: 90px;
  background: #f1f5f9;
  font-weight: 900;
}

/* Time Column cells */
.time-cell-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 14px 6px;
  height: 90px;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--muted-strong);
  background: #f8fafc;
  line-height: 1.35;
}

.time-cell-inner .time-label {
  font-weight: 900;
  color: var(--text);
  margin-bottom: 2px;
}

/* Day grid cells */
.grid-cell {
  height: 90px;
  cursor: pointer;
  transition: background-color 120ms ease;
  vertical-align: top;
}

.grid-cell:hover {
  background-color: #f8fbff;
}

/* Empty cell Hover prompt */
.grid-cell::after {
  content: "+";
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--accent, #2563eb);
  font-size: 1.8rem;
  font-weight: 300;
  opacity: 0;
  transition: opacity 120ms ease;
}

.grid-cell:hover::after {
  opacity: 0.35;
}

.grid-cell.occupied:hover::after {
  display: none !important;
}

/* Class Slot Card Layout */
.class-slot {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 8px 10px;
  font-size: 0.78rem;
  line-height: 1.35;
  border-radius: 0; /* Align flat inside cells */
  box-shadow: inset 4px 0 0 var(--border-color);
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: transform 150ms ease, box-shadow 150ms ease;
  overflow: hidden;
}

.class-slot:hover {
  transform: scale(0.98);
  box-shadow: inset 4px 0 0 var(--border-color), 0 4px 12px rgba(15, 23, 42, 0.06);
}

.slot-header {
  font-weight: 900;
  font-size: 0.84rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  margin-bottom: 2px;
}

.slot-meta {
  font-weight: 750;
  opacity: 0.85;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.slot-meta svg {
  width: 10px;
  height: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  margin-right: 3px;
  vertical-align: middle;
}

.slot-notes {
  font-size: 0.72rem;
  margin-top: 4px;
  opacity: 0.78;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  border-top: 1px dashed rgba(15, 23, 42, 0.08);
  padding-top: 3px;
}

/* Colors palette styles */
.color-blue {
  --bg-color: #f0f4ff;
  --border-color: #3b82f6;
  --text-color: #1e3a8a;
}
.color-green {
  --bg-color: #ecfdf5;
  --border-color: #10b981;
  --text-color: #065f46;
}
.color-amber {
  --bg-color: #fffbeb;
  --border-color: #f59e0b;
  --text-color: #78350f;
}
.color-rose {
  --bg-color: #fff1f2;
  --border-color: #f43f5e;
  --text-color: #9f1239;
}
.color-purple {
  --bg-color: #faf5ff;
  --border-color: #a855f7;
  --text-color: #581c87;
}
.color-orange {
  --bg-color: #fff7ed;
  --border-color: #f97316;
  --text-color: #7c2d12;
}

/* Modal dialog custom styling */
.slot-modal {
  border: none;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
  width: min(440px, calc(100vw - 32px));
  padding: 24px;
  background: #ffffff;
  outline: none;
}

.slot-modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal-form h2 {
  font-size: 1.3rem;
  font-weight: 900;
  margin: 0 0 16px;
  color: var(--text);
}

/* Form Styles */
.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 850;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group textarea {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line, #dfe5ef);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 150ms ease;
  width: 100%;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent, #2563eb);
}

/* Color Swatches Grid */
.color-palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.color-swatch-label {
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
}

.color-swatch-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.swatch-preview {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background-color: var(--bg-color);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 2px var(--border-color);
  transition: transform 100ms ease;
}

.color-swatch-label input:checked + .swatch-preview {
  transform: scale(0.85);
  border-color: #0f172a;
}

/* Modal Actions */
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.modal-actions-right {
  display: flex;
  gap: 8px;
}

.btn-danger {
  background: #ef4444;
  color: #ffffff;
  border: none;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.color-neutral, .color-gray {
  --bg-color: #f1f5f9;
  --border-color: #94a3b8;
  --text-color: #334155;
}

/* Dashboard Panel Layout */
.dashboard-panel {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .dashboard-panel {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Weekly Summary */
.summary-card h2 {
  font-size: 1.1rem;
  font-weight: 850;
  margin: 0 0 16px;
  color: var(--text);
}

.summary-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface, #ffffff);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 8px;
  padding: 12px 6px;
  text-align: center;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.metric-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.metric-item strong {
  font-size: 1.5rem;
  font-weight: 950;
  color: var(--accent, #2563eb);
  line-height: 1.2;
}

.metric-item span {
  font-size: 0.72rem;
  font-weight: 750;
  color: var(--muted-strong);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Color Legend */
.legend-card h2 {
  font-size: 1.1rem;
  font-weight: 850;
  margin: 0 0 16px;
  color: var(--text);
}

.legend-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 480px) {
  .legend-items {
    grid-template-columns: repeat(2, 1fr);
  }
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.legend-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.swatch-blue { background-color: #3b82f6; }
.swatch-green { background-color: #10b981; }
.swatch-amber { background-color: #f59e0b; }
.swatch-rose { background-color: #f43f5e; }
.swatch-purple { background-color: #a855f7; }
.swatch-orange { background-color: #f97316; }
.swatch-neutral, .swatch-gray { background-color: #94a3b8; }

/* Empty State Banner */
.empty-state-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 24px;
  transition: opacity 150ms ease, transform 150ms ease;
}

.empty-state-banner.hidden {
  display: none !important;
}

.empty-state-banner .banner-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.empty-state-banner .banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.88rem;
  color: #14532d;
  line-height: 1.4;
}

.empty-state-banner .banner-text strong {
  font-weight: 850;
}

.empty-state-banner .banner-text span {
  font-weight: 600;
  opacity: 0.9;
}

/* FAQ spacing */
.faq-section {
  margin-top: 32px;
}

/* Responsive Table Mobile Logic */
@media (max-width: 768px) {
  .settings-actions {
    justify-content: stretch;
  }
  
  .settings-actions button {
    flex: 1 1 50%;
  }

  .mobile-day-tabs {
    display: flex;
  }

  /* Hide all day columns except the active class matching the grid show class */
  #timetableGrid.show-Mon th.col-header:not(.col-time):not(.col-Mon),
  #timetableGrid.show-Mon td.col-cell:not(.col-time):not(.col-Mon) {
    display: none !important;
  }
  #timetableGrid.show-Tue th.col-header:not(.col-time):not(.col-Tue),
  #timetableGrid.show-Tue td.col-cell:not(.col-time):not(.col-Tue) {
    display: none !important;
  }
  #timetableGrid.show-Wed th.col-header:not(.col-time):not(.col-Wed),
  #timetableGrid.show-Wed td.col-cell:not(.col-time):not(.col-Wed) {
    display: none !important;
  }
  #timetableGrid.show-Thu th.col-header:not(.col-time):not(.col-Thu),
  #timetableGrid.show-Thu td.col-cell:not(.col-time):not(.col-Thu) {
    display: none !important;
  }
  #timetableGrid.show-Fri th.col-header:not(.col-time):not(.col-Fri),
  #timetableGrid.show-Fri td.col-cell:not(.col-time):not(.col-Fri) {
    display: none !important;
  }
  #timetableGrid.show-Sat th.col-header:not(.col-time):not(.col-Sat),
  #timetableGrid.show-Sat td.col-cell:not(.col-time):not(.col-Sat) {
    display: none !important;
  }
  #timetableGrid.show-Sun th.col-header:not(.col-time):not(.col-Sun),
  #timetableGrid.show-Sun td.col-cell:not(.col-time):not(.col-Sun) {
    display: none !important;
  }

  /* Stretch time col header slightly on mobile */
  #timetableGrid th.time-col-header {
    width: 76px;
    padding-inline: 4px;
  }

  .time-cell-inner {
    height: 84px;
    padding: 10px 4px;
  }

  .grid-cell {
    height: 84px;
  }
}

/* ----------------------------------------------------------------------
   Print-Ready Layout Styles
   ---------------------------------------------------------------------- */
@media print {
  /* Hide unnecessary elements completely */
  header,
  footer,
  #site-header,
  #site-footer,
  .topnav,
  .site-footer,
  .settings-section,
  .mobile-day-tabs,
  .faq-section,
  .slot-modal,
  .cookie-notice,
  dialog,
  button,
  .btn,
  .dashboard-panel,
  .empty-state-banner {
    display: none !important;
    visibility: hidden !important;
  }

  /* Reset layout structure */
  body, html {
    background: #ffffff !important;
    color: #000000 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .site-container,
  #mainContainer {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
  }

  .tool-header {
    margin: 0 0 14px 0 !important;
    text-align: center;
  }

  .tool-title {
    font-size: 1.8rem !important;
    color: #000000 !important;
  }

  .tool-subtitle {
    font-size: 0.88rem !important;
    color: #4b5563 !important;
  }

  /* Ensure the grid table is fully visible */
  .timetable-grid-section {
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
  }

  .table-container {
    border: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
  }

  #timetableGrid {
    table-layout: fixed !important;
    width: 100% !important;
    border-collapse: collapse !important;
    border: 1px solid #1f2937 !important;
  }

  /* Ensure all columns display in print, overriding mobile hides */
  #timetableGrid th.col-header,
  #timetableGrid td.col-cell {
    display: table-cell !important;
    visibility: visible !important;
    border: 1px solid #4b5563 !important;
    color: #000000 !important;
  }

  #timetableGrid th {
    background: #f3f4f6 !important;
    padding: 8px 4px !important;
  }

  #timetableGrid th.time-col-header {
    width: 76px !important;
    background: #e5e7eb !important;
  }

  .time-cell-inner {
    padding: 4px 2px !important;
    background: #f3f4f6 !important;
  }

  /* Class Slot colors in print - force background coloring */
  .class-slot {
    height: 100% !important;
    box-sizing: border-box !important;
    border-left: 4px solid var(--border-color) !important;
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* ----------------------------------------------------------------------
     1. LANDSCAPE PRINT LAYOUT ADJUSTMENTS
     ---------------------------------------------------------------------- */
  @media (orientation: landscape) {
    @page {
      size: landscape;
      margin: 1.2cm;
    }

    #timetableGrid th {
      font-size: 0.8rem !important;
    }

    .grid-cell,
    .time-cell-inner {
      height: 76px !important;
    }

    .class-slot {
      padding: 5px 8px !important;
    }

    .slot-header {
      font-size: 0.82rem !important;
    }

    .slot-meta {
      font-size: 0.72rem !important;
    }

    .slot-notes {
      font-size: 0.68rem !important;
      margin-top: 3px !important;
      padding-top: 3px !important;
    }
  }

  /* ----------------------------------------------------------------------
     2. PORTRAIT PRINT LAYOUT ADJUSTMENTS
     ---------------------------------------------------------------------- */
  @media (orientation: portrait) {
    @page {
      size: portrait;
      margin: 1cm;
    }

    #timetableGrid th {
      font-size: 0.7rem !important;
    }

    .grid-cell,
    .time-cell-inner {
      height: 60px !important;
    }

    .class-slot {
      padding: 3px 5px !important;
      border-left-width: 3px !important;
    }

    .slot-header {
      font-size: 0.72rem !important;
      font-weight: 900 !important;
    }

    .slot-meta {
      font-size: 0.62rem !important;
    }

    .slot-notes {
      font-size: 0.58rem !important;
      margin-top: 1px !important;
      padding-top: 1px !important;
    }
  }
}

/* HTML2Canvas capture styles override for mobile */
body.html2canvas-capture #timetableGrid th.col-header,
body.html2canvas-capture #timetableGrid td.col-cell {
  display: table-cell !important;
  visibility: visible !important;
}
