/**
 * Printive AI Image Generator — Frontend Styles
 * Version: 3.0.0
 * Design System: Dark Purple / Glassmorphism
 * =====================================================
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* =====================================================
   🎨 DESIGN TOKENS
   ===================================================== */
:root {
  --pv-bg:           #F0F5FA;
  --pv-card:         #ffffff;
  --pv-card-hover:   #F8FAFC;
  --pv-border:       #D1D5DB;
  --pv-border-hover: #9CA3AF;
  --pv-primary:      #334155;
  --pv-primary-dark: #045CB4;
  --pv-secondary:    #334155;
  --pv-accent:       #045CB4;
  --pv-glow:         rgba(51, 65, 85, 0.15);
  --pv-text:         #334155;
  --pv-text-muted:   #475569;
  --pv-text-dim:     #64748B;
  --pv-success: #10B981;
  --pv-error: #EF4444;
  --pv-warning: #F59E0B;
  --pv-radius: 14px;
  --pv-radius-sm: 8px;
  --pv-radius-lg: 20px;
  --pv-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  --pv-shadow-glow: 0 0 40px rgba(51, 65, 85, 0.2);
  --pv-transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =====================================================
   🏠 WRAPPER UTAMA
   ===================================================== */
.printive-ai-generator-section {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  max-width: 780px;
  margin: 0 auto;
  padding: 0 16px;
  color: var(--pv-text);
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   🔢 MODE TABS (Generate / Edit / Merge)
   ===================================================== */
.printive-mode-tabs {
  display: flex;
  gap: 6px;
  background: rgba(240, 245, 250, 0.8);
  border: 1px solid var(--pv-border);
  border-radius: 50px;
  padding: 5px;
  margin-bottom: 28px;
  backdrop-filter: blur(10px);
}

.printive-mode-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: 40px;
  border: none;
  background: transparent;
  color: var(--pv-text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--pv-transition);
  white-space: nowrap;
}

.printive-mode-tab .tab-icon {
  font-size: 16px;
  line-height: 1;
}

.printive-mode-tab:hover {
  color: var(--pv-text);
  background: rgba(51, 65, 85, 0.12);
}

.printive-mode-tab.active {
  background: linear-gradient(135deg, var(--pv-primary) 0%, var(--pv-secondary) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(51, 65, 85, 0.4);
}

/* =====================================================
   📋 FORM PANELS (tiap mode)
   ===================================================== */
.printive-mode-panel {
  display: none;
  animation: pv-fadein 0.3s ease;
}

.printive-mode-panel.active {
  display: block;
}

@keyframes pv-fadein {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================
   🏷️ LABELS
   ===================================================== */
.printive-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pv-text-muted);
  margin-bottom: 8px;
  margin-top: 20px;
}

.printive-label:first-child {
  margin-top: 0;
}

/* =====================================================
   📝 TEXTAREA
   ===================================================== */
.printive-textarea {
  width: 100%;
  min-height: 110px;
  padding: 14px 16px;
  background: var(--pv-card);
  border: 1px solid var(--pv-border);
  border-radius: var(--pv-radius);
  color: var(--pv-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  transition: var(--pv-transition);
  box-sizing: border-box;
}

.printive-textarea::placeholder {
  color: var(--pv-text-dim);
}

.printive-textarea:focus {
  outline: none;
  border-color: var(--pv-primary);
  box-shadow: 0 0 0 3px rgba(51, 65, 85, 0.2);
  background: var(--pv-card-hover);
}

/* =====================================================
   🔽 SELECT
   ===================================================== */
.printive-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--pv-card);
  border: 1px solid var(--pv-border);
  border-radius: var(--pv-radius);
  color: var(--pv-text);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: var(--pv-transition);
  box-sizing: border-box;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394A3B8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

.printive-select:focus {
  outline: none;
  border-color: var(--pv-primary);
  box-shadow: 0 0 0 3px rgba(51, 65, 85, 0.2);
}

.printive-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.printive-select option {
  background: #ffffff;
  color: var(--pv-text);
}

/* =====================================================
   📐 ORIENTATION CARDS (visual toggle)
   ===================================================== */
.printive-orientation-group {
  display: flex;
  gap: 10px;
}

.printive-orientation-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  background: var(--pv-card);
  border: 1.5px solid var(--pv-border);
  border-radius: var(--pv-radius);
  cursor: pointer;
  transition: var(--pv-transition);
  text-align: center;
}

.printive-orientation-card:hover {
  border-color: var(--pv-primary);
  background: var(--pv-card-hover);
}

