:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #151b2e;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --accent: #7c3aed;
  --accent-light: #a855f7;
  --accent-glow: rgba(124, 58, 237, 0.3);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(124, 58, 237, 0.5);
  --glass-blur: 20px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.form-control.is-invalid {
  border-color: #ef4444 !important;
  background-color: rgba(239, 68, 68, 0.08) !important;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2) !important;
}

.form-control.is-valid {
  border-color: #10b981 !important;
  background-color: rgba(16, 185, 129, 0.08) !important;
}

.validation-warning {
  color: #f87171;
  font-size: 0.8rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

.validation-success {
  color: #34d399;
  font-size: 0.8rem;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 50%, rgba(124, 58, 237, 0.08), transparent 25%),
    radial-gradient(circle at 85% 30%, rgba(168, 85, 247, 0.08), transparent 25%);
  background-attachment: fixed;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Typography */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
h1 { font-size: clamp(1.75rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 3vw, 1.75rem); }
p { color: var(--text-secondary); }

/* Header */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 70px;
  padding: 0 5%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(10, 14, 26, 0.8);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.5px;
}
.logo-icon { color: var(--accent-light); }

.step-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.step-dot {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}
.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  transition: var(--transition);
}
.step-dot.active { color: var(--text-primary); }
.step-dot.active .step-number {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px var(--accent-glow);
}
.step-dot.completed .step-number {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.step-line {
  width: 30px;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
}

/* Layout */
main {
  margin-top: 70px;
  padding: 2rem 5%;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.step {
  display: none;
  animation: fadeIn 0.4s ease-out forwards;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}
.step.active { display: block; }
.step-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

/* Templates Grid */
.templates-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 768px) { .templates-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .templates-grid { grid-template-columns: repeat(3, 1fr); } }

.template-card {
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.template-card:hover {
  transform: translateY(-5px);
  background: var(--bg-card-hover);
  border-color: var(--accent-light);
  box-shadow: 0 10px 30px var(--accent-glow);
}
.template-icon {
  font-size: 2.5rem;
  background: var(--bg-secondary);
  width: 60px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.template-card h3 { font-size: 1.25rem; }
.template-card p { font-size: 0.9rem; margin: 0; }

/* Step 2 Layout */
.step2-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  margin-bottom: 2rem;
}
@media (min-width: 1024px) {
  .step2-layout {
    flex-direction: row;
    align-items: flex-start;
  }
  .fields-panel { width: 55%; }
  .upload-panel { width: 45%; position: sticky; top: 90px; }
}

.panel-header { margin-bottom: 1.5rem; }

/* Forms */
.fields-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
}
.form-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--font-family);
  font-size: 1rem;
  transition: var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* AI Populated Field Styles */
.form-group.ai-filled .form-control {
  border-left: 4px solid var(--accent);
  background: rgba(124, 58, 237, 0.05);
}
.ai-badge {
  position: absolute;
  top: 0; right: 0;
  font-size: 0.75rem;
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  display: flex; align-items: center; gap: 4px;
}
.ai-actions {
  display: flex; gap: 0.5rem;
  margin-top: 0.25rem;
}
.ai-btn {
  background: transparent;
  border: none;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: var(--transition);
}
.ai-btn.accept { color: var(--success); }
.ai-btn.accept:hover { background: rgba(16, 185, 129, 0.1); }
.ai-btn.reject { color: var(--danger); }
.ai-btn.reject:hover { background: rgba(239, 68, 68, 0.1); }

/* Upload Zone */
.upload-zone {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 1rem;
}
.upload-zone:hover {
  border-color: var(--border-highlight);
  background: var(--bg-card-hover);
}
.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(124, 58, 237, 0.1);
  transform: scale(1.02);
  animation: borderDash 1s linear infinite;
}
.upload-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}
.upload-hint { font-size: 0.875rem; margin-top: 0.25rem; }
.upload-formats {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

/* Uploaded Files */
.uploaded-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0;
}
.file-chip {
  display: flex;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  gap: 0.75rem;
  animation: fadeIn 0.3s ease;
}
.file-chip-icon { font-size: 1.25rem; }
.file-chip-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.file-chip-name {
  font-size: 0.875rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-chip-size {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.file-chip-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.file-chip-delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  font-family: var(--font-family);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: white;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.2);
}
.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-secondary);
  border-color: var(--text-muted);
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}
.btn-full { width: 100%; }
.btn-recognize { margin-top: 0.5rem; padding: 1rem; font-size: 1.05rem; }
.btn-generate { padding: 1rem 2rem; font-size: 1.05rem; }

.step2-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Result Step */
.result-card {
  max-width: 500px;
  margin: 4rem auto;
  background: var(--bg-card);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.result-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: pulse 2s infinite;
}
.result-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: var(--bg-secondary);
  padding: 1rem;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}
.result-file .file-icon { font-size: 1.5rem; }
.result-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.spinner {
  width: 50px; height: 50px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: translateY(0);
  transition: transform 0.3s ease;
}
.modal.hidden .modal-content { transform: translateY(20px); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
}
.modal-desc { margin-bottom: 2rem; font-size: 0.9rem; }

/* Audio visualizer */
.audio-visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 60px;
  margin-bottom: 1rem;
}
.audio-visualizer .bar {
  width: 6px;
  height: 10px;
  background: var(--accent);
  border-radius: 3px;
  transition: height 0.1s ease;
}
.audio-visualizer.recording .bar {
  animation: soundBounce 1s ease-in-out infinite alternate;
}
.audio-visualizer.recording .bar:nth-child(2) { animation-delay: 0.2s; }
.audio-visualizer.recording .bar:nth-child(3) { animation-delay: 0.4s; }
.audio-visualizer.recording .bar:nth-child(4) { animation-delay: 0.1s; }
.audio-visualizer.recording .bar:nth-child(5) { animation-delay: 0.3s; }

.recording-time {
  text-align: center;
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  margin-bottom: 2rem;
  font-weight: 300;
}
.audio-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.record-dot {
  width: 10px; height: 10px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
}
.stop-square {
  width: 10px; height: 10px;
  background: currentColor;
  display: inline-block;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}
.toast {
  background: var(--bg-secondary);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.3);
  animation: slideInRight 0.3s ease forwards;
  max-width: 350px;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes borderDash {
  to { border-dashoffset: 20; }
}
@keyframes soundBounce {
  0% { height: 10px; }
  100% { height: 50px; }
}

/* Responsive */
@media (max-width: 767px) {
  header { padding: 0 1rem; }
  .step-label { display: none; }
  main { padding: 1.5rem 1rem; }
  
  .step2-actions {
    flex-direction: column-reverse;
    gap: 1rem;
  }
  .step2-actions .btn { width: 100%; }
  
  .toast-container {
    bottom: 1rem; left: 1rem; right: 1rem;
    align-items: center;
  }
  .toast { width: 100%; max-width: none; }
}

/* Field validation error */
.form-control.field-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

/* Warning toast */
.toast.warning { border-left-color: var(--warning); }

/* Empty/Error messages in template grid */
.empty-message,
.error-message {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  font-size: 1.1rem;
  grid-column: 1 / -1;
}
.error-message {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.05);
  border-radius: var(--radius);
  border: 1px solid rgba(239, 68, 68, 0.15);
}

/* Input placeholder */
.form-control::placeholder {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

