/* Reset & Base Styles */
* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
}

body { 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
  min-height: 100vh; 
  padding: 40px 20px; 
}

/* Container */
.container { 
  max-width: 1400px; 
  margin: 0 auto; 
  background: white; 
  padding: 40px; 
  border-radius: 16px; 
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); 
}

/* Typography */
h1 { 
  color: #2d3748; 
  margin-bottom: 10px; 
  font-size: 32px; 
}

h2 {
  color: #2d3748;
  font-size: 28px;
}

h3 {
  color: #2d3748;
  font-size: 18px;
}

.subtitle { 
  color: #718096; 
  margin-bottom: 30px; 
  font-size: 16px; 
}

/* Setup Screen */
.setup-screen { 
  max-width: 500px; 
  margin: 60px auto; 
  text-align: center; 
}

.setup-screen h2 { 
  margin-bottom: 15px;
}

.setup-screen p { 
  color: #718096; 
  margin-bottom: 30px; 
  line-height: 1.6; 
}

/* Form Elements */
.form-group { 
  margin-bottom: 20px; 
  text-align: left; 
}

.form-group label { 
  display: block; 
  color: #4a5568; 
  font-weight: 600; 
  margin-bottom: 8px; 
  font-size: 14px; 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
}

.form-group input { 
  width: 100%; 
  padding: 14px 20px; 
  font-size: 16px; 
  border: 2px solid #e2e8f0; 
  border-radius: 8px; 
  transition: all 0.3s; 
}

.form-group input:focus { 
  outline: none; 
  border-color: #667eea; 
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); 
}

.form-group .help-text { 
  font-size: 13px; 
  color: #718096; 
  margin-top: 6px; 
}

/* Input Group */
.input-group { 
  display: flex; 
  gap: 15px; 
  margin-bottom: 40px; 
  flex-wrap: wrap; 
}

input { 
  padding: 14px 20px; 
  font-size: 16px; 
  border: 2px solid #e2e8f0; 
  border-radius: 8px; 
  flex: 1; 
  min-width: 250px; 
  transition: all 0.3s; 
}

input:focus { 
  outline: none; 
  border-color: #667eea; 
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); 
}

/* Buttons */
button { 
  padding: 14px 32px; 
  font-size: 16px; 
  font-weight: 600; 
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
  color: white; 
  border: none; 
  border-radius: 8px; 
  cursor: pointer; 
  transition: transform 0.2s, box-shadow 0.2s; 
}

button:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3); 
}

button:active { 
  transform: translateY(0); 
}

button:disabled { 
  opacity: 0.5; 
  cursor: not-allowed; 
  transform: none; 
}

.btn-secondary { 
  background: #e2e8f0; 
  color: #4a5568; 
}

.btn-secondary:hover { 
  background: #cbd5e0; 
  box-shadow: 0 4px 8px rgba(0,0,0,0.1); 
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  margin-left: 10px;
}

/* API Key Status */
.api-key-status { 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  padding: 12px 20px; 
  background: #f0fdf4; 
  border: 2px solid #86efac; 
  border-radius: 8px; 
  margin-bottom: 20px; 
}

.api-key-status .status-text { 
  flex: 1; 
  color: #166534; 
  font-weight: 600; 
}

/* Preview Section */
.preview-section { 
  margin-top: 40px; 
}

.preview-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 20px; 
  padding-bottom: 15px; 
  border-bottom: 2px solid #e2e8f0; 
}

.preview-header h2 { 
  font-size: 24px; 
}

.preview-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Badges */
.creative-type-badge { 
  background: #edf2f7; 
  color: #4a5568; 
  padding: 6px 14px; 
  border-radius: 20px; 
  font-size: 13px; 
  font-weight: 600; 
}

.template-badge {
  background: #d1fae5;
  color: #065f46;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.product-badge { 
  display: inline-block; 
  background: #edf2f7; 
  color: #4a5568; 
  padding: 4px 10px; 
  border-radius: 12px; 
  font-size: 10px; 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
  font-weight: 700; 
  margin-bottom: 8px; 
}

