/* Popup CHỌN ẢNH CHO THIỆP — mobile bottom sheet + desktop panel theo Figma. */
:root {
  --gc-ip-deep: var(--qz-green-dark, #05783b);
  --gc-ip-green: var(--qz-green, #079b4e);
  --gc-ip-yellow: var(--qz-yellow, #ffc43d);
  --gc-ip-cream: var(--qz-cream, #fff3df);
}

/* Dialog modal (giữ focus trap + Esc) nhưng đặt khớp khung ngôi nhà: JS đo `.qz-card` và ghi
   --gc-ip-x/y/w/h khi mở. Sheet trượt từ đáy nhà lên, bị cắt theo bo góc nhà. Không có `.qz-card`
   (trang khác) thì biến trống và dialog phủ cả màn hình như cũ. */
.gc-ip {
  position: fixed;
  inset: auto;
  left: var(--gc-ip-x, 0);
  top: var(--gc-ip-y, 0);
  width: var(--gc-ip-w, 100vw);
  max-width: none;
  height: var(--gc-ip-h, 100dvh);
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--gc-ip-r, 0);
  background: transparent;
  overflow: hidden;
  /* Dialog bo góc + overflow hidden mà con trượt bằng transform thì Safari iOS hay nháy mép; isolation tách lớp cắt. */
  isolation: isolate;
}

/* Dialog đóng vẫn được dựng (bố cục, giải mã ảnh, layer của sheet) nhưng ẩn bằng visibility: mặc định `display: none`
   khiến toàn bộ việc đó dồn vào khung hình đầu tiên lúc mở và làm animation trượt khựng. visibility: hidden cũng loại
   nội dung khỏi thứ tự Tab và cây truy cập nên không ảnh hưởng người dùng. */
.gc-ip:not([open]) {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
}

.gc-ip[open] {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Không tối cả trang: chỉ phủ tối đúng khung ngôi nhà (hình chữ nhật bo góc của .qz-card, kể cả phần mái). */
.gc-ip::backdrop {
  background: transparent;
}

.gc-ip::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

/* Lớp tối mờ dần bằng CSS, bắt đầu cùng khung hình với lúc dialog hiện. Trước đây JS chạy animate() sau 2 khung hình
   nên lớp tối hiện đủ độ tối, bật về trong suốt rồi mới mờ dần: nhìn như bị chớp/khựng. */
.gc-ip[open]::before {
  animation: gc-ip-fade-in 320ms ease-out both;
}

.gc-ip.is-closing::before {
  animation: gc-ip-fade-out 320ms ease-in both;
}

@keyframes gc-ip-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes gc-ip-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .gc-ip[open]::before,
  .gc-ip.is-closing::before {
    animation: none;
  }
}

.gc-ip__sheet {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px; /* 12px làm lưới 6 ảnh tràn 2px trong sheet cao 497px (mobile) → hàng ảnh dưới bị cắt */
  width: 100%;
  max-height: min(88dvh, 497px);
  padding: 16px 10px 10px;
  overflow: hidden;
  background: var(--gc-ip-cream);
  border-radius: 16px 16px 0 0;
  color: var(--gc-ip-deep);
  font-family: 'Poppins', sans-serif;
  /* Drawer: chuyển động do ImagePickerPopup.js điều khiển bằng Web Animations (đặt sheet ngoài đáy, chờ bố cục
     xong mới trượt lên) nên CSS không khai transform/transition ở đây. */
  will-change: transform;
  backface-visibility: hidden;
  position: relative; /* nằm trên lớp tối ::before */
}

.gc-ip__handle {
  flex: none;
  width: 42px;
  height: 5px;
  border-radius: 18px;
  background: #d9d9d9;
}

.gc-ip__heading {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.gc-ip__title,
.gc-ip__subtitle,
.gc-ip__count,
.gc-ip__preview-text {
  margin: 0;
}

.gc-ip__title {
  color: var(--gc-ip-deep);
  font-size: 18px;
  font-weight: 700;
  line-height: 27px;
  text-align: center;
  text-transform: uppercase;
}

.gc-ip__subtitle {
  color: var(--gc-ip-deep);
  font-size: 14px;
  font-weight: 500;
  line-height: 21px;
  text-align: center;
}

.gc-ip__grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(5, 120, 59, 0.45) transparent;
}

.gc-ip__cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 149 / 106;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.gc-ip__cell img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.gc-ip__cell--hidden {
  display: none;
}

.gc-ip__cell.is-selected img {
  border: 3px solid var(--gc-ip-yellow);
}

.gc-ip__check {
  position: absolute;
  top: 4px;
  left: 4px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 9999px;
  background: var(--gc-ip-green);
}

.gc-ip__cell.is-selected .gc-ip__check {
  display: flex;
}

.gc-ip__cell:focus-visible {
  outline: 2px solid var(--gc-ip-deep);
  outline-offset: 2px;
}

.gc-ip__bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 40px;
}

.gc-ip__count {
  color: var(--gc-ip-deep);
  font-size: 14px;
  font-weight: 400;
  line-height: 21px;
}

.gc-ip__more {
  flex: none;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--gc-ip-deep);
  border-radius: 9999px;
  background: transparent;
  color: var(--gc-ip-deep);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 21px;
  cursor: pointer;
}

.gc-ip__more[hidden] {
  display: none;
}

.gc-ip__preview {
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
  box-sizing: border-box;
  width: 100%;
  min-height: 84px;
  padding: 2px;
  border-radius: 8px;
  background: rgba(32, 168, 92, 0.2);
}

.gc-ip__preview-img {
  flex: none;
  width: 128px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
}

.gc-ip__preview-text {
  color: var(--gc-ip-deep);
  font-size: 13px;
  font-weight: 600;
  line-height: 20px;
}

.gc-ip__confirm {
  flex: none;
  min-width: 186px;
  min-height: 48px;
  padding: 12px 24px;
  border: 1.5px solid #fff;
  border-radius: 41px;
  background: var(--gc-ip-yellow);
  color: var(--gc-ip-deep);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  cursor: pointer;
}

@media (min-width: 601px) {
  /* Rộng bằng ngôi nhà, dính đáy: bo góc dưới do dialog (bo 20px, overflow hidden) cắt. */
  .gc-ip__sheet {
    width: 100%;
    max-height: min(90%, 549px);
    padding: 16px 12px 12px;
    border: 2px solid var(--gc-ip-green);
    border-radius: 20px;
  }
}


