/* ==========================================================================
  Rio Setup Page — Styles
  Extends the base dark monochrome theme from style.css
  ========================================================================== */

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.setup {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px clamp(14px, 2.5vw, 28px) 40px;
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.setup__tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  background: var(--bg-surface-soft);
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 16px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.tab-btn--active {
  background: #f1f1f1;
  color: #111;
}

.tab-btn--active .icon {
  color: #111;
}

.tab-btn--active:hover {
  background: #ffffff;
  color: #111;
}

/* --------------------------------------------------------------------------
   Tab content
   -------------------------------------------------------------------------- */
.tab-content {
  display: none;
}

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

/* --------------------------------------------------------------------------
   Form sections (fieldsets)
   -------------------------------------------------------------------------- */
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--panel-radius);
  padding: 18px;
  margin-bottom: 20px;
  background: var(--bg-surface);
}

.form-section--danger {
  border-color: rgba(255, 255, 255, 0.2);
}

.form-section--danger .form-section__title {
  color: var(--text-primary);
}

.form-section__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
  padding: 0;
}

/* --------------------------------------------------------------------------
   Form groups
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 14px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.form-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  line-height: 1.45;
}

.req {
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   Inputs
   -------------------------------------------------------------------------- */
input[type="text"],
input[type="url"],
input[type="email"],
input[type="tel"],
textarea,
select {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  transition: border-color var(--transition-fast);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 5l3 3 3-3' stroke='%23909090' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea {
  resize: vertical;
  min-height: 52px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */
.form-row {
  display: flex;
  gap: 14px;
}

.form-row > .form-group {
  flex: 1;
}

.form-row--toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background var(--transition-base);
}

.toggle__track::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: all var(--transition-base);
}

.toggle input:checked + .toggle__track {
  background: #e8e8e8;
}

.toggle input:checked + .toggle__track::after {
  transform: translateX(18px);
  background: #111;
}

/* --------------------------------------------------------------------------
   Radio cards (homework mode)
   -------------------------------------------------------------------------- */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.radio-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-base);
}

.radio-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.radio-card input[type="radio"] {
  display: none;
}

.radio-card input[type="radio"]:checked ~ .radio-card__title {
  color: var(--text-primary);
}

.radio-card input[type="radio"]:checked ~ .radio-card__title::before {
  background: #f1f1f1;
  border-color: #f1f1f1;
}

.radio-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.radio-card__title::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.radio-card__desc {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-left: 22px;
}

/* --------------------------------------------------------------------------
   Tier cards
   -------------------------------------------------------------------------- */
.tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.tier-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.tier-card__label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.tier-card input {
  font-size: 11px;
  padding: 5px 8px;
}

/* --------------------------------------------------------------------------
   FAQ dynamic list
   -------------------------------------------------------------------------- */
.faq-item {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  align-items: flex-start;
}

.faq-item__fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.faq-item input {
  font-size: 12px;
}

.faq-item .btn-remove {
  margin-top: 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.faq-item .btn-remove:hover {
  background: var(--bg-surface-hover);
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 9px 16px;
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn--primary {
  background: #f1f1f1;
  color: #111;
}

.btn--primary:hover {
  background: #ffffff;
}

.btn--primary .icon {
  color: #111;
}

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

.btn--ghost:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Form actions (save row)
   -------------------------------------------------------------------------- */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 0 46px;
}

/* --------------------------------------------------------------------------
   Toast notification
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  top: 64px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  z-index: 999;
  animation: toast-in 0.3s ease;
}

.toast--hidden {
  display: none;
}

.toast__icon {
  font-size: 16px;
}

.toast--error {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text-secondary);
}

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

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

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

  .setup {
    padding: 14px 10px 30px;
  }

  .form-section {
    padding: 14px;
  }
}

/* --------------------------------------------------------------------------
   Status badges (API Key, Vertex AI)
   -------------------------------------------------------------------------- */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.status-badge--ok {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.status-badge--missing {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-badge--muted {
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
}

.status-badge--unknown {
  background: var(--bg-elevated);
  color: var(--text-tertiary);
  border: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Model badge (monospace display)
   -------------------------------------------------------------------------- */
.model-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.2);
  word-break: break-all;
}
