/* ============================================================
   schedule.css – Schedule tile v3.2
   ============================================================ */

/* Tile Container Override */
.tile-schedule {
  padding: 0; /* Remove default padding to allow edge-to-edge layout */
  max-height: none; 
  align-self: start;
  flex-direction: row;
}

.sch-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.sch-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* ============================================================
   Schedule Header
   ============================================================ */
.sch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--tile-padding);
  padding-bottom: 0.25rem;
  flex-shrink: 0;
}

.sch-header-title {
  font-size: var(--qa-header-size); /* 15px */
  color: var(--color-secondary);
  font-weight: 500;
}

.sch-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  border: 1px solid var(--tile-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-secondary);
  font-family: var(--font-family);
  font-size: var(--qa-header-size);
  cursor: pointer;
  transition: background 150ms ease;
}
.sch-header-btn:hover { background: rgba(255, 255, 255, 0.1); }
.sch-header-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.sch-header-btn svg { width: 0.875rem; height: 0.875rem; }

/* Merge hint */
.sch-merge-hint {
  text-align: center;
  font-size: 0.875rem;
  color: #3b82f6;
  margin-bottom: 0.5rem;
  display: none;
}
.sch-merge-hint.active { display: block; }
.sch-merge-cancel {
  background: none; border: none;
  color: var(--color-secondary);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
  margin-left: 0.5rem;
}

/* ============================================================
   Timetable Grid
   ============================================================ */
.sch-timetable-wrapper {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: visible;
  padding: 0 var(--tile-padding) var(--tile-padding) var(--tile-padding);
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.sch-timetable-wrapper::-webkit-scrollbar { height: 6px; width: 6px; }
.sch-timetable-wrapper::-webkit-scrollbar-track { background: transparent; }
.sch-timetable-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.sch-timetable-wrapper--empty-state .sch-timetable {
  filter: blur(8px);
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

.sch-empty-message {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 1rem;
  color: var(--color-primary);
  font-weight: 500;
  line-height: 1.5;
  pointer-events: none;
  z-index: 20;
}

.sch-timetable {
  display: grid;
  gap: 0.5rem;
  min-width: max-content;
  padding-bottom: 0.25rem;
}

/* ============================================================
   Grid Cells
   ============================================================ */
.sch-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 3rem; /* 48px */
}

/* Day Label Column (Sticky) */
.sch-cell--day {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--tile-bg); /* ensure it matches glass background */
  backdrop-filter: var(--tile-blur);
  -webkit-backdrop-filter: var(--tile-blur);
  font-size: 1rem;
  color: var(--color-primary);
  font-weight: 500;
  align-items: center;
  /* Add subtle shadow to the right when scrolled, if needed. For now, a subtle right border */
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sch-cell--top-left {
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Header Row Cells */
.sch-cell--header {
  min-height: 1.75rem;
  align-items: center;
  color: var(--color-secondary);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
}

.sch-grid--edit .sch-cell--header:not(.sch-cell--day) {
  cursor: pointer;
  border-radius: 0.5rem;
  transition: background 150ms ease;
}
.sch-grid--edit .sch-cell--header:not(.sch-cell--day):hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Add period button in header */
.sch-header-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  color: #3b82f6;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 0.5rem;
  border: 1px dashed rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.05);
}
.sch-header-add:hover {
  background: rgba(59, 130, 246, 0.1);
}

/* Header Delete Action */
.sch-header-actions {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.sch-grid--edit .sch-cell--header:hover .sch-header-actions {
  opacity: 1;
  pointer-events: auto;
}
.sch-header-btn-del {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.sch-header-btn-del svg { width: 0.75rem; height: 0.75rem; }
.sch-header-btn-del[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(239, 68, 68, 0.5);
}

/* Empty Cell */
.sch-cell--empty {
  border-radius: 0.875rem;
  align-items: center;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}
.sch-grid--edit .sch-cell--empty {
  border: 1px dashed rgba(255,255,255,0.1);
  color: #6b7280;
  cursor: pointer;
}
.sch-grid--edit .sch-cell--empty:hover {
  color: #9ca3af;
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.03);
}
.sch-empty-plus { font-size: 1.25rem; line-height: 1; font-weight: 300; }
.sch-empty-label { font-size: 0.75rem; margin-top: 0.125rem; }

/* Filled Block */
.sch-block {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 0.875rem;
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  user-select: none;
  transition: background 150ms ease, box-shadow 150ms ease;
}
.sch-block:hover {
  background: rgba(255, 255, 255, 0.07);
}

.sch-block-label {
  font-size: 1rem; /* 16px */
  color: var(--color-primary);
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}
.sch-block-desc {
  font-size: 0.8125rem; /* 13px */
  color: rgba(255, 255, 255, 0.7);
  font-weight: 400;
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}
.sch-block-time {
  font-size: 0.75rem;
  color: var(--color-secondary);
  font-variant-numeric: tabular-nums;
  margin-top: 0.125rem;
}

/* Block Actions */
.sch-block-actions {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
.sch-grid--edit .sch-block:hover .sch-block-actions {
  opacity: 1;
  pointer-events: auto;
}
.sch-grid--drag-active .sch-block-actions,
.sch-grid--merge-active .sch-block-actions {
  display: none !important;
}

.sch-block-btn {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 100ms ease, background 150ms ease;
  padding: 0;
}
.sch-block-btn:hover { transform: scale(1.1); }
.sch-block-btn svg { width: 0.875rem; height: 0.875rem; }

.sch-block-btn--edit { background: rgba(255, 255, 255, 0.15); color: #e5e7eb; }
.sch-block-btn--delete { background: #ef4444; color: white; }
.sch-block-btn--merge { background: #3b82f6; color: white; }

/* Merge Mode */
.sch-cell--merge-row {
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.05);
}
.sch-cell--merge-row:hover {
  background: rgba(59, 130, 246, 0.1);
  cursor: pointer;
}
.sch-block--merge-anchor {
  box-shadow: 0 0 0 2px #3b82f6, 0 0 1rem rgba(59, 130, 246, 0.2) !important;
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: rgba(59, 130, 246, 0.5) !important;
}
.sch-block--merge-flash {
  animation: sch-merge-pulse 400ms ease-out;
}
@keyframes sch-merge-pulse {
  0% { box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.5); background: rgba(59, 130, 246, 0.3); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); background: rgba(255, 255, 255, 0.05); }
}

/* Drag & Drop */
.sch-grid--edit .sch-block[data-draggable="true"] {
  cursor: grab;
}
.sch-grid--edit .sch-block[data-draggable="true"]:active {
  cursor: grabbing;
}
.sch-block--dragging {
  z-index: 100 !important;
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.45);
  opacity: 0.95;
  pointer-events: none;
}
.sch-cell--drop-target {
  outline: 2px solid var(--color-accent);
  outline-offset: -2px;
}
