/* Style riêng của app lịch trực — nền tảng (màu, nút, bảng, form, modal) nằm ở shared.css. */

.page-wide {
  max-width: 1200px;
}

.card > h2 {
  margin-top: 0;
}

.header-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.home-link.is-current {
  color: var(--color-text);
}

.btn[hidden] {
  display: none;
}

/* Bảng không xuống dòng — cột nào dài thì cuộn ngang trong .table-scroll (shared.css) thay vì bóp chữ thành
   nhiều dòng trên màn hình hẹp. */
.data-table th,
.data-table td {
  white-space: nowrap;
}

.title-cell {
  font-weight: 600;
}

.data-table .number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table .sticky-col {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--color-surface);
  box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.18);
}

.data-table tr.is-me td {
  background: #eff6ff;
}

.field input[readonly] {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

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

/* ---------- Thanh công cụ lịch ---------- */

.calendar-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 16px;
}

.calendar-nav {
  display: flex;
  gap: 6px;
}

.btn-compact {
  padding: 6px 12px;
  font-size: 13px;
}

.period-label {
  flex: 1;
  margin: 0;
  font-size: 18px;
  white-space: nowrap;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #eef2ff;
  border-radius: var(--radius);
}

.segmented-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  cursor: pointer;
}

.segmented-btn.is-active {
  background: var(--color-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.15);
}

.calendar-hint {
  margin: -6px 0 12px;
}

.calendar-container {
  width: 100%;
  overflow-x: auto;
}

/* ---------- Người trực (chip) ---------- */

.chip-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-chip.is-me {
  background: #dcfce7;
  color: #166534;
}

.person-chip-removable {
  justify-content: space-between;
  padding-right: 2px;
}

.person-chip-removable > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn-chip {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: transparent;
  color: inherit;
}

.icon-btn-chip svg {
  width: 12px;
  height: 12px;
}

.icon-btn-chip:hover {
  background: #fee2e2;
  color: var(--color-error);
}

.empty-slot {
  color: var(--color-text-muted);
}

select.assign-select {
  width: 100%;
  margin-top: 6px;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ---------- Lưới tuần (hàng = ca, cột = thứ) ---------- */

.schedule-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--color-border);
  padding: 8px;
  vertical-align: top;
}

.schedule-table thead th {
  background: #f8fafc;
  text-align: center;
}

.schedule-table .shift-head {
  width: 120px;
  text-align: left;
  background: #f8fafc;
}

.day-label,
.shift-label {
  display: block;
  font-weight: 700;
}

.day-date,
.shift-time {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.schedule-table td {
  height: 72px;
}

.schedule-table .is-weekend {
  background: #fafafa;
}

.schedule-table thead th.is-today {
  background: var(--color-primary);
  color: #fff;
}

.schedule-table thead th.is-today .day-date {
  color: #dbeafe;
}

.schedule-table td.is-today {
  background: #f5f9ff;
}

/* ---------- Lưới tháng ---------- */

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  min-width: 770px;
  border-top: 1px solid var(--color-border);
  border-left: 1px solid var(--color-border);
}

.month-head,
.month-day {
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.month-head {
  padding: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: #f8fafc;
}

.month-day {
  min-height: 96px;
  padding: 4px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.month-day.is-weekend,
.month-head.is-weekend {
  background: #fafafa;
}

.month-day.is-outside {
  background: #f3f4f6;
}

.month-day.is-outside .month-day-number,
.month-day.is-outside .person-chip {
  opacity: 0.55;
}

.month-day-number {
  align-self: flex-start;
  border: none;
  background: transparent;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  cursor: pointer;
}

.month-day-number:hover {
  background: #eef2ff;
}

.month-day.is-today .month-day-number {
  background: var(--color-primary);
  color: #fff;
}

.month-shift {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.month-shift-label {
  flex-shrink: 0;
  width: 36px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.month-shift .person-chip {
  font-size: 11px;
  padding: 0 6px;
}

/* ---------- Thông báo ngắn (shared-ui.js showToast) ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 300;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 16px;
  border-radius: var(--radius);
  background: #1f2328;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}

@media (max-width: 640px) {
  .page-header {
    flex-direction: column;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .period-label {
    flex-basis: 100%;
    order: -1;
  }
}

/* ---------- Lịch chờ duyệt ---------- */

.person-chip.is-pending {
  background: #fff7ed;
  color: #9a3412;
  outline: 1px dashed #fb923c;
  outline-offset: -1px;
}

.person-chip.is-pending > span::after {
  content: ' · chờ duyệt';
  font-weight: 400;
}

.icon-btn-approve {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #dcfce7;
  color: var(--color-success);
}

.icon-btn-approve svg {
  width: 12px;
  height: 12px;
}

.icon-btn-approve:hover {
  background: #bbf7d0;
}

.data-table .actions-cell .icon-btn-approve,
.data-table .actions-cell .icon-btn-chip {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
}

.data-table .actions-cell .icon-btn-chip {
  background: #fee2e2;
  color: var(--color-error);
}

.data-table .actions-cell svg {
  width: 16px;
  height: 16px;
}

.pending-count {
  color: #c2410c;
  font-weight: 600;
}

/* Trang phân công: chip có nút duyệt/gỡ đã chật — bỏ chữ "chờ duyệt", màu cam + viền đứt + tooltip đủ nhận
   biết. */
.person-chip-removable.is-pending > span::after {
  content: none;
}

/* ---------- Tự động xếp lịch ---------- */

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

.generator-form input[type='month'],
.generator-form input[type='number'] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}

.generator-form select:disabled {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.generator-summary {
  margin: 18px 0 0;
  font-size: 14px;
  font-weight: 600;
}

.warning-text {
  color: #b45309;
  font-size: 14px;
  margin: 8px 0 0;
}

.generator-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .generator-form {
    grid-template-columns: 1fr 1fr;
  }

  .generator-preview-grid {
    grid-template-columns: 1fr;
  }
}

/* Số lịch chờ duyệt cạnh link "Phân công" (shared-nav.js). */
.nav-badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ea580c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: 1px;
}

.nav-badge[hidden] {
  display: none;
}
