/* Dark Mode Theme with Red #e56e6e Accent */
.afg-dark-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 15px 0;
  box-sizing: border-box;
}

.afg-container.afg-dark {
  width: 100%;
  max-width: 480px;
  background: #0f172a;
  background: linear-gradient(180deg, #1a1e29 0%, #0f131c 100%);
  border: 1px solid rgba(229, 110, 110, 0.22);
  border-radius: 20px;
  padding: 24px 18px;
  box-shadow: 0 20px 45px -15px rgba(0, 0, 0, 0.75), 0 0 25px -5px rgba(229, 110, 110, 0.2);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  color: #f1f5f9;
  text-align: center;
  box-sizing: border-box;
}

.afg-container.afg-dark * {
  box-sizing: border-box;
}

.afg-header {
  margin-bottom: 18px;
}

.afg-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e56e6e;
  background: rgba(229, 110, 110, 0.12);
  border: 1px solid rgba(229, 110, 110, 0.35);
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.afg-title {
  margin: 0 0 6px 0;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.afg-subtitle {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
}

.afg-canvas-card {
  background: #090b10;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid rgba(229, 110, 110, 0.15);
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  margin-bottom: 18px;
}

.afg-canvas-wrapper {
  position: relative;
  width: 100%;
  padding-top: 100%;
  border-radius: 10px;
  overflow: hidden;
  background-color: #0d1117;
  background-image: linear-gradient(45deg, #161b22 25%, transparent 25%), 
                    linear-gradient(-45deg, #161b22 25%, transparent 25%), 
                    linear-gradient(45deg, transparent 75%, #161b22 75%), 
                    linear-gradient(-45deg, transparent 75%, #161b22 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.afg-canvas-wrapper:active {
  cursor: grabbing;
}

.afg-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.afg-placeholder-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 20px;
  pointer-events: none;
  background: radial-gradient(circle, rgba(15, 23, 42, 0.1) 0%, rgba(15, 23, 42, 0.75) 100%);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  transition: opacity 0.3s ease;
}

.afg-pulse-icon {
  background: rgba(229, 110, 110, 0.2);
  border: 1px solid rgba(229, 110, 110, 0.6);
  color: #e56e6e;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  animation: afg-pulse 2s infinite;
}

@keyframes afg-pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(229, 110, 110, 0.5); }
  70% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(229, 110, 110, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(229, 110, 110, 0); }
}

.afg-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.afg-tool-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 10px 14px;
}

.afg-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.afg-slider-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
  min-width: 85px;
}

.afg-slider-label svg {
  color: #e56e6e;
}

.afg-zoom-slider {
  flex: 1;
  height: 6px;
  border-radius: 4px;
  background: #334155;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.afg-zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e56e6e;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(229, 110, 110, 0.85);
  cursor: pointer;
  transition: transform 0.1s ease;
}

.afg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.afg-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.afg-btn:disabled {
  background: #1e293b !important;
  color: #64748b !important;
  border: 1px solid #334155 !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 0.7;
}

.afg-btn-primary {
  background: linear-gradient(135deg, #e56e6e 0%, #c53030 100%);
  color: #ffffff;
  width: 100%;
  box-shadow: 0 4px 15px rgba(229, 110, 110, 0.4);
}

.afg-btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 22px rgba(229, 110, 110, 0.6);
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.afg-action-grid {
  display: flex;
  gap: 10px;
}

.afg-btn-secondary {
  flex: 1;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #475569;
}

.afg-btn-secondary:hover:not(:disabled) {
  background: #334155;
  border-color: #64748b;
}

.afg-btn-success {
  flex: 2;
  background: linear-gradient(135deg, #dc2626 0%, #e56e6e 100%);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4);
}

.afg-btn-success:hover:not(:disabled) {
  box-shadow: 0 6px 22px rgba(229, 110, 110, 0.65);
  filter: brightness(1.1);
}

/* =========================================================
   MODAL LIGHTBOX FULLSCREEN CÂN ĐỐI (FIX TRÀN MÀN HÌNH IPHONE)
   ========================================================= */
.afg-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.afg-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 11, 19, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.afg-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: #131a29;
  border: 1px solid rgba(229, 110, 110, 0.35);
  border-radius: 20px;
  padding: 22px 18px 18px 18px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(229, 110, 110, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: afg-modal-in 0.25s ease-out;
  z-index: 2;
  box-sizing: border-box;
}

@keyframes afg-modal-in {
  from { opacity: 0; transform: scale(0.92) translateY(15px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.afg-modal-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.afg-modal-close:hover {
  color: #ffffff;
}

.afg-modal-header {
  text-align: center;
  margin-bottom: 14px;
}

.afg-modal-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #e56e6e;
  background: rgba(229, 110, 110, 0.15);
  border: 1px solid rgba(229, 110, 110, 0.4);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
}

.afg-modal-title {
  margin: 0 0 6px 0;
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

.afg-modal-desc {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
  line-height: 1.4;
}

.afg-modal-desc strong {
  color: #e56e6e;
}

.afg-modal-img-card {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 1 / 1;
  background: #000;
  border: 2px solid #e56e6e;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(229, 110, 110, 0.35);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.afg-modal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-touch-callout: default !important; /* Cho phép menu lưu ảnh mặc định trên iOS */
  user-select: auto !important;
}

.afg-modal-footer {
  width: 100%;
}

.afg-btn-full {
  width: 100%;
}