:root {
  --bg: #0a0b0f;
  --fg: #e9eaee;
  --muted: #a3a6b3;
  --accent: #8a6eff;
  --accent-light: #b597ff;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f85149;
  --card-bg: rgba(255, 255, 255, 0.03);
  --border: rgba(255, 255, 255, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  scroll-behavior: smooth;
}

body {
  font-family: 'Montserrat', system-ui, sans-serif;
  background: linear-gradient(180deg, #0a0b0f 0%, #100c1b 50%, #0a0b0f 100%);
  color: var(--fg);
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle at 40% 15%, rgba(138, 110, 255, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 75% 85%, rgba(138, 110, 255, 0.2) 0%, transparent 60%),
    radial-gradient(circle at 20% 70%, rgba(138, 110, 255, 0.1) 0%, transparent 60%);
  z-index: 0;
  pointer-events: none;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 0 3rem;
  gap: 1rem;
}

header>button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.logo {
  font-weight: 700;
  font-size: 1.4rem;
  background: linear-gradient(90deg, #8a6eff, #b597ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.nav button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav button:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  margin-bottom: 2rem;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
}

.card:hover {
  border-color: rgba(138, 110, 255, 0.3);
  box-shadow: 0 8px 30px rgba(138, 110, 255, 0.2);
}

h1 {
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  margin: 0 0 1rem 0;
  background: linear-gradient(90deg, #8a6eff, #b597ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 1.5rem 0;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

h2 i {
  color: var(--accent);
  font-size: 1.5rem;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 1rem;
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background: rgba(138, 110, 255, 0.05);
}

.upload-zone:hover {
  border-color: var(--accent);
  background: rgba(138, 110, 255, 0.1);
  transform: translateY(-2px);
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: rgba(138, 110, 255, 0.15);
  transform: scale(1.02);
}

.upload-zone i {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.upload-zone p {
  color: var(--muted);
  margin: 0.5rem 0;
}

.upload-zone .highlight {
  color: var(--accent);
  font-weight: 600;
}

.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.image-preview {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.image-preview:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(138, 110, 255, 0.3);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview .remove-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(248, 81, 73, 0.9);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 0.9rem;
}

.image-preview .remove-btn:hover {
  background: var(--danger);
  transform: scale(1.1);
}

button.action {
  width: 100%;
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, rgba(138, 110, 255, 0.8), rgba(181, 151, 255, 0.9));
  border: none;
  border-radius: 999px;
  color: var(--fg);
  font-weight: 700;
  font-size: 1rem;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button.action:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 25px rgba(138, 110, 255, 0.4);
}

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

button.action.secondary {
  background: rgba(138, 110, 255, 0.2);
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

thead {
  background: rgba(138, 110, 255, 0.1);
}

th {
  padding: 1rem 0.8rem;
  text-align: left;
  font-weight: 600;
  color: var(--accent-light);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--accent);
}

td {
  padding: 1rem 0.8rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: middle;
}

tr:hover {
  background: rgba(138, 110, 255, 0.05);
}

.status-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.status-badge.completed {
  background: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

.status-badge.pending {
  background: rgba(251, 191, 36, 0.2);
  color: var(--warning);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}

.empty-state i {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 1rem;
  opacity: 0.5;
}

.tabs {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
}

.tab {
  padding: 0.8rem 1.5rem;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.tab:hover {
  color: var(--accent);
}

.tab.active {
  color: var(--accent);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

/* Sub-tabs (smaller) */
.sub-tabs .tab {
  padding: 0.7rem 1.2rem;
  font-size: 0.9rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.job-output {
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  color: var(--accent-light);
  word-break: break-word;
  max-width: 400px;
  overflow-x: auto;
}

textarea {
  width: 100%;
  min-height: 200px;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--fg);
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  resize: vertical;
  transition: all 0.2s ease;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 110, 255, 0.1);
}

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
}

.modal-back-btn {
  position: fixed;
  top: 2rem;
  left: 2rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  backdrop-filter: blur(10px);
  z-index: 1001;
}

.modal-back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(138, 110, 255, 0.3);
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(138, 110, 255, 0.3);
  animation: slideUp 0.3s ease;
}

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

.modal h3 {
  margin: 0 0 1rem 0;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.modal input {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--fg);
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.modal input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(138, 110, 255, 0.1);
}

.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 0.7rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-size: 0.95rem;
}

.modal-actions button:hover {
  transform: translateY(-2px);
}

.modal-actions button.primary {
  background: linear-gradient(90deg, rgba(138, 110, 255, 0.8), rgba(181, 151, 255, 0.9));
  border: none;
}

/* Toast Styles */
.toast-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  pointer-events: none;
}

.toast {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 1rem 1.5rem;
  min-width: 300px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: slideInRight 0.3s ease;
  pointer-events: all;
}

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

.toast.hide {
  animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideOutRight {
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast.success {
  border-color: rgba(74, 222, 128, 0.5);
  background: rgba(74, 222, 128, 0.1);
}

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

.toast.error {
  border-color: rgba(248, 81, 73, 0.5);
  background: rgba(248, 81, 73, 0.1);
}

.toast.error .toast-icon {
  color: var(--danger);
}

.toast.warning {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.1);
}

.toast.warning .toast-icon {
  color: var(--warning);
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-weight: 700;
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}

.toast-message {
  color: var(--muted);
  font-size: 0.85rem;
}

.refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Visual Schema Builder Styles */
.schema-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto auto;
  gap: 1rem;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.schema-field-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.schema-field-row input[type="text"],
.schema-field-row select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--fg);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.9rem;
}

.schema-field-row input:focus,
.schema-field-row select:focus {
  outline: none;
  border-color: var(--accent);
}

.schema-field-row .req-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  cursor: pointer;
}

.schema-field-row .remove-field-btn {
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.schema-field-row .remove-field-btn:hover {
  transform: scale(1.1);
  color: #ff7066;
}

/* Code Snippet Styles */
pre {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: var(--accent-light);
}

code {
  font-family: 'Courier New', monospace;
}

pre .comment {
  color: var(--muted);
}

pre .key {
  color: var(--accent);
}

pre .string {
  color: var(--success);
}

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

  header {
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 2rem;
  }

  h1 {
    font-size: 2rem;
  }

  .tabs {
    flex-wrap: wrap;
  }

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

  table {
    font-size: 0.8rem;
  }

  th,
  td {
    padding: 0.6rem 0.4rem;
  }

  .toast-container {
    top: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    min-width: auto;
    width: 100%;
  }

  .modal-back-btn {
    top: 1rem;
    left: 1rem;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
  }

  .schema-field-row {
    grid-template-columns: 1fr 1fr;
  }

  .schema-field-row .desc-label,
  .schema-field-row .req-label,
  .schema-field-row .remove-field-btn {
    grid-column: 1 / -1;
  }

  .schema-field-row .req-label {
    justify-self: start;
  }

  .schema-field-row .remove-field-btn {
    justify-self: end;
  }
}