:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}

body {
  margin: 0;
  padding: 0;
  background: #f5f7fb;
  color: #1a1d26;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

header {
  margin-bottom: 2rem;
}

h1 {
  margin: 0;
  font-size: 2.25rem;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 0.5rem;
  color: #5e6575;
  max-width: 680px;
}

.form-section {
  background: #ffffff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e2e8ff;
  padding-bottom: 0;
}

.tab-button {
  background: transparent;
  color: #5e6575;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  padding: 0.85rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: -2px;
  flex: 0 1 auto;
}

.tab-button:hover {
  background: rgba(79, 70, 229, 0.05);
  color: #4f46e5;
  transform: none;
}

.tab-button.active {
  background: transparent;
  color: #4f46e5;
  border-bottom-color: #4f46e5;
}

.tab-button:active {
  transform: none;
}

/* Tab Content */
.tab-content-wrapper {
  position: relative;
  min-height: 300px;
  max-height: 600px;
  overflow-y: auto;
  padding: 1rem;
  margin: 0 -1rem;
}

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

.tab-content.active {
  display: block;
}

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

.feature-group {
  margin-bottom: 2rem;
  padding: 1.5rem;
  border: 1px solid #e2e8ff;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(237, 241, 255, 0.85), #ffffff);
}

.group-title {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #1f2540;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-grid {
  display: grid;
  gap: 1rem 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}

.field {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.65rem;
  margin: 0;
  background: #f7f8ff;
  border: 1px solid #dde3fb;
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.field label {
  font-weight: 600;
  margin-bottom: 0;
  color: #24314f;
  line-height: 1.35;
}

input[type="number"],
input[type="range"],
select {
  border: 1px solid #cdd5ed;
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:focus,
input[type="range"]:focus,
select:focus {
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
}

input[type="range"] {
  padding: 0.4rem 0;
}

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.range-value {
  min-width: 3.5rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: #4a536a;
  font-weight: 600;
}

.field-grid + .field-grid {
  margin-top: 1.25rem;
}

.feature-group + .feature-group {
  margin-top: 2.5rem;
}

.actions {
  text-align: right;
  margin-top: 1.5rem;
}

button {
  background: #4f46e5;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

button:hover {
  background: #423ab8;
}

button:active {
  transform: translateY(1px);
}

.results {
  margin-top: 2.5rem;
  background: #fff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.prediction-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.metric-label {
  display: block;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6a7287;
  margin-bottom: 0.35rem;
}

.metric-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: #1a1d26;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.75rem;
}

table th,
table td {
  padding: 0.75rem 0.85rem;
  text-align: left;
}

table thead {
  background: #eef1fb;
  color: #373d52;
}

table tbody tr:nth-child(even) {
  background: rgba(238, 241, 251, 0.4);
}

.input-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.85rem 1.5rem;
}

.input-label {
  display: block;
  font-weight: 600;
  color: #2e3548;
}

.input-value {
  display: block;
  color: #58607c;
  margin-top: 0.2rem;
}

.llm-feedback {
  margin-top: 2rem;
  padding: 1.75rem;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(79, 70, 229, 0.02));
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.llm-feedback h3 {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #312e81;
}

.llm-feedback p {
  margin: 0 0 0.75rem;
  line-height: 1.55;
  color: #3a4058;
}

.llm-feedback p:last-child {
  margin-bottom: 0;
}

@media (max-width: 720px) {
  .form-section,
  .results {
    padding: 1.5rem;
  }

  .feature-group {
    padding: 1.25rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .prediction-summary {
    grid-template-columns: 1fr;
  }

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

/* Loading Animation */
.predict-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.button-loading {
  display: none;
  align-items: center;
  gap: 0.3rem;
}

.htmx-request .button-text {
  opacity: 0.6;
}

.htmx-request .button-loading {
  display: flex;
}

.button-loading .dot {
  width: 6px;
  height: 6px;
  background: currentColor;
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out;
}

.button-loading .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.button-loading .dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes dotPulse {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}
