/* ============================================================
   LSR GX. Ninh Loan — THÀNH PHẦN DÙNG CHUNG — thẻ, bảng, nhãn, form, modal, lịch
   ============================================================ */

/* Ảnh logo bo tròn, viền trắng */
.brand-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 3px solid #fff;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.brand-img.lg {
  width: 96px;
  height: 96px;
  margin: 0 auto 8px;
  border-width: 4px;
}

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

.field.full {
  grid-column: 1/-1;
}

/* Nhãn dùng trên nền sáng (form đặt lịch nay nền kem, không còn nền đỏ) */
.field label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--den);
}

.field input,
.field select,
.field textarea {
  padding: 12px 15px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--den);
  font-family: inherit;
  font-size: 1rem;
  transition: 0.2s;
  width: 100%;
}

.field textarea {
  resize: vertical;
  min-height: 80px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--vang);
  box-shadow: 0 0 0 4px rgba(245, 197, 24, 0.28);
}

.field .err {
  color: #c0392b;
  font-size: 0.8rem;
  font-weight: 700;
  min-height: 1em;
  display: none;
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: #c0392b;
}

.field.invalid .err {
  display: block;
}

/* ============ MODAL ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 10, 10, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.overlay.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 20px;
  max-width: 400px;
  width: 100%;
  padding: 32px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

/* Modal rộng cho biểu mẫu thêm/sửa trong khu quản trị */
.modal.lg {
  max-width: 680px;
  text-align: left;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px;
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-head h3 {
  margin: 0;
  flex: 1;
  color: var(--do-dam);
  font-size: 1.15rem;
}

.modal-x {
  border: none;
  background: #f0ece5;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--xam);
  flex: none;
  transition: 0.2s;
}

.modal-x:hover {
  background: #fbe4e4;
  color: var(--do);
}

.modal .mask {
  font-size: 2.6rem;
}

.modal h3 {
  color: var(--do-dam);
  font-size: 1.5rem;
  margin: 8px 0 6px;
}

.modal p {
  color: var(--xam);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.modal input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 10px;
}

.modal input:focus {
  outline: none;
  border-color: var(--do);
}

/* 2 nút cạnh nhau; hết chỗ thì tự xuống thành 2 dòng full-width thay vì gãy chữ */
.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-actions .btn {
  flex: 1 1 140px;
  justify-content: center;
  padding: 13px 14px;
  font-size: 0.95rem;
  white-space: nowrap;
}

.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 14px;
}

.alert.err {
  background: #fbe4e4;
  color: #c0392b;
}

.alert.ok {
  background: var(--xanh-bg);
  color: var(--xanh-ok);
}

.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

