/* Modern Form Filler Styles */

/* Reset and Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.1);
  --secondary: #64748b;
  --secondary-hover: #475569;
  --success: #22c55e;
  --success-light: rgba(34, 197, 94, 0.1);
  --error: #ef4444;
  --error-light: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  
  /* Neutrals */
  --bg-main: #0f0f11;
  --bg-card: #18181b;
  --bg-input: #27272a;
  --bg-hover: #3f3f46;
  --border: #3f3f46;
  --border-light: #52525b;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.15);
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App Container */
.app-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

/* Steps */
.step {
  width: 100%;
  max-width: 900px;
  animation: fadeIn var(--transition-normal);
}

.step.hidden {
  display: none;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3rem;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

/* Step Header */
.step-header {
  text-align: center;
  margin-bottom: 3rem;
}

.step-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: var(--primary-light);
  border-radius: 50%;
  color: var(--primary);
  margin-bottom: 1.5rem;
}

.step-header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-secondary);
  font-size: 1.125rem;
}

/* Small Header */
.step-header-small {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-back:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-light);
}

.current-url {
  color: var(--text-muted);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* URL Input */
.url-input-wrapper {
  margin-bottom: 1.5rem;
}

.url-input-group {
  display: flex;
  gap: 1rem;
  align-items: stretch;
}

.url-input-group input {
  flex: 1;
  padding: 1rem 1.25rem;
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.url-input-group input::placeholder {
  color: var(--text-muted);
}

.url-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.url-hint {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem 1.75rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-light);
}

.btn .btn-loading {
  display: none;
}

.btn.loading .btn-text {
  display: none;
}

.btn.loading .btn-loading {
  display: inline-flex;
  align-items: center;
}

.spinner {
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
}

.spinner circle {
  stroke: currentColor;
  stroke-dasharray: 50;
  stroke-dashoffset: 20;
  stroke-linecap: round;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Error Message */
.error-message {
  background: var(--error-light);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  color: var(--error);
  font-size: 0.9rem;
  margin-top: 1rem;
}

.error-message.hidden {
  display: none;
}

/* Fields Section */
.fields-section {
  margin-bottom: 2rem;
}

.fields-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.fields-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

/* View Toggle */
.view-toggle {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.toggle-btn:hover {
  color: var(--text-primary);
}

.toggle-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Fields View */
.fields-view {
  animation: fadeIn var(--transition-fast);
}

.fields-view.hidden {
  display: none;
}

.fields-grid {
  display: grid;
  gap: 1rem;
}

/* Field Card */
.field-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition-fast);
}

.field-card:hover {
  border-color: var(--border-light);
}

.field-card:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.field-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.field-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.field-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-badge.required {
  background: var(--error-light);
  color: var(--error);
}

.field-badge.optional {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.field-badge.type {
  background: var(--primary-light);
  color: var(--primary);
}

.field-meta {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.field-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
}

.field-input::placeholder {
  color: var(--text-muted);
}

.field-input:focus {
  outline: none;
  border-color: var(--primary);
}

.field-input.filled {
  border-color: var(--success);
  background: var(--success-light);
}

/* Raw View */
.raw-code {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

/* Quick Actions Section */
.quick-actions-section {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.btn-random-fill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.btn-random-fill svg {
  flex-shrink: 0;
}

/* Captcha Warning */
.captcha-warning {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.captcha-warning-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.captcha-warning-content svg {
  flex-shrink: 0;
  color: #eab308;
  margin-top: 0.125rem;
}

.captcha-warning-content strong {
  color: #eab308;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 0.25rem;
}

.captcha-warning-content p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
  line-height: 1.5;
}

/* Form Selection Info */
.form-selection-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}

.form-selection-content {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.form-selection-content svg {
  flex-shrink: 0;
  color: #3b82f6;
  margin-top: 0.125rem;
}

.form-selection-content strong {
  color: #3b82f6;
  font-size: 0.95rem;
  display: block;
  margin-bottom: 0.25rem;
}

.form-selection-content p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin: 0;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.confidence-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.confidence-badge.high {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.confidence-badge.medium {
  background: rgba(234, 179, 8, 0.2);
  color: #eab308;
}

.confidence-badge.low {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
}

/* AI Section (kept for backwards compatibility) */
.ai-section {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.ai-header {
  margin-bottom: 1rem;
}

.ai-header h3 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.ai-header h3 svg {
  color: var(--primary);
}

.ai-input-wrapper {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
}

.ai-input-wrapper textarea {
  flex: 1;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
  transition: all var(--transition-fast);
}

.ai-input-wrapper textarea::placeholder {
  color: var(--text-muted);
}

.ai-input-wrapper textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-generate {
  flex-shrink: 0;
  height: fit-content;
}

.ai-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.75rem;
  text-align: center;
}

/* Actions Section */
.actions-section {
  display: flex;
  justify-content: center;
}

.btn-fill-form {
  padding: 1.25rem 3rem;
  font-size: 1.1rem;
}

/* Results */
.result-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.result-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin-bottom: 1.5rem;
}

.result-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.result-icon.error {
  background: var(--error-light);
  color: var(--error);
}

.result-header h2 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.result-url {
  color: var(--text-muted);
  font-size: 0.9rem;
  word-break: break-all;
}

/* Result Details */
.result-details {
  margin-bottom: 2rem;
}

.result-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
}

.result-item-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.result-item-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.result-item-icon.error {
  background: var(--error-light);
  color: var(--error);
}

.result-item-content {
  flex: 1;
  min-width: 0;
}

.result-item-field {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.result-item-value {
  color: var(--text-secondary);
  font-size: 0.85rem;
  word-break: break-word;
}

/* Screenshot */
.result-screenshot {
  margin-bottom: 2rem;
}

.result-screenshot.hidden {
  display: none;
}

.result-screenshot h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.result-screenshot img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Submission Status */
.result-submission-status {
  margin-bottom: 1.5rem;
}

.submission-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}

.submission-info.success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}

.submission-info.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.submission-info.error {
  background: var(--error-light);
  color: var(--error);
  border: 1px solid var(--error);
}

.submission-info a {
  color: inherit;
  text-decoration: underline;
  word-break: break-all;
}

.result-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* Result Actions */
.result-actions {
  display: flex;
  justify-content: center;
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    padding: 1rem;
  }

  .step-content {
    padding: 1.5rem;
  }

  .step-header h1 {
    font-size: 1.75rem;
  }

  .url-input-group {
    flex-direction: column;
  }

  .ai-input-wrapper {
    flex-direction: column;
  }

  .btn-generate {
    width: 100%;
  }

  .fields-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .view-toggle {
    justify-content: center;
  }
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-input);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection */
::selection {
  background: var(--primary);
  color: white;
}

/* CAPTCHA Modal */
.captcha-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.captcha-modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 550px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.captcha-modal-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.captcha-modal-header svg {
  color: #eab308;
  margin-bottom: 1rem;
}

.captcha-modal-header h3 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.captcha-message {
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.captcha-instructions {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.captcha-instructions strong {
  color: var(--primary);
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.captcha-instructions p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.captcha-preview {
  margin-bottom: 1.5rem;
}

.captcha-preview p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
}

.captcha-preview img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  max-height: 200px;
  object-fit: contain;
  background: var(--bg-input);
}

.captcha-steps {
  margin-bottom: 1.5rem;
}

.captcha-step {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}

.captcha-step:last-child {
  margin-bottom: 0;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 600;
  flex-shrink: 0;
}

.captcha-step span:last-child {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* CAPTCHA Field Values */
.captcha-field-values {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.field-values-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.field-values-header strong {
  color: var(--text-primary);
  font-size: 0.9rem;
}

.btn-copy-all {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-copy-all:hover {
  background: var(--primary-dark);
}

.field-values-list {
  max-height: 200px;
  overflow-y: auto;
}

.captcha-field-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin-bottom: 0.25rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.captcha-field-item:last-child {
  margin-bottom: 0;
}

.captcha-field-item .field-label {
  color: var(--text-secondary);
  font-size: 0.85rem;
  min-width: 100px;
  flex-shrink: 0;
}

.captcha-field-item .field-value {
  color: var(--text-primary);
  font-size: 0.85rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy-field {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.btn-copy-field:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.captcha-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.captcha-actions .btn {
  flex: 1;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.captcha-actions .btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.captcha-actions .btn-outline:hover {
  background: var(--bg-input);
  border-color: var(--border-light);
  color: var(--text-primary);
}

@media (max-width: 480px) {
  .captcha-modal-content {
    padding: 1.5rem;
  }

  .captcha-actions {
    flex-direction: column;
  }

  .captcha-actions .btn {
    width: 100%;
  }
}

/* Toast Notifications */
.toast-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  z-index: 10001;
  animation: toast-slide-up 0.3s ease-out;
}

.toast-success {
  background: var(--success);
  color: white;
}

.toast-error {
  background: var(--error);
  color: white;
}

.toast-info {
  background: var(--primary);
  color: white;
}

.toast-fade-out {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

@keyframes toast-slide-up {
  from {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}