.dimensions-badge { 
  position: absolute; 
  top: -12px; 
  left: 20px; 
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
  color: white; 
  padding: 6px 14px; 
  border-radius: 20px; 
  font-size: 13px; 
  font-weight: 600; 
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3); 
}

/* Ad Display */
.ad-wrapper { 
  display: inline-block; 
  position: relative; 
  background: #f7fafc; 
  padding: 20px; 
  border-radius: 12px; 
  box-shadow: 0 4px 6px rgba(0,0,0,0.07); 
}

.ad-preview-frame { 
  display: inline-block; 
  border: 2px solid #e2e8f0; 
  overflow: hidden; 
  background: white; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.1); 
  border-radius: 8px; 
  position: relative; 
}

.ad-preview-frame iframe { 
  border: none; 
  width: 100%; 
  height: 100%; 
}

.ad-preview-frame img { 
  display: block; 
  max-width: 100%; 
  max-height: 100%; 
  object-fit: contain; 
}

/* Sponsored Product Display */
.sponsored-product { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
  justify-content: center; 
  padding: 20px; 
  text-decoration: none; 
  color: inherit; 
  transition: all 0.3s; 
  background: white; 
}

.sponsored-product:hover { 
  background: #f7fafc; 
  transform: scale(1.02); 
}

.sponsored-product img { 
  max-width: 85%; 
  max-height: 55%; 
  object-fit: contain; 
  transition: transform 0.3s; 
}

.sponsored-product:hover img { 
  transform: scale(1.05); 
}

.product-info { 
  text-align: center; 
  margin-top: 15px; 
  width: 100%; 
}

.product-name { 
  font-size: 15px; 
  font-weight: 600; 
  margin-bottom: 10px; 
  line-height: 1.4; 
  color: #2d3748; 
}

.product-price { 
  font-size: 22px; 
  color: #e53e3e; 
  font-weight: 700; 
}

/* Messages */
.no-creative-message { 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  height: 100%; 
  color: #718096; 
  font-size: 14px; 
  text-align: center; 
  padding: 20px; 
}

/* Metadata */
.metadata { 
  margin-top: 30px; 
  padding: 25px; 
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%); 
  border-radius: 12px; 
  border-left: 4px solid #667eea; 
}

.metadata h3 { 
  margin-bottom: 15px; 
}

.metadata-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
  gap: 15px; 
}

.metadata-item { 
  display: flex; 
  flex-direction: column; 
  gap: 5px; 
}

.metadata-item strong { 
  color: #4a5568; 
  font-size: 13px; 
  text-transform: uppercase; 
  letter-spacing: 0.5px; 
}

.metadata-item span { 
  color: #2d3748; 
  font-size: 15px; 
}

.metadata-item a { 
  color: #667eea; 
  text-decoration: none; 
  word-break: break-all; 
}

.metadata-item a:hover { 
  text-decoration: underline; 
}

/* Loading State */
.loading { 
  text-align: center; 
  padding: 60px 20px; 
  color: #718096; 
  font-size: 18px; 
}

.loading::after { 
  content: '...'; 
  animation: dots 1.5s steps(4, end) infinite; 
}

@keyframes dots { 
  0%, 20% { content: '.'; } 
  40% { content: '..'; } 
  60%, 100% { content: '...'; } 
}

/* Error State */
.error { 
  background: #fff5f5; 
  border: 2px solid #fc8181; 
  color: #c53030; 
  padding: 20px; 
  border-radius: 8px; 
  margin-top: 20px; 
}

.error strong { 
  display: block; 
  margin-bottom: 5px; 
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #2d3748;
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease-out;
  z-index: 1000;
}

.toast.success {
  background: #065f46;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Utility */
.hidden { 
  display: none; 
}