.printive-orientation-card.active {
  border-color: var(--pv-primary);
  background: rgba(51, 65, 85, 0.15);
  box-shadow: 0 0 16px rgba(51, 65, 85, 0.2);
}

.orientation-shape {
  border: 2px solid var(--pv-text-muted);
  border-radius: 4px;
  transition: var(--pv-transition);
}

.orientation-shape.square {
  width: 32px;
  height: 32px;
}

.orientation-shape.portrait {
  width: 24px;
  height: 36px;
}

.orientation-shape.landscape {
  width: 44px;
  height: 28px;
}

.printive-orientation-card.active .orientation-shape {
  border-color: var(--pv-accent);
  background: rgba(168, 85, 247, 0.15);
}

.orientation-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--pv-text-muted);
  letter-spacing: 0.05em;
}

.printive-orientation-card.active .orientation-label {
  color: var(--pv-accent);
}

/* =====================================================
   📤 UPLOAD DROPZONE (Multi-image)
   ===================================================== */
.printive-upload-zone {
  position: relative;
  border: 2px dashed var(--pv-border);
  border-radius: var(--pv-radius);
  padding: 32px 20px;
  text-align: center;
  background: var(--pv-card);
  cursor: pointer;
  transition: var(--pv-transition);
  overflow: hidden;
}

.printive-upload-zone:hover,
.printive-upload-zone.dragover {
  border-color: var(--pv-primary);
  background: rgba(51, 65, 85, 0.08);
}

.printive-upload-zone.dragover {
  box-shadow: 0 0 24px rgba(51, 65, 85, 0.25);
}

.printive-upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.upload-zone-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
}

.upload-zone-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--pv-text);
  margin-bottom: 6px;
}

.upload-zone-sub {
  font-size: 12px;
  color: var(--pv-text-dim);
  line-height: 1.5;
}

.upload-zone-badge {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 10px;
  background: rgba(51, 65, 85, 0.2);
  border: 1px solid var(--pv-border);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: var(--pv-accent);
  letter-spacing: 0.04em;
}

/* =====================================================
   🖼️ IMAGE PREVIEW GRID (uploaded files)
   ===================================================== */
.printive-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.printive-preview-item {
  position: relative;
  border-radius: var(--pv-radius-sm);
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--pv-card);
  border: 1px solid var(--pv-border);
  animation: pv-fadein 0.2s ease;
}

.printive-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.printive-preview-item .remove-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(239, 68, 68, 0.9);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--pv-transition);
  z-index: 3;
}

.printive-preview-item .remove-btn:hover {
  background: var(--pv-error);
  transform: scale(1.15);
}

.printive-preview-item .img-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 3px 5px;
  background: rgba(0, 0, 0, 0.6);
  font-size: 10px;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--pv-text-muted);
  font-weight: 500;
}

.preview-count-badge span {
  background: rgba(51, 65, 85, 0.2);
  color: var(--pv-accent);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 700;
}

/* =====================================================
   🔵 SUBMIT BUTTON
   ===================================================== */
.printive-btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 24px;
  margin-top: 24px;
  background: linear-gradient(135deg, var(--pv-primary) 0%, var(--pv-secondary) 100%);
  border: none;
  border-radius: var(--pv-radius);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: var(--pv-transition);
  position: relative;
  overflow: hidden;
}

.printive-btn-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(51, 65, 85, 0.1) 0%, transparent 50%);
  opacity: 0;
  transition: var(--pv-transition);
}

.printive-btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(51, 65, 85, 0.5);
}

.printive-btn-submit:hover::before {
  opacity: 1;
}

.printive-btn-submit:active {
  transform: translateY(0);
}

.printive-btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(51, 65, 85, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pv-spin 0.7s linear infinite;
  display: none;
}

.printive-btn-submit.loading .btn-spinner {
  display: block;
}

.printive-btn-submit.loading .btn-text-idle {
  display: none;
}

/* =====================================================
   ⏳ LOADER / PROCESSING STATE
   ===================================================== */
.printive-loader {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 24px;
  margin-top: 24px;
  background: var(--pv-card);
  border: 1px solid var(--pv-border);
  border-radius: var(--pv-radius-lg);
  text-align: center;
}

.printive-loader.visible {
  display: flex;
}

.loader-orb {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0%, var(--pv-primary) 50%, var(--pv-accent) 100%);
  animation: pv-spin 1.2s linear infinite;
  position: relative;
}

.loader-orb::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--pv-card);
}

.loader-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--pv-text);
}

.loader-subtitle {
  font-size: 13px;
  color: var(--pv-text-muted);
  line-height: 1.5;
}

.loader-dots {
  display: flex;
  gap: 6px;
}

