/* AI Studio — generation flow, overlay, confirm & place order */

.ai-preview {
  position: relative;
}

.ai-preview-content {
  width: 100%;
  min-height: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-preview-content img {
  max-width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
}

/* ── Premium generation overlay ── */
.ai-gen-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background: linear-gradient(160deg, rgba(20, 12, 45, 0.94) 0%, rgba(45, 27, 105, 0.92) 50%, rgba(20, 12, 45, 0.94) 100%);
  border-radius: inherit;
  text-align: center;
  color: #fff;
}

.ai-gen-overlay.active {
  display: flex;
  animation: aiFlowFadeIn 0.35s ease;
}

@keyframes aiFlowFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ai-gen-orb {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 20px;
}

.ai-gen-orb::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 215, 0, 0.25);
  animation: aiGenRing 2s ease-in-out infinite;
}

.ai-gen-orb::after {
  content: '';
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8868c9, #6542a9);
  animation: aiGenPulse 1.8s ease-in-out infinite;
  box-shadow: 0 0 30px rgba(136, 104, 201, 0.5);
}

.ai-gen-orb i {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  color: #ffd700;
  z-index: 1;
  animation: aiGenIcon 2.5s ease-in-out infinite;
}

@keyframes aiGenRing {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.12); opacity: 1; }
}

@keyframes aiGenPulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1; }
}

@keyframes aiGenIcon {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.08) rotate(8deg); }
}

.ai-gen-status {
  margin: 0 0 16px;
  font-size: 0.95rem;
  font-weight: 600;
  max-width: 280px;
  line-height: 1.45;
}

.ai-gen-bar {
  width: min(240px, 80%);
  height: 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
  margin-bottom: 14px;
}

.ai-gen-bar span {
  display: block;
  height: 100%;
  width: 35%;
  border-radius: 4px;
  background: linear-gradient(90deg, #8868c9, #ffd700);
  animation: aiGenBar 1.6s ease-in-out infinite;
}

@keyframes aiGenBar {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}

.ai-gen-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.8;
}

.ai-gen-steps li.active {
  color: #ffd700;
  font-weight: 600;
}

/* ── Result flow panels ── */
.ai-result-flow {
  margin-top: 16px;
  animation: aiFlowSlideUp 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.ai-result-flow.d-none { display: none !important; }

@keyframes aiFlowSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-flow-card {
  border-radius: 16px;
  padding: 18px;
  border: 1px solid var(--ai-glass-border, rgba(136, 104, 201, 0.22));
  background: var(--ai-glass, rgba(255, 255, 255, 0.72));
}

body.dark-mode .ai-flow-card {
  background: rgba(30, 30, 42, 0.9);
  border-color: rgba(136, 104, 201, 0.35);
}

.ai-flow-success {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border-color: rgba(74, 222, 128, 0.35);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.1), rgba(136, 104, 201, 0.06));
}

body.dark-mode .ai-flow-success {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.12), rgba(30, 30, 42, 0.9));
}

.ai-flow-success-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(74, 222, 128, 0.2);
  color: #4ade80;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.ai-flow-success h4 {
  margin: 0 0 4px;
  font-size: 0.95rem;
  font-weight: 700;
}

.ai-flow-success p {
  margin: 0;
  font-size: 0.8rem;
  opacity: 0.85;
  line-height: 1.45;
}

.ai-flow-confirm {
  margin-top: 12px;
  text-align: center;
}

.ai-flow-confirm p {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: inherit;
  opacity: 0.8;
}

.ai-btn-confirm {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #8868c9, #6542a9);
  box-shadow: 0 6px 20px rgba(101, 66, 169, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ai-btn-confirm:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 26px rgba(101, 66, 169, 0.45);
}

.ai-flow-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 10px;
}

.ai-btn-hd {
  width: 100%;
  border: 1px solid rgba(136, 104, 201, 0.45);
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  color: #6542a9;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s, transform 0.2s;
}

body.dark-mode .ai-btn-hd {
  background: #1c1a22;
  color: #c4b5fd;
  border-color: rgba(167, 139, 250, 0.45);
}

.ai-btn-hd:hover {
  transform: translateY(-1px);
  background: rgba(136, 104, 201, 0.08);
}

@media (max-width: 640px) {
  .ai-flow-confirm-actions {
    grid-template-columns: 1fr;
  }
}

/* Place order panel */
.ai-flow-order {
  margin-top: 12px;
  border-color: rgba(255, 215, 0, 0.35);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.08), rgba(136, 104, 201, 0.06));
}

body.dark-mode .ai-flow-order {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(30, 30, 42, 0.95));
}

.ai-flow-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ai-flow-order-header h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-flow-order-header h4 i { color: var(--ai-primary, #8868c9); }

.ai-moq-pill {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: 50px;
  color: #fff;
  background: linear-gradient(45deg, #ff6b6b, #ffd700);
  white-space: nowrap;
}

.ai-flow-order-qty {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.ai-flow-order-qty label {
  font-size: 0.78rem;
  font-weight: 600;
  flex-shrink: 0;
}

.ai-flow-order-qty input {
  flex: 1;
  max-width: 120px;
  border: 1.5px solid var(--ai-glass-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.9);
  color: inherit;
}

body.dark-mode .ai-flow-order-qty input {
  background: #1a1a26;
  border-color: #3d3d52;
  color: #f0f0f8;
}

.ai-flow-order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-flow-order-actions .ai-btn {
  flex: 1;
  min-width: 140px;
}

.ai-btn-order {
  background: linear-gradient(45deg, #ff6b6b, #ffd700) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 6px 22px rgba(255, 107, 107, 0.35) !important;
}

/* Error card */
.ai-flow-error {
  border-color: rgba(255, 107, 107, 0.4);
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.1), rgba(255, 255, 255, 0.05));
}

body.dark-mode .ai-flow-error {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(30, 30, 42, 0.95));
}

.ai-flow-error-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.ai-flow-error h4 {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #c0392b;
}

body.dark-mode .ai-flow-error h4 { color: #ff8a8a; }

.ai-flow-error p {
  margin: 0 0 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  opacity: 0.9;
}

.ai-flow-error-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-flow-error-actions .ai-btn {
  flex: 1;
  min-width: 120px;
}

/* Enhanced top error banner */
.ai-error.visible {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.ai-error-icon {
  flex-shrink: 0;
  color: #c0392b;
  font-size: 1.1rem;
  margin-top: 2px;
}

body.dark-mode .ai-error-icon { color: #ff8a8a; }

.ai-error-text {
  flex: 1;
  line-height: 1.45;
}

@media (max-width: 576px) {
  .ai-gen-overlay { padding: 20px 16px; }
  .ai-gen-orb { width: 72px; height: 72px; }
  .ai-flow-order-actions { flex-direction: column; }
  .ai-flow-order-actions .ai-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-gen-overlay.active,
  .ai-result-flow,
  .ai-gen-orb::before,
  .ai-gen-orb::after,
  .ai-gen-orb i,
  .ai-gen-bar span {
    animation: none !important;
  }
}
