/* ==========================================================================
   Quản Lý Kho XNT v1.8 - M2GPS Cloud
   Toàn bộ CSS giao diện nền, thẻ OneUI, bảng dính tiêu đề và hiệu ứng chuyển cảnh
   ========================================================================== */

html {
  font-size: 13.5px;
  background:
    radial-gradient(900px 480px at 0% -10%, rgba(59, 130, 246, 0.09), transparent 62%) no-repeat,
    radial-gradient(760px 440px at 100% -6%, rgba(99, 102, 241, 0.075), transparent 58%) no-repeat,
    radial-gradient(640px 360px at 50% 0%, rgba(255, 255, 255, 0.85), transparent 70%) no-repeat,
    linear-gradient(180deg, #fafcff 0%, #f5f7fb 45%, #eef2f7 100%) no-repeat,
    #f5f7fb;
  background-attachment: fixed;
}

@media (min-width: 640px) {
  html {
    font-size: 14.2px;
    scrollbar-gutter: stable;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: transparent;
  color: #1e293b;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

body.viewport-locked {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 0 !important;
}

body.viewport-locked main {
  height: calc(100vh - var(--header-h, 76px) - var(--nav-h, 60px));
  height: calc(100dvh - var(--header-h, 76px) - var(--nav-h, 60px));
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  overflow: hidden;
}

.oneui-card {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 32px -18px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(15, 23, 42, 0.075);
}

.hide-scroll::-webkit-scrollbar {
  display: none;
}

.hide-scroll {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Bảng cuộn dính tiêu đề cho Báo cáo XNT & Sổ tháng */
.sticky-table {
  border-collapse: separate;
  border-spacing: 0;
}

.sticky-table thead {
  position: sticky;
  top: 0;
  z-index: 20;
}

.sticky-table th,
.sticky-table td {
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.sticky-table th:first-child,
.sticky-table td:first-child {
  border-left: 1px solid #e2e8f0;
}

.sticky-table thead tr:first-child th {
  border-top: 1px solid #475569;
}

.sticky-table thead th {
  border-right-color: #475569;
  border-bottom-color: #475569;
}

/* Tab 2 Lịch sử: Khối từng ngày nổi rõ tách bạch, giao dịch bên trong dạng bảng đường kẻ phẳng */
.history-day-card {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid #cbd5e1;
  border-top: 3px solid #2563eb;
  box-shadow: 0 10px 26px -12px rgba(15, 23, 42, 0.15), 0 2px 6px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.history-day-header {
  background: linear-gradient(135deg, #ffffff 0%, #f1f6ff 100%);
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
}

.history-day-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

.history-day-table thead th {
  background: #f1f5f9;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  border-bottom: 1px solid #cbd5e1;
  border-right: 1px solid #e2e8f0;
  white-space: nowrap;
}

.history-day-table thead th:last-child {
  border-right: none;
}

.history-day-table tbody.history-tx-group {
  border-top: 1px solid #cbd5e1;
  transition: background-color 0.14s ease;
}

.history-day-table tbody.history-tx-group:first-of-type {
  border-top: none;
}

.history-day-table tbody.history-tx-group.is-clickable {
  cursor: pointer;
}

.history-day-table tbody.history-tx-group.is-clickable:hover {
  background-color: #eff6ff;
}

.history-day-table tbody.history-tx-group.is-synthetic {
  background-color: #fffbeb;
}

.history-day-table td {
  padding: 7px 8px;
  border-right: 1px solid #e2e8f0;
  vertical-align: top;
}

.history-day-table td:last-child {
  border-right: none;
}

.history-day-table tr.history-subitem-row td {
  border-top: 1px dashed #e2e8f0;
}

/* Hiệu ứng chuyển tab, xổ form, mở modal mượt mà */
button {
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

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

.tab-enter {
  animation: tabFadeSlide 0.22s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes panelSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.panel-enter {
  animation: panelSlideDown 0.2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes modalBackdropIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalCardIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-backdrop {
  transition: opacity 0.18s ease;
}

.modal-backdrop.is-open {
  animation: modalBackdropIn 0.18s ease both;
}

.modal-backdrop.is-open > div {
  animation: modalCardIn 0.24s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.modal-backdrop.is-closing {
  opacity: 0;
  pointer-events: none;
}

.modal-backdrop.is-closing > div {
  transform: translateY(10px) scale(0.97);
  opacity: 0;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.nav-btn {
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.nav-btn .nav-ico {
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-btn.is-active .nav-ico {
  transform: translateY(-1px) scale(1.12);
}

/* Nút trợ lý AI Agent nổi và ngăn kéo chat */
.ai-fab {
  position: fixed;
  right: 16px;
  bottom: 76px;
  z-index: 45;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 12px 28px -8px rgba(37, 99, 235, 0.52), 0 4px 10px rgba(15, 23, 42, 0.14);
}

.ai-fab:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.ai-msg-user {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
}

.ai-msg-assistant {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 16px 16px 16px 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
