/* ============================================================
   components.css — UI Components tái sử dụng toàn hệ thống
   Import sau base.css
   ============================================================ */

/* ══════════════════════════════════════════
   NAV
   ══════════════════════════════════════════ */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: var(--hairline) solid var(--line);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0;
}

/* Logo */
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: var(--gap-xl);
  flex-shrink: 0;
}

.nav-logo:hover { opacity: .85; }

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--brand);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.logo-img {
  height: 34px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.logo-text {
  font-size: var(--fs-logo);
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}

.logo-text small {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
}

/* Nav links */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-link {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: var(--fs-md);
  color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

/* Nav actions */
.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  margin-left: auto;
}

/* ══════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════ */

/* Base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--btn-pad);
  border-radius: var(--radius);
  font-size: var(--fs-btn);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  border: var(--hairline) solid transparent;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Ghost — chữ đen nền trắng */
.btn-ghost {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}
.btn-ghost:hover {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}

/* Primary — chữ trắng nền teal */
.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

/* Danger */
.btn-danger {
  background: var(--cut-soft);
  color: var(--cut);
  border-color: var(--cut);
}
.btn-danger:hover {
  background: var(--cut);
  color: #fff;
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
}

/* Sizes */
.btn-sm {
  padding: 5px 10px;
  font-size: var(--fs-xs);
}
.btn-lg {
  padding: 10px 22px;
  font-size: var(--fs-base);
  border-radius: var(--radius-md);
}

/* ══════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════ */
.card {
  background: var(--panel);
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: var(--gap-lg);
}

.card-hover {
  cursor: pointer;
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.card-hover:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-md);
  border-bottom: var(--hairline) solid var(--line);
}

.card-title {
  font-size: var(--fs-h3);
  font-weight: 500;
  color: var(--ink);
}

/* ══════════════════════════════════════════
   BADGES & PILLS
   ══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-span);
  font-weight: 500;
  line-height: 1.4;
}

.badge-brand   { background: var(--brand-soft);  color: var(--brand-dark);  border: var(--hairline) solid rgba(24,116,95,.32); }
.badge-cut     { background: var(--cut-soft);    color: var(--cut);         border: var(--hairline) solid rgba(224,68,56,.32); }
.badge-crease  { background: var(--crease-soft); color: var(--crease);      border: var(--hairline) solid rgba(37,99,217,.32); }
.badge-warn    { background: var(--warn-soft);   color: var(--warn);        border: var(--hairline) solid rgba(217,119,6,.32); }
.badge-ok      { background: var(--ok-soft);     color: var(--ok);          border: var(--hairline) solid rgba(22,163,74,.32); }
.badge-muted   { background: var(--bg);          color: var(--muted);       border: var(--hairline) solid var(--line); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 14px;
  border-radius: 99px;
  font-size: var(--fs-span);
  font-weight: 500;
}

/* ══════════════════════════════════════════
   MODULE ICON
   ══════════════════════════════════════════ */
.mod-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.mod-icon-teal { background: var(--brand-soft);  color: var(--brand); }
.mod-icon-blue { background: var(--crease-soft); color: var(--crease); }
.mod-icon-red  { background: var(--cut-soft);    color: var(--cut); }
.mod-icon-warn { background: var(--warn-soft);   color: var(--warn); }

/* ══════════════════════════════════════════
   FORM ELEMENTS
   ══════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
}

.form-input {
  height: 38px;
  padding: 0 12px;
  border: var(--hairline) solid var(--line-strong);
  border-radius: var(--radius);
  font-size: var(--fs-base);
  color: var(--ink);
  background: var(--panel);
  transition: border-color var(--t-fast);
  width: 100%;
}

.form-input:hover { border-color: var(--subtle); }
.form-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}

.form-input::placeholder { color: var(--subtle); }

.form-textarea {
  padding: 10px 12px;
  min-height: 100px;
  resize: vertical;
}

.form-error {
  font-size: var(--fs-xs);
  color: var(--cut);
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   TABLE
   ══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}

.table th {
  text-align: left;
  padding: 10px 14px;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--muted);
  background: var(--panel-soft);
  border-bottom: var(--hairline) solid var(--line-strong);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: var(--hairline) solid var(--line);
  color: var(--ink);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.table tr:hover td { background: color-mix(in srgb, var(--brand-soft) 55%, transparent); }

/* ══════════════════════════════════════════
   STATS ROW
   ══════════════════════════════════════════ */
.stats-row {
  display: flex;
  background: var(--panel);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.stat-cell {
  flex: 1;
  padding: 18px 16px;
  text-align: center;
  border-right: var(--hairline) solid var(--line);
}
.stat-cell:last-child { border-right: none; }

.stat-num {
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1;
}

.stat-lbl {
  font-size: var(--fs-span);
  color: var(--muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   LOADING & EMPTY STATE
   ══════════════════════════════════════════ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-3xl);
  color: var(--muted);
  font-size: var(--fs-base);
  gap: var(--gap-sm);
}

/* ── Skeleton loading — dùng cho khối nội dung lớn (bảng/danh sách/card cấu
   hình) thay cho '.loading' tĩnh (chữ + icon đồng hồ cát treo giữa màn hình,
   không gợi ý được nội dung sắp hiện dạng gì). Mảng xám chạy sáng theo hình
   dạng gần đúng nội dung thật giúp cảm giác chờ ngắn hơn. */
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.skeleton-block { display: flex; flex-direction: column; gap: 10px; padding: var(--gap-md) 0; }

.skeleton-line, .skeleton-card, .skeleton-row {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--panel-soft) 25%, var(--line) 37%, var(--panel-soft) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}