.card h3 {
  color: var(--do-dam);
  font-size: 1.15rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.toolbar select,
.toolbar input {
  padding: 9px 13px;
  border-radius: 10px;
  border: 2px solid var(--line);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.toolbar .grow {
  flex: 1;
  min-width: 40px;
}

.view-toggle {
  display: flex;
  background: #f0ece5;
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}

.view-toggle button {
  border: none;
  background: transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--xam);
}

.view-toggle button.active {
  background: var(--do);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 720px;
}

th {
  background: var(--vang-nhat);
  color: var(--do-dam);
  text-align: left;
  padding: 12px 14px;
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

tr:hover td {
  background: #fffaf0;
}

.st {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

/* Nhãn trạng thái bấm được (bảng thành viên): trông y hệt nhãn thường,
   chỉ khác con trỏ và cái nhấc nhẹ khi rê chuột để biết là bấm được. */
.st-form {
  display: inline;
}
button.st-btn {
  border: none;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s, filter 0.14s;
}
button.st-btn:hover {
  transform: translateY(-1px);
  filter: brightness(0.96);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
}
button.st-btn:active {
  transform: none;
  box-shadow: none;
}
button.st-btn:focus-visible {
  outline: 2px solid var(--do);
  outline-offset: 2px;
}

.st-moi {
  background: #e8eefb;
  color: #2d5bd7;
}

.st-coc {
  background: #fff0d6;
  color: #b57d00;
}

.st-xacnhan {
  background: #e0f0ff;
  color: #0a6ebd;
}

.st-hoanthanh {
  background: var(--xanh-bg);
  color: var(--xanh-ok);
}

.st-huy {
  background: #fbe4e4;
  color: #c0392b;
}

.st-active {
  background: var(--xanh-bg);
  color: var(--xanh-ok);
}

.st-off {
  background: #eee;
  color: #888;
}

/* Ô nhập nằm TRONG bảng. Trước chỉ có select nên ô chữ (cột "Lý do / ghi chú"
   ở trang Điểm danh) trơ ra kiểu mặc định của trình duyệt, lạc hẳn tông. */
td select,
td input[type='text'],
td input[type='tel'],
td input[type='number'],
td input[type='date'],
.inline-select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1.5px solid var(--line);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  background: #fff;
  color: var(--den);
}
/* Ô chữ dài hơn ô chọn, và nét chữ thường cho dễ đọc nội dung nhập vào */
td input[type='text'] {
  width: 100%;
  min-width: 150px;
  font-weight: 500;
}
td select:focus,
td input:focus {
  outline: none;
  border-color: var(--do);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}
td input::placeholder {
  color: #b9aca6;
  font-weight: 400;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.icon-btn {
  border: none;
  background: #f0ece5;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: 0.2s;
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  color: inherit;
}

.icon-btn:hover {
  background: var(--vang);
}

.icon-btn.del:hover {
  background: #fbe4e4;
}

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--xam);
}

.empty .big {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 10px;
}

/* Calendar */
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-head b {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: var(--do-dam);
}

.cal-nav {
  display: flex;
  gap: 8px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-dow {
  text-align: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--xam);
  padding: 6px 0;
  text-transform: uppercase;
}

.cal-cell {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  background: #fff;
  font-size: 0.78rem;
  overflow: hidden;
}

.cal-cell.other {
  background: #f6f3ee;
  opacity: 0.5;
}

.cal-cell.today {
  border-color: var(--do);
  box-shadow: inset 0 0 0 1px var(--do);
}

.cal-cell .dnum {
  font-weight: 800;
  color: var(--den);
  margin-bottom: 3px;
}

.cal-ev {
  background: var(--vang-nhat);
  border-left: 3px solid var(--do);
  border-radius: 5px;
  padding: 2px 5px;
  margin-bottom: 3px;
  font-weight: 600;
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.cal-ev.done {
  border-left-color: var(--xanh-ok);
  background: var(--xanh-bg);
}

.cal-ev.huy {
  border-left-color: #c0392b;
  background: #fbe4e4;
  text-decoration: line-through;
  opacity: 0.7;
}

/* align-items:end làm các ô lệch nhau: field có .field-hint thì cao hơn nên bị đẩy lên.
   Căn theo đỉnh + cho mỗi field là flex-column thì mọi label & ô nhập thẳng hàng. */
.mform {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px 12px;
  align-items: start;
}

.mform .field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Ô nhập luôn nằm sát dưới label, phần gợi ý đẩy xuống cuối */
.mform .field input,
.mform .field select,
.mform .field textarea {
  width: 100%;
}

.mform .field .field-hint {
  margin-top: auto;
  padding-top: 4px;
}

/* Field chứa nút bấm không có label → chèn khoảng trống bằng đúng chiều cao label
   để nút thẳng hàng với các ô nhập bên cạnh thay vì trồi lên trên. */
.mform .field.submit::before {
  content: '';
  display: block;
  min-height: 1.2em;
  margin-bottom: 3px;
}

.mform .field.submit .btn {
  width: 100%;
  justify-content: center;
}

.mform .field label {
  color: var(--den);
  font-size: 0.82rem;
  margin-bottom: 3px;
  font-weight: 600;
  min-height: 1.2em;
}

.mform .field input,
.mform .field select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid var(--line);
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: var(--den);
}

.mform .field input:focus,
.mform .field select:focus {
  outline: none;
  border-color: var(--do);
}

/* Ô nhập nhiều dòng + form dạng lưới rộng hơn cho các module mới */
.mform .field textarea {
  padding: 10px 12px;
  border-radius: 10px;
  border: 2px solid var(--line);
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: var(--den);
  resize: vertical;
  min-height: 74px;
}

.mform .field textarea:focus {
  outline: none;
  border-color: var(--do);
}

.mform.wide {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.mform .span2 {
  grid-column: span 2;
}

.field-hint {
  font-size: 0.76rem;
  color: var(--xam);
  margin-top: 3px;
}

/* Chấm màu con lân */
.lion-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
  border: 2px solid rgba(0, 0, 0, 0.18);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.lion-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #f6f3ee;
  border-radius: 50px;
  padding: 5px 13px 5px 7px;
  font-weight: 700;
  font-size: 0.83rem;
  white-space: nowrap;
}

.lion-none {
  color: var(--xam);
  font-style: italic;
  font-size: 0.85rem;
}

/* Cột số thứ tự: hẹp, canh giữa, chữ mờ cho khỏi tranh chú ý với nội dung */
th.num,
td.num {
  width: 48px;
  text-align: center;
  color: var(--xam);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Ô lọc trên thanh công cụ: rộng theo nội dung, KHÔNG chiếm trọn hàng
   (width:100% từng làm mỗi ô rớt xuống một dòng, vỡ bố cục Lịch diễn). */
.toolbar select,
.toolbar input[type='date'] {
  width: auto;
  padding: 10px 34px 10px 13px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--den);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s;
  /* Mũi tên tự vẽ bằng SVG inline cho đồng bộ mọi trình duyệt */
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b0000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.toolbar select:hover {
  border-color: var(--vang);
}

.toolbar select:focus,
.toolbar input[type='date']:focus {
  outline: none;
  border-color: var(--do);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.12);
}

/* input date có sẵn icon lịch của trình duyệt → bỏ mũi tên tự vẽ đi */
.toolbar input[type='date'] {
  background-image: none;
  padding-right: 13px;
}

/* Khung xem trước tin nhắn để copy */
.copy-box {
  background: #2b211d;
  color: #f6ead9;
  border-radius: 12px;
  padding: 16px 18px;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  border-left: 4px solid var(--vang);
  min-height: 60px;
}

@media (max-width: 720px) {
  .cal-cell {
    min-height: 58px;
    padding: 4px;
  }
  .cal-ev {
    font-size: 0.62rem;
  }
  table {
    font-size: 0.84rem;
  }
  .mform .span2 {
    grid-column: auto;
  }
}

/* ---------- Ô "Tên" của bảng thành viên ----------
   Gộp 3 thông tin vào một ô. Trên máy tính để năm sinh nằm ngay sau tên
   cho gọn hàng; địa chỉ luôn xuống dòng riêng. */
.person .p-name {
  font-weight: 700;
}
/* Cỡ chữ ghi bằng rem chứ KHÔNG dùng em: bảng đã là 0.9rem, nhân thêm em nữa
   thì tụt xuống ~12px, đọc không nổi. rem neo thẳng vào cỡ gốc của trang. */
.person .p-age,
.person .p-addr {
  color: var(--xam);
  font-size: 0.85rem;
  line-height: 1.45;
}
.person .p-age {
  margin-left: 5px;
  white-space: nowrap;
}
.person .p-addr {
  display: block;
  margin-top: 2px;
}

/* Ô ghi chú trong bảng: giới hạn bề ngang, dài thì xuống dòng cho khỏi giãn bảng */
td.cell-note {
  max-width: 260px;
  white-space: normal;
  word-break: break-word;
  font-size: 0.86rem;
  color: var(--xam);
}

/* Toast thông báo (Toastify) — bo tròn, đổ bóng theo tông của web */
.toastify.lsr-toast {
  border-radius: 12px;
  padding: 14px 18px;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: min(420px, 88vw);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}
.toastify.lsr-toast .toast-close {
  opacity: 0.85;
  font-size: 1.25rem;
  padding: 0 0 0 12px;
  align-self: flex-start;
}
.toastify.lsr-toast .toast-close:hover {
  opacity: 1;
}

/* ============================================================
   MOBILE ≤720px — bảng biến thành THẺ XẾP DỌC
   Bảng nhiều cột trên điện thoại phải cuộn ngang rất khó dùng.
   Ở đây mỗi dòng thành một thẻ, mỗi ô hiện kèm tên cột (data-label).
   ============================================================ */
@media (max-width: 720px) {
  .table-wrap {
    overflow: visible;
    border: none;
    border-radius: 0;
  }
  table {
    display: block;
    min-width: 0;
    font-size: 0.93rem;
  }
  thead {
    display: none;
  }
  tbody {
    display: block;
  }
  tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 4px 14px rgba(139, 0, 0, 0.05);
    overflow: hidden;
  }
  tr:hover td {
    background: transparent;
  }
  td {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border: none;
    padding: 10px 14px;
  }
  td + td {
    border-top: 1px dashed var(--line);
  }
  /* Tên cột nằm bên trái mỗi dòng */
  td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    font-weight: 700;
    font-size: 0.76rem;
    line-height: 1.5;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--xam);
  }
  /* Ô trống rỗng (dòng "chưa có dữ liệu") giữ nguyên, không thêm nhãn */
  td[colspan] {
    display: block;
    padding: 0;
  }
  /* Số thứ tự: cho ra vẻ tiêu đề thẻ thay vì một dòng riêng lẻ */
  td.num {
    background: var(--vang-nhat);
    font-weight: 800;
    color: var(--do-dam);
    width: auto;
    text-align: left;
  }
  td.cell-note {
    max-width: none;
  }
  /* Ô "Tên": trên điện thoại tách hẳn 3 hàng — tên / năm sinh + tuổi / địa chỉ.
     Chỗ này hẹp, để năm sinh nằm cùng hàng với tên là bị ngắt dòng lung tung. */
  .person .p-name,
  .person .p-age,
  .person .p-addr {
    display: block;
  }
  /* Trên điện thoại nới thêm chút nữa cho dễ đọc */
  .person .p-age,
  .person .p-addr {
    font-size: 0.9rem;
  }
  .person .p-age {
    margin-left: 0;
    margin-top: 3px;
  }
  .person .p-addr {
    margin-top: 3px;
  }
  /* Nút thao tác trải hết bề ngang cho dễ bấm bằng ngón tay */
  .row-actions {
    width: 100%;
  }
  .row-actions .btn {
    flex: 1 1 auto;
  }
  .row-actions .icon-btn {
    width: 42px;
    height: 42px;
  }

  /* ---- Thẻ, thanh công cụ, form ---- */
  .card {
    padding: 16px;
    border-radius: 14px;
  }
  .card-head {
    gap: 10px;
  }
  .card-head .btn,
  .card-head form {
    width: 100%;
  }
  .card-head .btn {
    justify-content: center;
  }
  /* Ô lọc chiếm trọn hàng cho dễ chạm */
  .toolbar {
    gap: 8px;
  }
  .toolbar > * {
    width: 100%;
  }
  .toolbar select,
  .toolbar input,
  .toolbar input[type='date'] {
    width: 100%;
    min-width: 0;
  }
  .toolbar .grow {
    display: none;
  }

  /* ---- Modal ---- */
  .overlay {
    padding: 10px;
    align-items: flex-start;
    padding-top: 24px;
  }
  .modal,
  .modal.lg {
    padding: 18px;
    border-radius: 16px;
    max-height: 92vh;
  }
  .mform,
  .mform.wide {
    grid-template-columns: 1fr;
  }
  .modal-actions .btn {
    flex: 1 1 100%;
  }
}
