/* =========================================================
   HD Diamonds Dental Lab – trang quản trị
   ========================================================= */
:root {
  --brand: #0d4aa6;
  --brand-dark: #0a3478;
  --brand-navy: #06204d;
  --brand-soft: #eaf1fb;
  --line: #e3e9f2;
  --sidebar-w: 250px;
}

body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: .92rem;
  background: #f3f6fb;
  color: #16243a;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-outline-primary {
  color: var(--brand);
  border-color: var(--brand);
}

.btn-outline-primary:hover {
  background: var(--brand);
  border-color: var(--brand);
}

a {
  color: var(--brand);
}

/* ---------- Khung ---------- */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  flex-direction: column;
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand-navy) 0%, #041633 100%);
  color: #fff;
}

aside.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
}

.offcanvas.admin-sidebar {
  width: var(--sidebar-w);
}

.admin-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.admin-brand img {
  height: 44px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: 1rem .75rem;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .9rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
  transition: background .2s ease, color .2s ease;
}

.admin-nav-link i {
  font-size: 1.05rem;
}

.admin-nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, .07);
}

.admin-nav-link.active {
  color: #fff;
  background: var(--brand);
}

.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.admin-page-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

.admin-content {
  padding: 1.5rem;
}

@media (max-width: 575.98px) {
  .admin-content {
    padding: 1rem;
  }
}

/* ---------- Thành phần ---------- */
.admin-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(6, 32, 77, .04);
  overflow: hidden;
}

.admin-card .card-header {
  background: #fff;
  font-weight: 600;
  padding: .9rem 1.25rem;
}

.admin-card .table th {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #5d6b80;
  background: #f8fafd;
  white-space: nowrap;
}

.admin-card .table td,
.admin-card .table th {
  padding: .75rem 1rem;
}

.table-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--brand-soft);
}

.photo-thumb {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: box-shadow .2s ease, transform .2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(6, 32, 77, .08);
}

.stat-card-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1.35rem;
}

.stat-card strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1.1;
}

.stat-card small {
  color: #5d6b80;
}

.admin-tabs .nav-link {
  color: #5d6b80;
  font-weight: 500;
}

.admin-tabs .nav-link.active {
  color: var(--brand);
}

.image-input-box {
  display: flex;
  gap: .9rem;
  align-items: flex-start;
}

.image-input-preview {
  width: 120px;
  height: 90px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--brand-soft);
}

.article-editor {
  min-height: 360px;
  font-size: 1rem;
}

.ql-toolbar.ql-snow {
  border-radius: 10px 10px 0 0;
}

.ql-container.ql-snow {
  border-radius: 0 0 10px 10px;
}

/* ---------- Đăng nhập ---------- */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1rem;
  background:
    radial-gradient(circle at 80% 20%, rgba(59, 140, 240, .25), transparent 50%),
    linear-gradient(140deg, var(--brand-navy) 0%, #0b3270 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 2.25rem 2rem;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
}

.login-logo {
  display: block;
  height: 56px;
  margin: 0 auto 1.25rem;
}

/* ---------- Trang cài đặt website ---------- */
.settings-nav {
  position: sticky;
  top: 80px;
}

.settings-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .85rem;
  color: #3b4a60;
  text-align: left;
  border-radius: 10px;
}

.settings-nav .nav-link.active {
  background: var(--brand);
  color: #fff;
}

.settings-search-icon {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8a97a8;
}

.settings-content.searching .tab-pane {
  display: none;
}

.settings-content.searching .tab-pane.search-hit {
  display: block;
  opacity: 1;
  margin-bottom: 1rem;
}

.content-field .form-label {
  font-weight: 500;
}

.icon-preview {
  min-width: 46px;
  justify-content: center;
  font-size: 1.15rem;
  color: var(--brand);
}

.settings-savebar {
  position: sticky;
  bottom: 0;
  z-index: 1010;
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 1.5rem -1.5rem -1.5rem;
  padding: .85rem 1.5rem;
  background: #fff;
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 18px rgba(6, 32, 77, .05);
}

/* Logo / favicon: hiển thị trọn vẹn, logo trắng đặt trên nền tối */
.image-input-preview.is-logo {
  object-fit: contain;
  padding: .5rem;
  background: #fff;
}

.image-input-preview.on-dark {
  background: var(--brand-navy);
}

/* Bản đồ xem trước trong trang cài đặt */
.map-preview {
  height: 260px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef2f7;
}

.map-preview iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- Chọn tông màu website ---------- */
.theme-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: .6rem;
}

.theme-swatch {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: .5rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  text-align: left;
  transition: border-color .15s ease, transform .15s ease;
}

.theme-swatch:hover {
  transform: translateY(-2px);
  border-color: #c3ccd8;
}

.theme-swatch.active {
  border-color: #16243a;
  box-shadow: 0 0 0 3px rgba(22, 36, 58, .12);
}

.theme-swatch-colors {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  height: 28px;
  overflow: hidden;
  border-radius: 7px;
}

.theme-swatch-name {
  font-size: .78rem;
  font-weight: 600;
  color: #3b4a60;
}

.theme-swatch.active .theme-swatch-name::after {
  content: " ✓";
}

.settings-content.searching .theme-picker {
  display: none;
}

/* Xem trước tông màu (màu lấy từ --p-primary / --p-dark / --p-navy do script gán) */
.theme-preview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: .78rem;
  max-width: 560px;
}

.theme-preview-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem .8rem;
  background: #fff;
  border-bottom: 1px solid #eef1f5;
}

.theme-preview-logo {
  width: 54px;
  height: 14px;
  border-radius: 4px;
  background: var(--p-primary);
}

