/* Shifts — scheduling, time off, hours */

.shifts-section-wrap {
  margin-top: 0.5rem;
}

.shifts-toolbar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.shifts-toolbar > * { flex-shrink: 0; }

@media (max-width: 768px) {
  .shifts-toolbar { gap: 0.55rem 0.75rem; }
  .shifts-metrics { flex-wrap: nowrap; overflow-x: auto; }
  .shifts-metric { white-space: nowrap; flex-shrink: 0; }
  .shifts-cal-views { margin-left: 0; width: 100%; }
  .shifts-cal-views button { flex: 1; }
  .shifts-day-row { grid-template-columns: 1fr; }
}

.shifts-toolbar label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.shifts-toolbar select,
.shifts-toolbar input[type="month"] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.shifts-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.shifts-metric {
  font-size: 0.875rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.shifts-metric--warn {
  background: #fff7ed;
  color: #c2410c;
}

.shifts-metric--ok {
  background: #ecfdf5;
  color: #047857;
}

.shifts-alerts {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff7ed;
  border-radius: var(--radius-sm);
  border-left: 4px solid #ea580c;
  font-size: 0.875rem;
}

.shifts-alerts:empty {
  display: none;
}

.shifts-section-panel {
  display: none;
}

.shifts-section-panel.active {
  display: block;
}

.shifts-calendar-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.shifts-calendar-nav h3 {
  font-size: 1.1rem;
  min-width: 12rem;
  text-align: center;
  margin: 0;
}

.shifts-cal-views {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.shifts-cal-views button {
  border: 0;
  background: var(--bg-card);
  padding: 0.35rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.shifts-cal-views button + button {
  border-left: 1px solid var(--border);
}

.shifts-cal-views button.is-active {
  background: var(--accent);
  color: #fff;
}

.shifts-calendar-grid--week .shifts-cal-day {
  min-height: 140px;
}

.shifts-day-board {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shifts-day-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) 1fr;
  gap: 0.75rem;
  align-items: start;
  text-align: left;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.shifts-day-row:hover {
  border-color: var(--accent);
}

.shifts-day-name {
  font-weight: 600;
}

.shifts-day-team {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.shifts-day-events .shifts-cal-event {
  display: inline-block;
  margin: 0 0.35rem 0.35rem 0;
  font-size: 0.8rem;
  padding: 2px 6px;
}

.shifts-day-empty,
.shifts-day-free {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.shifts-team-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}

.shifts-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.shifts-cal-head {
  background: var(--bg-app);
  padding: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
}

.shifts-cal-day {
  background: var(--bg-card);
  min-height: 88px;
  padding: 0.35rem;
  font-size: 0.7rem;
  vertical-align: top;
}

.shifts-cal-day--other {
  background: #f8f9fa;
  color: var(--text-muted);
}

.shifts-cal-day--today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.shifts-cal-day-num {
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

.shifts-cal-event {
  display: block;
  padding: 1px 4px;
  margin-bottom: 2px;
  border-radius: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  font-size: 0.65rem;
}

.shifts-cal-event--off {
  background: #94a3b8;
}

.shifts-cal-event--sick {
  background: #dc2626;
}

.shifts-cal-event--holiday {
  background: #7c3aed;
}

.shifts-cal-event--dayoff {
  background: #0d9488;
}

.shifts-status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.shifts-status--pending { background: #fef3c7; color: #92400e; }
.shifts-status--approved { background: #d1fae5; color: #065f46; }
.shifts-status--rejected { background: #fee2e2; color: #991b1b; }

.shifts-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.shifts-legend span::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.shifts-legend .leg-shift::before { background: var(--accent); }
.shifts-legend .leg-sick::before { background: #dc2626; }
.shifts-legend .leg-holiday::before { background: #7c3aed; }
.shifts-legend .leg-dayoff::before { background: #0d9488; }

.shifts-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.shifts-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-md);
}

.shifts-modal-body {
  padding: 1.25rem;
}

.shifts-modal-body .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.shifts-modal-body .form-group {
  margin-bottom: 0.75rem;
}

.shifts-modal-body label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.shifts-modal-body input,
.shifts-modal-body select,
.shifts-modal-body textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.shifts-modal-body label.shifts-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.shifts-modal-body label.shifts-check input {
  width: auto;
  margin-top: 0.15rem;
}

.shifts-modal-body label.shifts-check span {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.shifts-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0 1.25rem 1.25rem;
}

.shifts-availability-list {
  list-style: none;
  padding: 0;
}

.shifts-availability-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.shifts-hours-total {
  font-weight: 600;
}

.shifts-conflict-row {
  background: #fff7ed;
}

.shifts-intro { margin-bottom: 0.75rem; }

.shifts-section-nav {
  display: none;
}

.shifts-cal-day { cursor: pointer; }

.shifts-cal-day--picked {
  background: #eef2ff;
}

.shifts-cal-dow { display: none; }

.shifts-cal-agenda:not([hidden]) {
  margin-top: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.shifts-cal-agenda-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.shifts-cal-agenda-head h4 {
  margin: 0;
  font-size: 1rem;
}

.shifts-cal-agenda ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shifts-cal-agenda li {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.shifts-cal-agenda li span { color: var(--text-secondary); }

.shifts-day-log { margin-top: 0.45rem; }

/* Tablet and phone: sections live in the page, and the menu drawer stays out of the way. */
@media (max-width: 1024px) {
  body:has(#page-shifts.active) .menu-toggle { display: flex; }
  body:has(#page-shifts.active) .sidebar {
    transform: translateX(-100%);
    z-index: 95;
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.18);
  }
  body:has(#page-shifts.active) .sidebar.open { transform: translateX(0); }
  body.sidebar-open:has(#page-shifts.active) .sidebar-backdrop { display: block; }
  body:has(#page-shifts.active) #app-screen,
  body:has(#page-shifts.active) .main-content,
  body:has(#page-shifts.active) #page-shifts,
  body:has(#page-shifts.active) .shifts-module,
  body:has(#page-shifts.active) .module-detail {
    min-width: 0;
    max-width: 100%;
  }
  body:has(#page-shifts.active) .main-content { margin-left: 0; }

  .shifts-section-nav {
    display: flex;
    gap: 0.4rem;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    margin: 0 0 0.85rem;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .shifts-section-nav::-webkit-scrollbar { display: none; }
  .shifts-section-chip {
    flex: 0 0 auto;
    min-height: 40px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    padding: 0.35rem 0.85rem;
    font: inherit;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
  }
  .shifts-section-chip.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
  }

  #page-shifts .shifts-toolbar {
    flex-wrap: wrap;
    overflow: visible;
  }
  #page-shifts .shifts-calendar-nav .shifts-nav-btn,
  #page-shifts .shifts-cal-views button {
    min-height: 44px;
    min-width: 44px;
  }
}

@media (max-width: 1024px) and (min-width: 701px) {
  #page-shifts .table-wrap { overflow-x: auto; }
  #page-shifts .data-table th:first-child,
  #page-shifts .data-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-card);
    z-index: 1;
  }
  #page-shifts .shifts-conflict-row td:first-child { background: #fff7ed; }
}

@media (max-width: 700px) {
  .shifts-intro { display: none; }

  #page-shifts .shifts-toolbar:has(select),
  #page-shifts .shifts-toolbar:has(input) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.55rem 0.65rem;
    overflow: visible;
  }
  #page-shifts .shifts-toolbar:has(select) > select,
  #page-shifts .shifts-toolbar:has(select) > input,
  #page-shifts .shifts-toolbar:has(input) > select,
  #page-shifts .shifts-toolbar:has(input) > input {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }
  #page-shifts .shifts-toolbar:has(select) > .btn,
  #page-shifts .shifts-toolbar:has(input) > .btn {
    grid-column: 1 / -1;
  }
  #page-shifts .shifts-toolbar .btn {
    min-height: 44px;
    flex: 1 1 9rem;
  }

  #page-shifts .shifts-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    overflow: visible;
  }
  #page-shifts .shifts-metric { white-space: normal; }

  #page-shifts .shifts-calendar-nav {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.35rem 0.5rem;
  }
  #page-shifts .shifts-calendar-nav h3 {
    min-width: 0;
    font-size: 0.95rem;
    line-height: 1.25;
  }
  #page-shifts .shifts-cal-views {
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
    margin-left: 0;
  }
  #page-shifts .shifts-cal-views button { flex: 1; }

  .shifts-calendar-grid:not(.shifts-calendar-grid--week) .shifts-cal-head {
    padding: 0.35rem 0.1rem;
    font-size: 0.68rem;
  }
  .shifts-calendar-grid:not(.shifts-calendar-grid--week) .shifts-cal-day {
    min-height: 52px;
    padding: 0.2rem 0.1rem;
    text-align: center;
  }
  .shifts-calendar-grid:not(.shifts-calendar-grid--week) .shifts-cal-event {
    width: 8px;
    height: 8px;
    padding: 0;
    margin: 2px auto 0;
    border-radius: 99px;
    font-size: 0;
    color: transparent;
  }
  .shifts-calendar-grid:not(.shifts-calendar-grid--week) .shifts-cal-event:nth-of-type(n+4) {
    display: none;
  }

  .shifts-calendar-grid--week {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: transparent;
    border: 0;
  }
  .shifts-calendar-grid--week .shifts-cal-head { display: none; }
  .shifts-calendar-grid--week .shifts-cal-day {
    min-height: 0;
    padding: 0.75rem 0.85rem;
  }
  .shifts-calendar-grid--week .shifts-cal-dow {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .shifts-calendar-grid--week .shifts-cal-day-num {
    font-size: 1.05rem;
  }
  .shifts-calendar-grid--week .shifts-cal-event {
    white-space: normal;
    font-size: 0.8rem;
    padding: 4px 8px;
    margin-top: 0.35rem;
  }

  .shifts-day-row { min-height: 56px; }

  #page-shifts .data-table thead { display: none; }
  #page-shifts .data-table,
  #page-shifts .data-table tbody,
  #page-shifts .data-table tr,
  #page-shifts .data-table td {
    display: block;
    width: 100%;
  }
  #page-shifts .data-table {
    border: 0;
    background: transparent;
  }
  #page-shifts .data-table tr {
    margin-bottom: 0.65rem;
    padding: 0.7rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }
  #page-shifts .data-table td {
    border: 0;
    padding: 0.28rem 0;
    white-space: normal;
  }
  #page-shifts .data-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.1rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
  #page-shifts .data-table td.shifts-card-actions::before,
  #page-shifts .shifts-empty-row td::before { content: none; }
  #page-shifts .data-table td.shifts-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.45rem;
  }
  #page-shifts .data-table td.shifts-card-actions .btn {
    flex: 1 1 6.5rem;
    min-height: 40px;
  }
  #page-shifts .shifts-conflict-row { background: #fff7ed; }

  .shifts-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .shifts-modal {
    display: flex;
    flex-direction: column;
    max-width: none;
    width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: 16px 16px 0 0;
    overflow: hidden;
  }
  .shifts-modal-body {
    overflow: auto;
    flex: 1 1 auto;
  }
  .shifts-modal-body .form-row { grid-template-columns: 1fr; }
  .shifts-modal-body input,
  .shifts-modal-body select,
  .shifts-modal-body textarea {
    min-height: 44px;
    max-width: none;
    font-size: 16px;
  }
  .shifts-modal-body textarea { min-height: 72px; }
  .shifts-modal-actions {
    flex-shrink: 0;
    padding-top: 0.75rem;
    background: var(--bg-card);
  }
  .shifts-modal-actions .btn { flex: 1; min-height: 44px; }
}
