@charset "UTF-8";

/* ==== BASE & RESET ==== */
body {
  background: #f5f6fa;
  min-height: 100vh;
  margin: 0;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  color: #222;
}

h1 {
  text-align: center;
  font-size: 1.3em;
  margin-bottom: 18px;
  letter-spacing: 1px;
}

h2 {
  font-size: 1.14em;
  margin: -10px -16px 20px -16px;
  padding: 15px 0 14px 0;
  border-bottom: 2.5px solid #e3f0fd;
  color: #1675c1;
  background: linear-gradient(90deg, #eaf5fe 0 20%, #fff 100%);
  border-radius: 12px 12px 0 0;
  font-weight: 700;
  letter-spacing: .4px;
  box-shadow: 0 2px 8px #00f2fe09;
  text-align: center;
}

/* ==== CARD ==== */
.card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 12px #0002;
  padding: 20px 16px;
  margin-bottom: 32px;
  position: relative;
  transition: box-shadow 0.14s;
}

/* ==== UPLOAD ==== */
.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
#facePreview {
  width: 120px; height: 160px;
  object-fit: cover;
  border-radius: 14px;
  box-shadow: 0 2px 8px #0002;
  border: 2.5px solid #e0e0e0;
  margin-bottom: 5px;
  background: #fafbfc;
}

