/* ===== layout.css - Main Structure & Page Layouts ===== */

header {
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--table-border);
  background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent);
}

main {
  max-width: 1175px;
  margin: 1.5rem auto;
  padding: 1.25rem;
}

/* Wide schedule matrices (month/year): substitute columns can push the table
   past the centred main column, which used to overflow to the right and look
   off-centre. Fix it without widening the table:
   - .month-grid breaks out to the full viewport width so centring is measured
     against the viewport, not the 1175px main column.
   - safe center: the table is centred when it fits the viewport, but aligns to
     the start (left-aligned, page scrolls right) once it is wider than the
     viewport, so the left edge stays reachable.
   - the table keeps its compact natural width (min-content) with a floor equal
     to main's current content width, so narrow months still fill main exactly
     as before and never force a scrollbar on smaller screens.
   No overflow container is used, so the sticky header stays pinned. The floor's
   1175px / 2.5rem track main's max-width and padding above. */
.month-grid {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  display: flex;
  justify-content: safe center;
  box-sizing: border-box;
}
.month-schedule {
  width: min-content;
  min-width: calc(min(100vw, 1175px) - 2.5rem);
}

footer {
  margin-top: 1.75rem;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 1rem;
}

/* Page Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.875rem;
}

.page-header-left, .page-header-right {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-title {
  margin: 0.625rem 0 1.125rem 0;
  font-size: 1.25rem;
}

/* Day View Layout */
.day-header { margin-top: 0.75rem; margin-bottom: 1.125rem; }
.day-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(0, 1.4fr);
  gap: 1.5rem;
  margin-top: 1rem;
}
.day-section h3 { margin-top: 0; margin-bottom: 0.5rem; }

/* Year View Grid Layout */
.year-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.year-layout > div { overflow-x: auto; }
.year-monthly  { grid-column: 1 / -1; }
.year-ob       { grid-row: 2; grid-column: 1; }
.year-absence  { grid-row: 2; grid-column: 2; }
.year-overtime  { grid-row: 3; grid-column: 1; }
.year-oncall    { grid-row: 3; grid-column: 2; }
.year-vacation  { grid-column: 1 / -1; }
.year-cowork    { grid-column: 1 / -1; }

/* Responsive Layout */
@media (max-width: 900px) {
  .day-layout { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  main { padding: 0.75rem; }
  header .row { justify-content: space-between; align-items: center; }
  
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .page-header-left, .page-header-right { width: 100%; }

  /* Year view: single column on narrow screens */
  .year-layout { grid-template-columns: 1fr; }
  .year-monthly, .year-ob, .year-oncall, .year-overtime, .year-absence, .year-vacation, .year-cowork {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 480px) {
  header { padding: 0.75rem 1rem; }
  main { padding: 0.5rem; }
}