.loader-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pv-primary);
  animation: pv-bounce 1.2s ease infinite;
}

.loader-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.loader-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* =====================================================
   🖼️ RESULT CONTAINER
   ===================================================== */
.printive-result {
  display: none;
  margin-top: 28px;
  animation: pv-fadein 0.4s ease;
}

.printive-result.visible {
  display: block;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.result-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--pv-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-image-wrapper {
  position: relative;
  border-radius: var(--pv-radius-lg);
  overflow: hidden;
  box-shadow: var(--pv-shadow), var(--pv-shadow-glow);
}

.result-image-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--pv-radius-lg);
}

.result-image-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* =====================================================
   🎮 ACTION BUTTONS (Edit / Continue to Mockup)
   ===================================================== */
.printive-result-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.pv-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: var(--pv-radius);
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--pv-transition);
  text-decoration: none;
  white-space: nowrap;
}

.pv-btn-secondary {
  background: rgba(51, 65, 85, 0.15);
  color: var(--pv-accent);
  border: 1px solid rgba(51, 65, 85, 0.3);
}

.pv-btn-secondary:hover {
  background: rgba(51, 65, 85, 0.25);
  border-color: var(--pv-primary);
  transform: translateY(-1px);
}

.pv-btn-primary {
  background: linear-gradient(135deg, var(--pv-primary) 0%, var(--pv-secondary) 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(51, 65, 85, 0.35);
}

.pv-btn-primary:hover {
  box-shadow: 0 6px 24px rgba(51, 65, 85, 0.5);
  transform: translateY(-2px);
  color: #fff;
  text-decoration: none;
}

.pv-btn-outline {
  background: transparent;
  color: var(--pv-text-muted);
  border: 1px solid rgba(51, 65, 85, 0.1);
}

.pv-btn-outline:hover {
  border-color: var(--pv-border-hover);
  color: var(--pv-text);
  background: rgba(51, 65, 85, 0.04);
}

/* =====================================================
   🚨 STATUS / ERROR MESSAGES (Inherits unified styles from printive-feedback.css)
   ===================================================== */
.printive-status {
  margin-top: 12px;
}

/* =====================================================
   ℹ️ INFO HINT BOX
   ===================================================== */
.printive-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(51, 65, 85, 0.07);
  border: 1px solid rgba(51, 65, 85, 0.18);
  border-radius: var(--pv-radius-sm);
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--pv-text-muted);
  line-height: 1.5;
}

.printive-hint .hint-icon {
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* =====================================================
   ✨ FALLBACK INDICATOR
   ===================================================== */
.printive-provider-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
}

.pv-badge-openai {
  background: rgba(16, 185, 129, 0.15);
  color: #6EE7B7;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.pv-badge-gemini {
  background: rgba(245, 158, 11, 0.15);
  color: #FCD34D;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

/* =====================================================
   📱 RESPONSIVE
   ===================================================== */
@media (max-width: 600px) {
  .printive-mode-tabs {
    border-radius: var(--pv-radius);
    flex-wrap: wrap;
  }

  .printive-mode-tab {
    padding: 9px 12px;
    font-size: 13px;
  }

  .printive-orientation-group {
    gap: 8px;
  }

  .printive-result-actions {
    flex-direction: column;
  }

  .pv-btn {
    width: 100%;
    justify-content: center;
  }

  .printive-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }
}

/* =====================================================
   🔄 KEYFRAMES
   ===================================================== */
@keyframes pv-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pv-bounce {

  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }

  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* =====================================================
   💊 PILL BUTTONS (Size Selector)
   ===================================================== */
.pv-size-pill input {
  display: none;
}
.pv-pill-text {
  padding: 8px 14px;
  border: 1px solid var(--pv-border);
  border-radius: 20px;
  background: var(--pv-card);
  color: var(--pv-text-muted);
  font-size: 13px;
  cursor: pointer;
  display: inline-block;
  transition: all 0.2s ease;
  user-select: none;
}
.pv-size-pill input:checked + .pv-pill-text {
  background: var(--pv-primary);
  color: #fff;
  border-color: var(--pv-primary);
}
.pv-size-pill:hover .pv-pill-text {
  border-color: var(--pv-primary);
}
/* Unified Primary Button Hover */
.printive-btn-submit:hover,
.pv-btn-primary:hover,
.pv-editor-btn-mockup:hover,
.pv-editor-btn-upscale:hover,
.pv-editor-btn-save:hover,
.btn-push-printful:hover,
.btn-checkout-woo:hover,
.btn-trigger-upscale:hover:not(:disabled),
.editor-btn[style*='background:#334155']:hover {
    background: #045cb4 !important;
    color: #fff !important;
}