.theme-preview-menu {
  display: flex;
  gap: .4rem;
  flex: 1;
}

.theme-preview-menu b,
.theme-preview-menu i {
  width: 32px;
  height: 6px;
  border-radius: 3px;
  background: #d5dbe3;
}

.theme-preview-menu b {
  background: var(--p-primary);
}

.theme-preview-pill {
  padding: .2rem .6rem;
  border-radius: 999px;
  background: var(--p-primary);
  color: #fff;
  font-weight: 600;
}

.theme-preview-body {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  padding: .9rem .8rem;
  background: linear-gradient(110deg, #fff 0%, color-mix(in srgb, var(--p-primary) 9%, white) 100%);
}

.theme-preview-eyebrow {
  color: var(--p-primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .68rem;
}

.theme-preview-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--p-navy);
}

.theme-preview-title em {
  font-style: normal;
  color: var(--p-primary);
}

.theme-preview-btn {
  padding: .3rem .8rem;
  border-radius: 999px;
  background: var(--p-primary);
  border: 1px solid var(--p-primary);
  color: #fff;
  font-weight: 600;
}

.theme-preview-btn.outline {
  background: #fff;
  color: var(--p-primary);
}

.theme-preview-footer {
  padding: .6rem .8rem;
  background: linear-gradient(160deg, var(--p-navy) 0%, color-mix(in srgb, var(--p-navy) 70%, black) 100%);
  color: rgba(255, 255, 255, .8);
}

/* ---------- Thành phần Bootstrap theo màu thương hiệu ---------- */
.text-primary {
  color: var(--brand) !important;
}

.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: color-mix(in srgb, var(--brand) 50%, white);
  box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 25%, transparent);
}

.page-link {
  color: var(--brand);
}

.page-item.active .page-link {
  background-color: var(--brand);
  border-color: var(--brand);
}

.btn-outline-primary:active,
.btn-check:checked + .btn-outline-primary {
  background-color: var(--brand-dark);
  border-color: var(--brand-dark);
}

/* ---------- Ô chọn ảnh: khung xem trước đúng tỉ lệ + kiểm tra kích thước ---------- */
.image-frame {
  position: relative;
  flex-shrink: 0;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef1f5;
}

.image-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Logo, favicon: hiện trọn ảnh trên nền caro để thấy rõ phần trong suốt */
.image-frame.is-contain {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #f0f2f5 25%, transparent 25%), linear-gradient(-45deg, #f0f2f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f2f5 75%), linear-gradient(-45deg, transparent 75%, #f0f2f5 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
}

.image-frame.is-contain img {
  object-fit: contain;
  padding: 6px;
}

.image-frame.on-dark {
  background: var(--brand-navy);
}

.image-spec {
  margin-bottom: .4rem;
  font-size: .82rem;
  color: #3b4a60;
}

.image-spec .bi {
  color: var(--brand);
}

.image-check {
  margin-top: .4rem;
  font-size: .8rem;
  line-height: 1.45;
}

.image-check:empty {
  display: none;
}

.image-check-summary {
  color: #3b4a60;
}

.image-check-ok { color: #198754; }
.image-check-info { color: #0b6b8a; }
.image-check-warn { color: #9a6700; }
.image-check-error { color: #b42318; font-weight: 600; }

.min-w-0 {
  min-width: 0;
}

/* Cột hẹp (form sản phẩm, bài viết): phần chữ xuống dưới khung ảnh */
.image-input-box {
  flex-wrap: wrap;
}

.image-input-box > .flex-grow-1 {
  min-width: 220px;
}
/* ---------- Sơ đồ chọn răng (hệ FDI) ---------- */
.tooth-picker {
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafbfd;
  overflow-x: auto;
}

.tooth-picker-sides,
.tooth-picker-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .75rem;
  color: #6b778a;
  padding-left: 72px;
}

.tooth-picker-actions {
  margin-top: .4rem;
}

.tooth-row {
  display: grid;
  grid-template-columns: 64px 1fr 1fr;
  align-items: center;
  min-width: 520px;
}

.tooth-row + .tooth-row .tooth-quadrant {
  border-top: 2px solid #16243a;
}

.tooth-row-name {
  font-size: .75rem;
  font-weight: 600;
  color: #3b4a60;
}

.tooth-quadrant {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  padding: 6px;
}

.tooth-quadrant:first-of-type {
  border-right: 2px solid #16243a;
}

.tooth {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .3rem 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  line-height: 1.1;
  color: #16243a;
  transition: all .15s ease;
}

.tooth small {
  font-size: .62rem;
  font-weight: 500;
  color: #8a97a8;
}

.tooth:hover {
  border-color: var(--brand);
}

.tooth.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.tooth.active small {
  color: rgba(255, 255, 255, .8);
}

/* ---------- Nhập Excel ---------- */
.step-badge {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: .35rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
}

.import-preview {
  max-height: 560px;
}

.import-preview thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.text-warning-dark { color: #9a6700; }
.text-info-dark { color: #0b6b8a; }

/* Đã có kết quả xem trước: khung tải file thu gọn thành 1 hàng */
@media (min-width: 992px) {
  .import-upload-compact {
    display: grid;
    grid-template-columns: 1fr auto 1.4fr;
    gap: 1rem 1.5rem;
    align-items: center;
  }

  .import-upload-compact > p,
  .import-upload-compact > hr {
    display: none;
  }

  .import-upload-compact form {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
  }

  .import-upload-compact form > * {
    margin: 0 !important;
  }

  .import-upload-compact form .form-control {
    flex: 1;
    min-width: 200px;
  }

  .import-upload-compact form .btn {
    width: auto !important;
  }

  .import-upload-compact form .form-text {
    flex-basis: 100%;
  }
}
