/* ===== WC Engraving Popup Styles ===== */

/* --- Trigger Button --- */
.engraving-btn-wrapper {
  margin-top: 12px;
}

.engraving-trigger-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  background: #fff !important;
  color: #1a1a1a !important;
  border: 1.5px solid #1a1a1a !important;
  padding: 10px 20px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  border-radius: 6px !important;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.engraving-trigger-btn:hover {
  background: #1a1a1a !important;
  color: #fff !important;
}

/* --- Overlay --- */
.engraving-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
}

.engraving-overlay.is-open {
  display: flex !important;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity:0 } to { opacity:1 } }

/* --- Popup Box --- */
.engraving-popup {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: slideUp 0.25s ease;
}

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

/* --- Header --- */
.engraving-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #f0f0f0;
  flex-shrink: 0;
}

.engraving-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
}

.engraving-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #888;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.engraving-close:hover { background: #f5f5f5; color: #1a1a1a; }

/* --- Body --- */
.engraving-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* --- Tabs --- */
.engraving-tabs {
  display: flex;
  border-bottom: 1px solid #f0f0f0;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.engraving-tabs::-webkit-scrollbar { display: none; }

.eng-tab {
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: #888;
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.eng-tab:hover { color: #1a1a1a; }
.eng-tab.active { color: #c9a84c; border-bottom-color: #c9a84c; }

/* --- Panels --- */
.eng-panel { display: none; padding: 20px 24px; }
.eng-panel.active { display: flex; flex-direction: column; gap: 16px; }

/* --- Preview --- */
.eng-preview-wrap {
  display: flex;
  justify-content: center;
}

.eng-preview {
  background: linear-gradient(135deg, #f8f8f8, #efefef);
  border: 1px dashed #ddd;
  border-radius: 10px;
  padding: 20px 28px;
  min-height: 80px;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: serif;
}

.prev-line1 {
  font-size: 18px;
  font-weight: 700;
  color: #555;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.prev-line1.prev-serif {
  font-family: Georgia, serif;
  font-style: italic;
}

.prev-line2 {
  font-size: 13px;
  color: #888;
}

.prev-icon {
  font-size: 22px;
  margin-bottom: 4px;
}

.prev-sport-icon {
  font-size: 28px;
}

.prev-logo img { max-height: 40px; opacity: 0.5; }

/* --- Fields --- */
.eng-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.eng-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.eng-field label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
}

.eng-hint {
  font-weight: 400;
  color: #aaa;
  font-size: 12px;
  margin-left: 4px;
}

.eng-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.eng-input {
  width: 100%;
  padding: 10px 44px 10px 12px !important;
  border: 1.5px solid #e0e0e0 !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  transition: border-color 0.15s !important;
  box-sizing: border-box;
  outline: none !important;
}

.eng-input:focus {
  border-color: #c9a84c !important;
  box-shadow: 0 0 0 3px rgba(201,168,76,0.12) !important;
}

.eng-counter {
  position: absolute;
  right: 10px;
  font-size: 11px;
  color: #bbb;
  pointer-events: none;
}

/* --- Upload Area --- */
.eng-upload-area {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eng-upload-area:hover {
  border-color: #c9a84c;
  background: rgba(201,168,76,0.04);
}

.eng-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.eng-upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #aaa;
  font-size: 13px;
  pointer-events: none;
}

.eng-logo-thumb {
  max-height: 60px;
  max-width: 100%;
  border-radius: 4px;
  object-fit: contain;
}

/* --- Wedding Templates --- */
.eng-wedding-templates {
  margin-bottom: 8px;
}

.eng-template-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
}

.eng-template-item {
  aspect-ratio: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 6px;
  background: #fafafa;
  font-size: 11px;
  color: #666;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eng-template-item:hover { border-color: #c9a84c; }
.eng-template-item.active { border-color: #c9a84c; background: rgba(201,168,76,0.1); color: #b8962a; }

/* --- Icon Group (Birthday) --- */
.eng-icon-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.eng-icon-btn {
  width: 44px;
  height: 44px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  background: #fafafa;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.eng-icon-btn:hover { border-color: #c9a84c; }
.eng-icon-btn.active { border-color: #c9a84c; background: rgba(201,168,76,0.1); }

/* --- Sport Group --- */
.eng-sport-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.eng-sport-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  background: #fafafa;
  font-size: 11px;
  color: #555;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.15s, background 0.15s;
}

.eng-sport-btn .sport-icon { font-size: 18px; }
.eng-sport-btn:hover { border-color: #c9a84c; }
.eng-sport-btn.active { border-color: #c9a84c; background: rgba(201,168,76,0.1); color: #b8962a; }

/* --- Footer --- */
.engraving-footer {
  border-top: 1px solid #f0f0f0;
  padding: 20px 24px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.eng-price-summary {
  background: #fafafa;
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.eng-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #555;
}

.eng-highlight {
  color: #c9a84c;
  font-weight: 500;
}

.eng-total {
  font-weight: 700;
  font-size: 16px;
  color: #1a1a1a;
  border-top: 1px solid #eee;
  padding-top: 6px;
  margin-top: 2px;
}

.eng-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #aaa;
  font-style: italic;
}

.eng-qty-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
}

.eng-qty-control {
  display: flex;
  align-items: center;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.eng-qty-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #f5f5f5;
  font-size: 18px;
  cursor: pointer;
  color: #555;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.eng-qty-btn:hover { background: #ebebeb; }

.eng-qty-input {
  width: 48px;
  height: 36px;
  border: none;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
  -moz-appearance: textfield;
}

.eng-qty-input::-webkit-outer-spin-button,
.eng-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }

.eng-add-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px !important;
  background: #e8a020 !important;
  color: #fff !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  border: none !important;
  border-radius: 10px !important;
  cursor: pointer;
  transition: background 0.2s;
}

.eng-add-btn:hover { background: #d4901a !important; }

.eng-add-btn:disabled {
  background: #ddd !important;
  cursor: not-allowed;
}

.eng-cart-message {
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  font-size: 14px;
}

.eng-cart-message.success {
  background: #f0fff4;
  color: #2d7a4a;
  border: 1px solid #b7e4c7;
}

.eng-cart-message.error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #fed7d7;
}

/* --- Scrollbar within body --- */
.engraving-body::-webkit-scrollbar { width: 4px; }
.engraving-body::-webkit-scrollbar-track { background: transparent; }
.engraving-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* --- Responsive --- */
@media (max-width: 480px) {
  .engraving-popup { max-height: 95vh; border-radius: 16px 16px 0 0; }
  .engraving-overlay { align-items: flex-end; padding: 0; }
  .eng-template-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ── Image Swatch ─────────────────────────────────────── */
.eng-image-swatch-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.eng-swatch-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  width: 80px;
  text-align: center;
}

.eng-swatch-btn img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
}

.eng-swatch-label {
  font-size: 11px;
  line-height: 1.3;
  color: #555;
  word-break: break-word;
  max-width: 72px;
}

.eng-swatch-check {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: #0073aa;
  color: #fff;
  border-radius: 50%;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
}

.eng-swatch-btn:hover {
  border-color: #0073aa;
  box-shadow: 0 0 0 2px rgba(0,115,170,.15);
}

.eng-swatch-btn.active {
  border-color: #0073aa;
  box-shadow: 0 0 0 3px rgba(0,115,170,.2);
}

.eng-swatch-btn.active .eng-swatch-check {
  display: block;
}

/* Nút mở popup bị disabled khi chưa chọn biến thể */
#open-engraving-popup:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: auto; /* giữ để title tooltip hiện được */
}