/* ==== BUTTONS ==== */
.big-btn {
  display: block;
  width: 95%;
  max-width: 320px;
  padding: 14px 0;
  font-size: 0.8em;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  color: #fff; 
  border: none; 
  border-radius: 10px;
  font-weight: bold;
  letter-spacing: .5px;
  margin: 12px auto 8px auto;  /* căn giữa theo chiều ngang */
  box-shadow: 0 1px 4px #00f2fe40;
  transition: background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.big-btn.download-btn {
  background: linear-gradient(90deg, #1fd1f9 0%, #b621fe 100%);
  box-shadow: 0 2px 16px #b621fe25;
}
.big-btn:hover,
.big-btn.download-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 18px #00f2fe40;
}

.big-btn:active { background: linear-gradient(90deg, #00f2fe 0%, #4facfe 100%);}
.small-btn {
  font-size: 0.85em; padding: 6px 14px; border-radius: 7px;
  border: none; background: #ececec; color: #222;
  margin: 0 0 4px 0;
}
.small-btn.danger { background: #fa5252; color: #fff;}
.small-btn.danger:active { background: #c92a2a;}

.big-btn-re {
  display: block;
  width: 100%;
  max-width: 350px;
  padding: 14px 25px;
  font-size: 0.8em;
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
  color: #fff; 
  border: none; 
  border-radius: 10px;
  font-weight: bold;
  letter-spacing: .5px;
  margin: 12px auto 8px auto;  /* căn giữa theo chiều ngang */
  box-shadow: 0 1px 4px #00f2fe40;
  transition: background 0.2s, box-shadow 0.2s;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}
.big-btn-re.download-btn-re {
  background: linear-gradient(90deg, #1fd1f9 0%, #b621fe 100%);
  box-shadow: 0 2px 16px #b621fe25;
}
.big-btn-re:hover,
.big-btn-re.download-btn-re:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 18px #00f2fe40;
}

.big-btn-re:active { background: linear-gradient(90deg, #00f2fe 0%, #4facfe 100%);}
.small-btn-re {
  font-size: 0.85em; padding: 6px 14px; border-radius: 7px;
  border: none; background: #ececec; color: #222;
  margin: 0 0 4px 0;
}
.big-btn[disabled], .big-btn.disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ==== TEMPLATE BLOCKS ==== */
.template-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.group-block {
  margin-bottom: 10px;
  border-radius: 12px;
  box-shadow: 0 1.5px 8px #cce6ff18;
  background: #fafdff;
  border: 1.5px solid #e3f0fd;
  padding-bottom: 8px;
  transition: box-shadow 0.12s;
}
.group-title {
  font-size: 1.08em;
  font-weight: bold;
  color: #2490fa;
  margin: 7px 0 8px 0;
  letter-spacing: .3px;
  background: linear-gradient(90deg, #f2fbff 75%, #f5f6fa 100%);
  padding: 8px 22px 8px 13px;
  border-left: 5px solid #47c1f7;
  border-radius: 9px;
  box-shadow: 0 2px 8px #00f2fe0b;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.group-title.open {
  background: linear-gradient(90deg, #e3f0fd 80%, #f5f6fa 100%);
  color: #1476d6;
  border-left-color: #1e88e5;
}
.group-title .arrow {
  font-size: 1.15em;
  transition: transform 0.18s;
  margin-right: 2px;
}
.group-title:hover, .group-title:focus {
  background: linear-gradient(90deg, #d1e9fc 70%, #e3f0fd 100%);
  color: #1971c2;
}

/* ==== TEMPLATES GRID ==== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(5, 85px);
  grid-auto-flow: column;
  gap: 10px;
  max-width: 330px; /* 5*85 + 4*10 */
  overflow-x: auto;
  overflow-y: hidden;
  background: #f8fafb;
  border-radius: 8px;
  margin-bottom: 2px;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.template {
  display: flex; justify-content: center; align-items: center;
}
.template img {
  width: 80px; height: 80px; object-fit: contain;
  border-radius: 8px;
  border: 2.5px solid #eee;
  background: #f8fafb;
  transition: border 0.14s, box-shadow 0.12s;
  cursor: pointer;
}
.template img:hover, .template.selected img {
  border: 2.5px solid #4facfe;
  box-shadow: 0 2px 10px #4facfe55;
}

/* ==== RESULT ==== */
#result-row {
  display: flex;
  gap: 32px;
  justify-content: center;
  align-items: flex-start;
  margin-bottom: 8px;
}
.result-col {
  flex: 1 1 0;
  min-width: 210px;
  max-width: 350px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fafdff;
  border-radius: 13px;
  box-shadow: 0 1.5px 8px #cce6ff11;
  border: 1.5px solid #e3f0fd;
  padding: 12px 8px 13px 8px;
  margin-bottom: 6px;
}
.result-title {
  font-weight: bold;
  margin-bottom: 9px;
  color: #1976d2;
  font-size: 1.08em;
  letter-spacing: .15px;
  text-shadow: 0 1px 2px #e3f0fd;
  padding-bottom: 4px;
  border-bottom: 1.5px dashed #b7e2ff;
  width: 96%;
  text-align: center;
  margin-top: 2px;
}
.result-img {
  width: 98%;
  max-width: 320px;
  max-height: 330px;
  border-radius: 15px;
  margin-bottom: 11px;
  box-shadow: 0 2px 10px #00f2fe26;
  background: #fff;
  object-fit: contain;
  display: block;
  border: 2px solid #e3f0fd;
}

/* ==== ACTION ROW ==== */
.action-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  margin: 24px 0 10px 0;
  width: 100%;
  max-width: 830px;
}
.merge-btn-wrapper {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
}
.merge-btn-wrapper .big-btn {
  max-width: 420px;
  font-size: 1em;
  padding: 10px 0;
  box-shadow: 0 2px 16px #00f2fe22;
}
.bg-choose-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  justify-content: center;
  background: #fafdff;
  border-radius: 12px;
  padding: 13px 8px;
  margin: 0 auto 24px auto;
  max-width: 640px;
  box-shadow: 0 1.5px 8px #cce6ff13;
  border: 1.5px solid #e3f0fd;
}
.bg-title {
  font-weight: bold;
  margin-right: 10px;
  color: #177fdc;
  font-size: 1.05em;
}
.bg-option {
  display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 1em;
}
.bg-color {
  display: inline-block; width: 22px; height: 22px; border-radius: 7px; border:1.5px solid #ddd; margin-right:4px;
  box-shadow: 0 2px 7px #00f2fe09;
}
.bg-white { background: #fff; }
.bg-blue { background: #2e78fa; border-color: #1976d2; }
.bg-black { background: #23252b; border-color: #000; }
.bg-upload { background: linear-gradient(135deg, #f4f7ff 65%, #dbf1f7 100%); border:1.5px dashed #258; }
.bg-option input[type="radio"] { accent-color: #1976d2; }

/* ==== MODALS ==== */
#cropModal {
  position: fixed; left:0; top:0; width:100vw; height:100vh;
  background: #fff;
  z-index: 1000; display: none;
  align-items: center; justify-content: center; flex-direction:column;
  box-shadow: 0 0 0 100vw #0005;
}
#cropModal img { max-width:88vw; max-height:60vh; border-radius:10px; }
#cropBtn { margin-top:14px; width: 90%; max-width:220px; }

/* ==== HEADER ==== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background-image: url('../../assets/img/header-bg.gif');
  background-color: #FFFF33; /* fallback nếu không có ảnh */
  background-size: cover;
  background-position: center;
  border-radius: 0 0 18px 18px;
  box-shadow: 0 4px 16px #00f2fe18;
  margin-bottom: 16px;
  min-height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 13px;
}
.logo {
  height: 38px;
  width: 38px;
  border-radius: 10px;
  object-fit: cover;
  background: #f5f6fa;
  box-shadow: 0 2px 8px #e0e0e0;
}
.site-title {
  font-size: 1.24em;
  font-weight: bold;
  color: #FFFF00;
	text-shadow: 2px 2px royalblue;
  letter-spacing: .6px;
  font-family: 'Segoe UI', 'Arial', sans-serif;
  margin-top: 3px;
}
.backhome-btn {
  background: linear-gradient(90deg, #00f2fe 0%, #4facfe 100%);
  color: #FFFF66;
	text-shadow: 1px 2px royalblue;
  font-weight: bold;
  padding: 9px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 1em;
  box-shadow: 0 2px 8px #4facfe15;
  transition: background 0.18s;
}
.backhome-btn:active {
  background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
}

/* ==== PREVIEW ==== */
#hairPreviewBox img, #clothPreviewBox img {
  margin-top: 4px;
  box-shadow: 0 1px 6px #4facfe1a;
}
#hairPreviewBox, #clothPreviewBox {
  min-height: 40px;
}

/* ==== RESPONSIVE ==== */
@media (max-width: 1200px) {
  .mobile-container, .main-wrapper { max-width: 100vw !important; }
}
@media (max-width: 900px) {
  #result-row { flex-direction: column; gap: 18px; }
  .result-col { max-width: 98vw; }
  .merge-btn-wrapper .big-btn { width: 100vw; }
}
@media (max-width: 800px) {
  .main-wrapper {
    flex-direction: column;
    gap: 18px;
    margin-bottom: 16px;
    margin-top: 10px;
    max-width: 99vw;
  }
  .merge-btn-wrapper { margin: 23px 0 12px 0; }
  .action-row {
    flex-direction: column;
    align-items: stretch;
    gap: 13px;
    margin: 18px 0 10px 0;
    max-width: 99vw;
  }
  .bg-choose-wrapper {
    max-width: 99vw;
    min-width: 0;
    padding: 10px 7vw 12px 7vw;
  }
}

/* ==== MAIN WRAPPER Bố cục 3 cột các bước ==== */
/* Bọc ngoài main-wrapper căn giữa trang */
.row-center, .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.main-wrapper {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  margin: 24px auto 36px auto;
  width: 100%;
  max-width: 1200px;
  box-sizing: border-box;
}

/* ==== CARD từng bước: Chia đều, giới hạn kích thước, bỏ margin dưới ==== */
.card.step1,
.card.step-hair,
.card.step2 {
  flex: 1 1 0;
  min-width: 300px;
  max-width: 350px;
  margin: 0; /* bỏ margin để gap hoạt động */
  align-self: stretch; /* chiều cao đều nhau nếu muốn */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center; /* Căn nội dung vào giữa card */
}

.card {
  margin-bottom: 0; /* bỏ margin dưới, dùng gap ngoài */
}
.action-row, #result-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
  margin: 24px auto 24px auto;
  width: 100%;
  max-width: 1100px;
  box-sizing: border-box;
}
/* Card cuối không margin phải nếu cần */
.main-wrapper .card.step2 {
  margin-right: 0 !important;
}

/* ==== Responsive: về lại dọc trên mobile/tablet ==== */
@media (max-width: 1100px) {
  .main-wrapper {
    flex-direction: column;
    gap: 18px;
    max-width: 98vw;
  }
  .card.step1, .card.step-hair, .card.step2 {
    max-width: 98vw;
    min-width: 0;
    margin-bottom: 18px;
  }
}

@media (max-width: 700px) {
  .page-header {
    flex-direction: column;
    gap: 7px;
    align-items: flex-start;
    padding: 10px 7vw;
  }
  .header-left {
    gap: 7px;
  }
  .site-title { font-size: 1.09em; }
  .backhome-btn { padding: 8px 20px; font-size: .98em; }
}
@media (max-width: 600px) {
  h2 { font-size: 1em; margin: -8px -5px 16px -5px; padding: 10px 0 9px 0;}
  .templates-grid {
    grid-auto-rows: 64px;
    max-height: 138px;
    gap: 7px;
  }
  .template img { width: 100%; height: 100%; }
  .result-col { padding: 6px 1vw 11px 1vw; }
  .card { padding: 13px 5px; }
}
.small-btn {
  padding: 5px 14px;
  font-size: 1em;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #1e88e5;
  color: #fff;
  margin-left: 7px;
}
.small-btn:hover { filter: brightness(1.1);}

/* Tooltip */
.btn-tooltip-wrap {
  position: relative;
  display: inline-block;
}
.btn-tooltip-wrap .tooltip-text {
  visibility: hidden;
  background: #23252b;
  color: #fff;
  font-size: 0.95em;
  padding: 7px 14px;
  border-radius: 7px;
  position: absolute;
  left: 50%; top: 100%;
  transform: translateX(-50%);
  white-space: nowrap;
  margin-top: 7px;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 99;
  pointer-events: none;
}
.btn-tooltip-wrap:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

.frame-btn {
  background: linear-gradient(90deg, #fb2020 0%, #ff9797 100%);
  color: #fffb00 !important;
  border-radius: 10px;
  padding: 12px 32px;
  font-size: 1em;
  font-weight: bold;
  margin-left: 10px;
  box-shadow: 0 2px 8px #43a04733;
  border: none;
  outline: none;
  display: inline-block;
  transition: background 0.18s, box-shadow 0.18s;
  text-decoration: none;
  letter-spacing: .2px;
  cursor: pointer;
}
.frame-btn:hover, .frame-btn:focus {
  background: linear-gradient(90deg, #f82e2e 0%, #f96a6a 100%);
  box-shadow: 0 4px 18px #43a04744;
  text-decoration: none;
  color: #fff;
}

#imgZoomPopup {
  display: none;
  position: fixed;
  left:0; top:0;
  width:100vw; height:100vh;
  z-index: 9999;
  background: rgba(0,0,0,0.38);
  align-items: center;
  justify-content: center;
  animation: fadeIn .15s;
}
#imgZoomPopup img {
  border-radius: 16px;
  box-shadow: 0 4px 28px #0007;
  max-width: 92vw;
  max-height: 88vh;
  background: #fff;
}
@keyframes fadeIn {
  from { opacity: 0 }
  to { opacity: 1 }
}

/* Responsive: về cột khi nhỏ */
@media (max-width: 1100px) {
  .main-wrapper, .action-row, #result-row {
    flex-direction: column;
    align-items: center;
    gap: 18px;
    max-width: 98vw;
  }
  .card.step1, .card.step-hair, .card.step2 {
    max-width: 98vw;
    min-width: 0;
  }
}

@media (max-width: 600px) {
  .card, .result-col, .bg-choose-wrapper {
    max-width: 97vw !important;
  }
  .main-wrapper, .action-row, #result-row {
    padding: 0 1vw;
  }
}