.skeleton-line { height: 14px; }
.skeleton-line.w-30 { width: 30%; }
.skeleton-line.w-50 { width: 50%; }
.skeleton-line.w-70 { width: 70%; }

.skeleton-row { height: 20px; flex: 1; }
.skeleton-row-group { display: flex; gap: 16px; align-items: center; }

.skeleton-card { height: 100px; border-radius: var(--radius-md); }

.empty-state {
  text-align: center;
  padding: var(--gap-3xl) var(--gap-lg);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: var(--gap-md);
  opacity: .4;
}

.empty-state h3 {
  font-size: var(--fs-h3);
  color: var(--ink);
  margin-bottom: var(--gap-sm);
}

.empty-state p {
  font-size: var(--fs-base);
  color: var(--muted);
  margin-bottom: var(--gap-lg);
}

/* ══════════════════════════════════════════
   TOAST NOTIFICATION
   ══════════════════════════════════════════ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: var(--fs-base);
  box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease;
  min-width: 240px;
  max-width: 360px;
}

.toast-ok      { background: var(--brand); }
.toast-error   { background: var(--cut); }
.toast-warn    { background: var(--warn); color: var(--ink); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════ */
.footer {
  border-top: var(--hairline) solid var(--line);
  background: rgba(255, 255, 255, .75);
  padding: 14px 0;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer p {
  font-size: var(--fs-footer);
  color: var(--muted);
  line-height: 1.4;
}

.footer-version {
  font-size: var(--fs-span);
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: var(--hairline) solid rgba(24, 116, 95,.32);
}

/* ══════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 36, 48, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--gap-xl) var(--gap-md);
  overflow-y: auto;
  animation: toast-in .15s ease;
}

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--gap-xl) * 2);
}
.modal-lg { max-width: 680px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md) var(--gap-lg);
  border-bottom: var(--hairline) solid var(--line);
}

.modal-title { font-size: var(--fs-h3); font-weight: 500; color: var(--ink); }

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}
.modal-close:hover { color: var(--ink); }

.modal-body { padding: var(--gap-lg); overflow-y: auto; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  justify-content: flex-end;
  padding: var(--gap-md) var(--gap-lg);
  border-top: var(--hairline) solid var(--line);
}

/* ══════════════════════════════════════════
   DRAWER — trượt bên phải, không che toàn màn hình
   (dùng khi cần xem chi tiết mà vẫn giữ ngữ cảnh bảng phía sau, vd Kanban)
   ══════════════════════════════════════════ */
.drawer-panel {
  position: fixed;
  top: var(--nav-height);
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100%;
  background: var(--panel);
  border-left: var(--hairline) solid var(--line);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--t-base);
  z-index: 200;
}
.drawer-panel.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--gap-md) var(--gap-lg);
  border-bottom: var(--hairline) solid var(--line);
  flex-shrink: 0;
}

.drawer-title { font-size: var(--fs-h3); font-weight: 500; color: var(--ink); }

.drawer-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--muted);
  padding: 4px 8px;
}
.drawer-close:hover { color: var(--ink); }

.drawer-body { flex: 1; overflow-y: auto; padding: var(--gap-lg); }

.drawer-foot {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  justify-content: flex-end;
  padding: var(--gap-md) var(--gap-lg);
  border-top: var(--hairline) solid var(--line);
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .drawer-panel { width: 100%; top: 0; }
}

/* ══════════════════════════════════════════
   FORM GRID (dùng trong modal)
   ══════════════════════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-md);
}
.form-grid .form-col-2 { grid-column: 1 / -1; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
  color: var(--ink);
  cursor: pointer;
}

select.form-input { appearance: auto; background: var(--panel); }

.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: var(--fs-base);
}
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; color: var(--ink); }

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

/* ===== Bảng chọn ngày/tháng tiếng Việt (js/datepicker.js) ===== */
.vnp-pop {
  position: fixed;
  z-index: 1000;
  width: 280px;
  padding: 12px;
  background: var(--panel);
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  color: var(--ink);
}
.vnp-head { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.vnp-title { flex: 1; text-align: center; font-weight: 600; }
.vnp-nav {
  width: 28px; height: 28px;
  border: 0; border-radius: var(--radius);
  background: transparent; color: var(--ink);
  font-size: 16px; line-height: 1; cursor: pointer;
}
.vnp-nav:hover { background: var(--brand-soft); }
.vnp-week, .vnp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.vnp-week span { text-align: center; padding: 4px 0; font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.vnp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.vnp-cell {
  height: 32px;
  border: var(--hairline) solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--ink);
  font-size: var(--fs-base); cursor: pointer;
}
.vnp-months .vnp-cell { height: 40px; }
.vnp-cell:hover { background: var(--brand-soft); }
.vnp-cell.is-out { color: var(--subtle); }
.vnp-cell.is-today { border-color: var(--brand); }
.vnp-cell.is-selected { background: var(--brand); color: #fff; font-weight: 600; }
.vnp-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: var(--hairline) solid var(--line); }
.vnp-link { border: 0; background: transparent; color: var(--brand); font-size: var(--fs-btn); font-weight: 600; cursor: pointer; }
.vnp-link:hover { color: var(--brand-dark); text-decoration: underline; }
@media (max-width: 480px) { .vnp-pop { width: calc(100vw - 16px); } }

/* Gợn sóng khi click chuột (js/click-ripple.js) — nhiều vòng, nhẹ */
.click-ripple {
  position: fixed;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  border: 1px solid var(--brand);
  pointer-events: none;
  z-index: 99999;
  opacity: 0;
  animation: click-ripple .9s ease-out both;
}
@keyframes click-ripple {
  0%   { transform: scale(.3); opacity: .35; }
  100% { transform: scale(5);  opacity: 0; }
}
