/* Wiliot Tools UI — shared look matching the Deployment Tool app.
   Header (logo + title + avatar), light-gray content, outlined cards,
   contained primary button. Mobile-first; centered card on wider screens. */

:root {
  --wlt-primary: #378FA5;
  --wlt-primary-dark: #2d7888;
  --wlt-text: #3F434F;
  --wlt-text-secondary: #6b7280;
  --wlt-border: #e4e6eb;
  --wlt-bg: #f6f7f9;
  --wlt-card-bg: #ffffff;
  --wlt-radius: 10px;
  --wlt-good: #1a9d6b;
  --wlt-bad: #c0392b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--wlt-text);
  background: #eceef1;
  -webkit-font-smoothing: antialiased;
}

/* App shell — full screen on mobile, centered outlined card on desktop.
   100dvh (dynamic viewport height) is critical on mobile: 100vh on Chrome
   for Android counts the URL bar area, which pushes the footer (Submit
   button) off the visible viewport. 100dvh adapts as the URL bar collapses. */
.wlt-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;       /* fallback for older browsers */
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--wlt-bg);
}

@media (min-width: 520px) {
  .wlt-app {
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 32px);
    margin: 16px auto;
    border: 1px solid var(--wlt-border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.04);
  }
}

/* ---- Header ---- */
.wlt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  padding: 14px 20px;
  border-bottom: 1px solid var(--wlt-border);
}

.wlt-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.wlt-header__brand a {
  display: inline-flex;
  line-height: 0;
}

.wlt-header__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--wlt-text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Close (X) link used on sub-pages */
.wlt-header__back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--wlt-text);
  text-decoration: none;
}
.wlt-header__back svg { width: 22px; height: 22px; }

/* Avatar with user initials */
.wlt-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--wlt-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.3px;
}

/* Plain text action button (e.g. Reset) in the header */
.wlt-text-btn {
  background: none;
  border: none;
  color: var(--wlt-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 6px 4px;
  cursor: pointer;
}
.wlt-text-btn:active { color: var(--wlt-primary-dark); }

/* ---- Content ---- */
.wlt-content {
  flex: 1;
  padding: 22px 20px;
}

.wlt-welcome__title {
  font-size: 1.5rem;
  font-weight: 500;
  margin: 0 0 4px;
  color: var(--wlt-text);
}
.wlt-welcome__subtitle {
  font-size: 0.95rem;
  color: var(--wlt-text-secondary);
  margin: 0 0 22px;
}

.wlt-section-title {
  font-size: 1.4rem;
  font-weight: 500;
  margin: 0 0 14px;
  color: var(--wlt-text);
}
.wlt-divider {
  border: 0;
  border-top: 1px solid var(--wlt-border);
  margin: 0 0 18px;
}

/* ---- Cards ---- */
.wlt-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--wlt-card-bg);
  border: 1px solid var(--wlt-border);
  border-radius: var(--wlt-radius);
  padding: 18px 16px;
  margin-bottom: 14px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.wlt-card:hover {
  border-color: #cdd2da;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.wlt-card:active { background: #fafbfc; }

.wlt-card__icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  color: var(--wlt-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.wlt-card__icon svg { width: 100%; height: 100%; }

.wlt-card__title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 2px;
  color: var(--wlt-text);
}
.wlt-card__subtitle {
  font-size: 0.9rem;
  color: var(--wlt-text-secondary);
  margin: 0;
}

/* ---- Form fields ---- */
.wlt-field { margin-bottom: 18px; }

.wlt-field-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--wlt-text-secondary);
  margin-bottom: 7px;
}
.wlt-field-label.good { color: var(--wlt-good); }
.wlt-field-label.bad { color: var(--wlt-text-secondary); }

.wlt-input,
.wlt-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--wlt-border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--wlt-text);
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}
.wlt-input:focus,
.wlt-select:focus {
  outline: none;
  border-color: var(--wlt-primary);
  box-shadow: 0 0 0 3px rgba(55, 143, 165, 0.15);
}
.wlt-input:disabled { background: #fff; color: var(--wlt-text); }

textarea.wlt-input {
  resize: vertical;
  line-height: 1.5;
}

/* Chevron for selects */
.wlt-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

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

.wlt-submitted {
  font-size: 0.95rem;
  color: var(--wlt-text);
  margin: 18px 0 0;
}
.wlt-submitted span { font-weight: 600; }

/* Debug toggle — small and unobtrusive */
.wlt-debug {
  margin-top: 22px;
  font-size: 0.85rem;
  color: var(--wlt-text-secondary);
}
.wlt-debug textarea {
  width: 100%;
  margin-top: 8px;
  border: 1px solid var(--wlt-border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  padding: 10px;
}

/* ---- Footer button ---- */
.wlt-footer {
  padding: 16px 20px;
  background: #fff;
  border-top: 1px solid var(--wlt-border);
  /* Sticky so it stays visible even when content overflows the viewport
     (e.g. mobile with a virtual keyboard, or a long history list). */
  position: sticky;
  bottom: 0;
}

.wlt-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  background: var(--wlt-primary);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}
.wlt-btn:not(:disabled):hover { background: var(--wlt-primary-dark); }
.wlt-btn:not(:disabled):active { background: var(--wlt-primary-dark); }
.wlt-btn:disabled {
  background: #e4e6eb;
  color: #a0a4ab;
  cursor: not-allowed;
}
