/* ==========================================================================
   GELEX HUB — Lịch họp team (khối trong màn Hôm nay + modal tạo họp)
   Enterprise: card phẳng trong .td-section-list (divider style, không lồng
   viền), token chuẩn — không fallback màu rác.
   ========================================================================== */

/* ---------- Nút tạo lịch họp ở đầu ngày ---------- */
.td-meet-new {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease) 120ms, border-color var(--ease) 120ms, color var(--ease) 120ms;
}
.td-meet-new:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-dark);
}

/* Dấu hiệu "ngày này có họp" trên dải 7 ô của tuần. */
.ws-day-meet {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2563eb;
}
.ws-day { position: relative; }
.ws-day.is-selected .ws-day-meet { background: currentColor; }

/* ---------- Khối lịch họp ---------- */
.td-section-meet .td-section-icon { color: #2563eb; }
.mt-list {
  display: flex;
  flex-direction: column;
}

/* Card = hàng phẳng trong section list (không viền riêng — section list đã có). */
.mt-card {
  display: grid;
  grid-template-columns: 68px 1fr;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
  transition: background var(--ease) 100ms;
}
.mt-card:last-child { border-bottom: none; }
.mt-card:hover { background: var(--surface-sunken); }

/* States: vạch trái 3px theo trạng thái. */
.mt-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: #2563eb;               /* mặc định: họp thường (xanh dương lịch) */
}
.mt-card.is-ongoing::before { background: #16a34a; }
.mt-card.is-cancelled::before { background: var(--border-strong); }

.mt-card.is-ongoing { background: #f6fdf9; }
.mt-card.is-ongoing:hover { background: #effcf5; }
.mt-card.is-past { opacity: 0.55; }
.mt-card.is-cancelled { opacity: 0.6; }
/* Gạch ngang CHỈ tiêu đề, không gạch cả thẻ: gạch hết thì giờ/địa điểm cũng
   khó đọc, mà người dùng vẫn cần biết lịch bị huỷ là lịch nào. */
.mt-card.is-cancelled .mt-title { text-decoration: line-through; }
/* Nháy viền một nhịp khi tới từ deep-link trong thông báo. */
.mt-card.is-focused {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Cột giờ: start đậm + end mờ, tabular. */
.mt-time {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  padding-top: 1px;
  padding-right: 14px;
  border-right: 1px solid var(--border-subtle);
  font-variant-numeric: tabular-nums;
}
.mt-time b { font-size: 14px; font-weight: 700; line-height: 1.25; color: var(--text); }
.mt-time small { font-size: 11.5px; color: var(--text-3); }

.mt-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.mt-title-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.mt-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.mt-live,
.mt-need,
.mt-source,
.mt-cancelled-tag {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.mt-live {
  background: #dcfce7; color: #15803d;
  display: inline-flex; align-items: center; gap: 4px;
}
.mt-live::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #16a34a;
  animation: mt-pulse 1.6s ease-in-out infinite;
}
@keyframes mt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.mt-need { background: #fef3c7; color: #b45309; }
.mt-source { background: #eff6ff; color: #2563eb; }
.mt-cancelled-tag { background: var(--surface-sunken); color: var(--text-3); }

.mt-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-3);
}
.mt-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}
.mt-agenda {
  font-size: 12px;
  color: var(--text-2);
  /* Agenda dài không được đẩy cả thẻ cao lên. Cắt 2 dòng; phần còn lại xem
     bằng tooltip của trình duyệt (v1 chưa có trang chi tiết cuộc họp). */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}

.mt-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* Avatar neo TRÁI, mọi nút dồn PHẢI. Dùng margin-right:auto ở đây thay vì
   margin-left:auto trên từng nút: nhiều phần tử cùng có margin-left:auto trong
   một flex row sẽ CHIA ĐỀU khoảng trống, nên thẻ vừa có "Tham gia" vừa có
   Sửa/Huỷ sẽ thấy nút Tham gia trôi ra giữa. */
.mt-avs { display: inline-flex; margin-right: auto; }
.mt-av {
  width: 24px;
  height: 24px;
  margin-right: -7px;
  border-radius: 50%;
  border: 2px solid var(--surface-raised);
  background: var(--surface-sunken);
  color: var(--text-2);
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mt-card:hover .mt-av { border-color: var(--surface-sunken); }
/* Màu nền = câu trả lời, để nhìn một cái là biết ai đã nhận lời. */
.mt-av.rsvp-accepted { background: #dcfce7; color: #15803d; }
.mt-av.rsvp-declined { background: #fee2e2; color: #b91c1c; }
.mt-av.rsvp-tentative { background: #fef3c7; color: #b45309; }
.mt-av.more { background: var(--surface-sunken); color: var(--text-3); }

.mt-btn {
  padding: 4px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text-2);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ease) 120ms, border-color var(--ease) 120ms, color var(--ease) 120ms;
}
.mt-btn:hover { background: var(--surface-sunken); color: var(--text); border-color: var(--border-strong); }
.mt-join {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.mt-join::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
  opacity: 0.9;
}
.mt-join:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.mt-cancel:hover { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.mt-edit:hover { border-color: var(--brand-border); background: var(--brand-soft); color: var(--brand-dark); }

/* RSVP: nhóm segmented nhỏ. */
.mt-rsvp {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.mt-rsvp-btn {
  padding: 3px 9px;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-3);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--ease) 120ms, color var(--ease) 120ms;
}
.mt-rsvp-btn:hover:not(:disabled) { color: var(--text); }
.mt-rsvp-btn:disabled { opacity: 0.5; cursor: default; }
.mt-rsvp-btn.active {
  background: var(--surface-raised);
  color: #15803d;
  box-shadow: var(--shadow-sm);
}
.mt-rsvp-btn.active[data-rsvp="declined"] { color: var(--danger); }
.mt-rsvp-btn.active[data-rsvp="tentative"] { color: #b45309; }

/* ---------- Modal tạo lịch họp ----------
   Khung riêng `.modal--meet`: form nhiều trường nên rộng hơn modal generic
   (400px), chia section rõ ràng, footer (lỗi + nút) luôn cố định dưới khung,
   chỉ phần thân cuộn. Ô giờ tách Ngày/Bắt đầu/Kết thúc riêng để không bị cắt
   cụt như datetime-local nhét 2 cột trong khung 400px cũ. */
.modal--meet {
  width: min(560px, 100%);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.meet-head {
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin-bottom: 0;
  padding: 18px 52px 14px 22px;
  border-bottom: 1px solid var(--border-subtle);
}
.meet-head strong { font-size: 17px; letter-spacing: -0.01em; }
.meet-head-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.meet-head-txt .modal-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-head-ic {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: var(--brand-soft);
  color: var(--brand);
}
.meet-head-ic svg { width: 19px; height: 19px; }

.modal--meet .meet-form { flex: 1; min-height: 0; gap: 0; }
.meet-body {
  min-height: 0; /* flex item cuộn được: không có dòng này hộp sẽ chống giãn theo nội dung */
  overflow-y: auto;
  padding: 18px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.meet-sec { display: flex; flex-direction: column; gap: 10px; }
.meet-sec-t {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}
.meet-sec-t svg { flex: none; width: 14px; height: 14px; }
.meet-sec-t em {
  margin-left: auto;
  font: inherit;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-3);
}

.meet-time-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
}
.meet-grid-time { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 10px; }

.meet-dur-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.meet-dur {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--ease) 120ms, background var(--ease) 120ms, color var(--ease) 120ms;
}
.meet-dur:hover { border-color: var(--border-strong); color: var(--text); }
.meet-dur.active {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-dark);
}
.meet-dur-now { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.meet-dur-now.is-empty { color: var(--text-3); font-weight: 500; }

.meet-field { display: flex; flex-direction: column; gap: 6px; }
.meet-field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.meet-field input,
.meet-field textarea,
.meet-picker input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color var(--ease) 120ms, background var(--ease) 120ms, box-shadow var(--ease) 120ms;
}
.meet-field input::placeholder,
.meet-picker input::placeholder { color: var(--text-3); }
.meet-field textarea {
  height: auto;
  min-height: 92px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.55;
}
.meet-field input:focus,
.meet-field textarea:focus,
.meet-picker input:focus {
  outline: none;
  border-color: var(--brand-border);
  background: var(--surface-raised);
  box-shadow: 0 0 0 3px var(--brand-tint-strong);
}
/* Ô nằm trong khung thời gian nền xám nên lật ngược: ô trắng nổi lên trên. */
.meet-time-panel input { background: var(--surface-raised); }

.meet-field-title input {
  height: 46px;
  font-size: 15px;
  font-weight: 600;
}

.meet-picker { position: relative; display: flex; flex-direction: column; gap: 8px; }
.meet-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.meet-chips:empty { display: none; }
.meet-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 7px 0 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-sunken);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.meet-chip-av {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-tint-strong);
  color: var(--brand-dark);
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.meet-chip-x {
  border: 0;
  background: none;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 3px;
}
.meet-chip-x:hover { color: var(--danger); }

.meet-results {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}
.meet-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: none;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background var(--ease) 100ms;
}
.meet-result:last-child { border-bottom: none; }
.meet-result:hover { background: var(--surface-sunken); }
.meet-result .meet-chip-av { background: var(--surface-sunken); color: var(--text-2); }
.meet-result-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meet-result small { color: var(--text-3); font-size: 11.5px; font-weight: 500; }
.meet-result-empty { padding: 10px 12px; font-size: 12.5px; color: var(--text-3); }

.meet-hint {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-3);
}

/* Chế độ SỬA: danh sách người dự chỉ đọc, avatar màu theo RSVP như ngoài card. */
.meet-ro-list { display: flex; flex-direction: column; gap: 6px; max-height: 208px; overflow-y: auto; }
.meet-ro {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
}
.meet-ro .mt-av { margin: 0; width: 26px; height: 26px; border: 0; font-size: 11px; }
.meet-ro-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.meet-chip-rsvp {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--text-3);
}
.meet-chip-rsvp.rsvp-accepted { background: #dcfce7; color: #15803d; }
.meet-chip-rsvp.rsvp-declined { background: #fee2e2; color: #b91c1c; }
.meet-chip-rsvp.rsvp-tentative { background: #fef3c7; color: #b45309; }

.meet-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}
.meet-foot .modal-error:not([hidden]) {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-light);
  border: 1px solid #fecaca;
}
.meet-actions { display: flex; gap: 10px; }
.meet-actions .modal-btn { flex: none; width: 96px; height: 44px; }
.meet-actions .modal-submit { flex: 1; margin-top: 0; height: 44px; font-size: 14px; }

@media (max-width: 560px) {
  /* Ngày chiếm cả hàng, Bắt đầu/Kết thúc chia đôi hàng dưới — ô time trên
     màn hẹp vẫn đủ rộng hiển thị đủ "HH:MM". */
  .meet-grid-time { grid-template-columns: 1fr 1fr; }
  .meet-grid-time .meet-field:first-child { grid-column: 1 / -1; }
  .meet-head { padding: 16px 48px 12px 16px; }
  .meet-body { padding: 16px 16px 18px; }
  .meet-foot { padding: 12px 16px 16px; }
  .mt-card { grid-template-columns: 58px 1fr; gap: 10px; padding: 10px 12px; }
  .mt-time { padding-right: 10px; }
  /* Hẹp thì cho nút xuống dòng ngay dưới avatar, không đẩy sang phải nữa. */
  .mt-avs { margin-right: 0; }
}
