/* ==========================================================================
   Atelier Design System - Components
   Buttons, forms, cards, tabs, upload zones, pro features, modals.
   Requires: design-system.css
   ========================================================================== */

/* ---------- Buttons (shared base) ---------- */
.btn,
.btn-primary,
.btn-secondary,
.btn-download,
.btn-pro {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  min-height: 44px;
}

/* Primary */
.btn-primary {
  background-color: var(--accent-primary);
  color: var(--text-primary);
}
.btn-primary:hover:not(:disabled) { background-color: var(--accent-hover); }
.btn-primary:active { background-color: var(--accent-active); }
.btn-primary:disabled {
  background-color: var(--border-default);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* Secondary */
.btn-secondary {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
}
.btn-secondary:hover:not(:disabled) { background-color: var(--border-default); }
.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Download / Success */
.btn-download,
.btn-success {
  background-color: var(--success-mid);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-md);
}
.btn-download:hover:not(:disabled),
.btn-success:hover:not(:disabled) { background-color: var(--success-dark); }
.btn-download:disabled,
.btn-success:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-download.pro-locked {
  background: var(--border-default);
  color: var(--text-disabled);
  cursor: not-allowed;
}

/* Pro / Gold */
.btn-pro {
  background: var(--pro-gradient);
  color: var(--pro-text);
  font-weight: 600;
}
.btn-pro:hover {
  opacity: 0.9;
  box-shadow: 0 4px 12px var(--pro-glow);
  transform: translateY(-1px);
}
.btn-pro.full-width {
  width: 100%;
  padding: 12px 24px;
  font-size: 16px;
}

/* Size variants */
.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  min-height: 36px;
}
.btn-large {
  padding: 16px 32px;
  font-size: 16px;
  min-height: 52px;
}

/* ---------- Form Controls ---------- */
.label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.input-field,
.select-field,
.textarea-field {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  transition: border-color var(--transition-fast);
}

.input-field:focus,
.select-field:focus,
.textarea-field:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.input-field::placeholder,
.textarea-field::placeholder {
  color: var(--text-disabled);
}

.textarea-field {
  min-height: 120px;
  resize: vertical;
}

.help-text {
  color: var(--text-disabled);
  font-size: 13px;
  margin-top: var(--space-xs);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 15px;
  color: var(--text-muted);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"]:checked {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Slider */
.slider {
  width: 100%;
  height: 4px;
  background: var(--border-default);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--accent-primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.slider:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* ---------- Tabs ---------- */
.tab-group {
  display: flex;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.tab {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-weight: 500;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tab:hover { background: var(--border-default); }

.tab.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

/* ---------- Cards / Panels ---------- */
.input-panel,
.preview-panel,
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
}

.input-section {
  margin-bottom: var(--space-xl);
}

.options-panel {
  border-top: 1px solid var(--border-default);
  padding-top: var(--space-xl);
}

.option-group {
  position: relative;
  margin-bottom: var(--space-lg);
}

/* ---------- Upload Zone ---------- */
.file-upload-zone {
  background-color: var(--bg-primary);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.file-upload-zone:hover,
.file-upload-zone.drag-active {
  border-color: var(--accent-primary);
  background-color: #1e3a8a;
}

.file-upload-zone input[type="file"] {
  display: none;
}

.upload-primary {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.upload-secondary {
  font-size: 14px;
  color: var(--text-disabled);
}

/* ---------- Preview / Output ---------- */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.preview-container {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
}

/* States */
.empty-state,
.loading-state,
.error-state {
  text-align: center;
  color: var(--text-dim);
}

.empty-state h4,
.error-state h4 {
  margin-bottom: var(--space-sm);
  color: var(--text-secondary);
}

.error-state { color: var(--error); }

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-default);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ---------- Pro Features ---------- */
.pro-feature {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.pro-feature::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(1px);
}

.pro-badge {
  background: var(--pro-gradient);
  color: var(--pro-text);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  z-index: 1;
}

.pro-badge-inline {
  background: var(--pro-gradient);
  color: var(--pro-text);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  margin-right: var(--space-xs);
}

.disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
}
.disabled input,
.disabled select {
  cursor: not-allowed;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--space-lg);
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-default);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-disabled);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background-color: var(--border-default);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-default);
}

/* Feature list (modal / marketing) */
.feature-list {
  list-style: none;
  margin-bottom: var(--space-lg);
}

.feature-list li {
  padding: var(--space-sm) 0;
  color: var(--text-secondary);
  position: relative;
  padding-left: var(--space-lg);
}

.feature-list li::before {
  content: '\2713';
  color: var(--success);
  position: absolute;
  left: 0;
  font-weight: bold;
}

/* Pricing block inside modals */
.upgrade-pricing {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.price {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.price-subtitle {
  color: var(--text-disabled);
  font-size: 14px;
}

/* ---------- Notification ---------- */
.notification {
  position: fixed;
  top: 80px;
  right: var(--space-lg);
  background: var(--success);
  color: var(--text-primary);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  z-index: 1500;
  max-width: 300px;
}

.notification button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
}

/* ---------- Code Output ---------- */
.code-container {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-md);
}

.code-output {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- Error / Success Messages ---------- */
.error-message {
  background-color: #7f1d1d;
  border: 1px solid var(--error-dark);
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-top: var(--space-sm);
}

.success-message {
  background-color: #064e3b;
  border: 1px solid var(--success-mid);
  color: #6ee7b7;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-top: var(--space-sm);
}

/* ---------- Loading shimmer ---------- */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* ---------- Similar Tools Section ---------- */
.similar-tools {
  margin-top: var(--space-2xl);
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border-default);
}

.similar-tools h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-lg);
}

.similar-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

@media (max-width: 900px) {
  .similar-tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .similar-tools-grid {
    grid-template-columns: 1fr;
  }
}

.similar-tool-card {
  display: block;
  padding: var(--space-md);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.similar-tool-card:hover {
  border-color: var(--accent-primary);
  background-color: var(--bg-tertiary);
  transform: translateY(-2px);
}

.similar-tool-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-xs);
}

.similar-tool-card p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}
