/* FieldStock App Styles — matches landing page dark theme */
/* Owns: app chrome, form, supply list output, history. Does NOT own landing page styles. */

/* ============================================================
   App Header
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--fg);
}

.brand-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #0a0f1a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--fg);
}

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

.nav-link {
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.05);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-glow);
}

/* ============================================================
   App Main
   ============================================================ */
.app-main {
  min-height: calc(100vh - 60px);
}

/* ============================================================
   Generator Layout
   ============================================================ */
.generator-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  min-height: calc(100vh - 60px);
}

.form-panel {
  background: var(--surface);
  border-right: 1px solid var(--surface-border);
  padding: 2.5rem 2rem;
  overflow-y: auto;
}

.results-panel {
  padding: 2.5rem 2.5rem;
  overflow-y: auto;
}

/* ============================================================
   Form Panel Header
   ============================================================ */
.panel-header {
  margin-bottom: 2rem;
}

.panel-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  margin-bottom: 1rem;
  font-family: 'Space Grotesk', sans-serif;
}

.panel-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.6rem;
  line-height: 1.2;
}

.panel-lede {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.6;
}

/* ============================================================
   Form
   ============================================================ */
.job-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-group--half {
  min-width: 0;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.02em;
  font-family: 'Space Grotesk', sans-serif;
}

.optional {
  font-weight: 400;
  color: var(--fg-muted);
}

.select-wrapper {
  position: relative;
}

.form-select,
.form-input,
.form-textarea {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  color: var(--fg);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-select {
  padding: 0.65rem 2.5rem 0.65rem 0.9rem;
  appearance: none;
  cursor: pointer;
}

.form-input {
  padding: 0.65rem 0.9rem;
}

.form-textarea {
  padding: 0.75rem 0.9rem;
  resize: vertical;
  min-height: 120px;
  line-height: 1.55;
}

.form-select:focus,
.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.select-arrow {
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--fg-muted);
  pointer-events: none;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--accent);
  color: #0a0f1a;
  border: none;
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  margin-top: 0.25rem;
}

.btn-generate:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-generate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-icon {
  font-size: 1.1rem;
  transition: transform 0.15s;
}

.btn-generate:hover:not(:disabled) .btn-icon {
  transform: translateX(3px);
}

/* ============================================================
   Example Chips
   ============================================================ */
.examples-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--surface-border);
}

.examples-label {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.examples-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.example-chip {
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  color: var(--fg-muted);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.example-chip:hover {
  border-color: var(--accent);
  color: var(--fg);
  background: var(--accent-glow);
}

/* ============================================================
   Results States
   ============================================================ */
.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
  max-width: 440px;
  margin: 4rem auto;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1.25rem;
  opacity: 0.6;
}

.empty-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.75rem;
}

.empty-body {
  color: var(--fg-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.empty-features {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
}

.empty-feature {
  font-size: 0.85rem;
  color: var(--fg-muted);
  padding: 0.2rem 0;
}

.empty-feature::before {
  color: var(--accent);
  margin-right: 0.5rem;
}

/* Loading */
.results-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 1.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.loading-body {
  color: var(--fg-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: left;
}

.loading-step {
  font-size: 0.85rem;
  color: var(--fg-muted);
  padding: 0.3rem 0;
  padding-left: 1.25rem;
  position: relative;
  transition: color 0.3s;
}

.loading-step::before {
  content: '○';
  position: absolute;
  left: 0;
  color: var(--surface-border);
  transition: color 0.3s, content 0.3s;
}

.loading-step.active {
  color: var(--fg);
}

.loading-step.active::before {
  content: '◉';
  color: var(--accent);
}

/* Error */
.results-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 400px;
}

.error-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.error-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.error-body {
  color: var(--fg-muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  max-width: 360px;
}

.btn-retry {
  background: var(--surface-border);
  color: var(--fg);
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-retry:hover { background: #2a3555; }

/* ============================================================
   Supply List Output
   ============================================================ */
.output-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.output-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  background: var(--accent-glow);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 0.3rem 0.75rem;
  border-radius: 100px;
  margin-bottom: 0.6rem;
  font-family: 'Space Grotesk', sans-serif;
}

.output-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 0.3rem;
}

.output-subtitle {
  font-size: 0.875rem;
  color: var(--fg-muted);
}

.output-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.5rem;
}

.btn-copy,
.btn-print {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  color: var(--fg-muted);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-copy:hover,
.btn-print:hover {
  border-color: var(--accent);
  color: var(--fg);
}

/* Summary stats */
.output-summary {
  display: flex;
  gap: 2rem;
  padding: 1rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  margin-bottom: 2rem;
}

.summary-stat {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.summary-number {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.summary-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
}

/* Category sections */
.supply-category {
  margin-bottom: 1.75rem;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--surface-border);
}

.category-name {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fg-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.category-total {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-family: 'Space Grotesk', sans-serif;
}

.category-items {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

/* Individual line items */
.supply-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  transition: background 0.1s;
  align-items: start;
}

.supply-item:hover {
  background: var(--card-bg);
}

.item-qty {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 0.1rem;
}

.item-quantity {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--fg);
  line-height: 1.2;
}

.item-unit {
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-transform: lowercase;
}

.item-details {
  min-width: 0;
}

.item-name-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.item-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.4;
}

.item-spec {
  font-size: 0.78rem;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
}

.item-notes {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin-top: 0.25rem;
  line-height: 1.5;
}

.item-pricing {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  min-width: 80px;
  padding-top: 0.1rem;
}

.item-price {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

.item-total {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
}

/* Footer */
.output-footer {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-note {
  font-size: 0.78rem;
  color: var(--fg-muted);
  max-width: 400px;
}

.btn-new-list {
  background: var(--surface-border);
  color: var(--fg);
  border: none;
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

.btn-new-list:hover { background: #2a3555; color: var(--fg); }

/* ============================================================
   History Page
   ============================================================ */
.history-main {
  padding: 2.5rem;
  max-width: 1000px;
  margin: 0 auto;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.history-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--fg);
}

.btn-new {
  background: var(--accent);
  color: #0a0f1a;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn-new:hover { opacity: 0.9; }

.history-empty {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--fg-muted);
}

.history-empty .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.history-empty h2 { font-family: 'Space Grotesk', sans-serif; color: var(--fg); margin-bottom: 0.5rem; }
.history-empty p { margin-bottom: 1.5rem; font-size: 0.9rem; }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.history-card {
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 1.25rem;
  text-decoration: none;
  display: block;
  transition: border-color 0.15s, transform 0.1s;
}

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

.hcard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.hcard-type {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-family: 'Space Grotesk', sans-serif;
}

.hcard-status {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.hcard-status--complete { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.hcard-status--pending,
.hcard-status--processing { color: var(--accent); background: var(--accent-glow); }
.hcard-status--error { color: #f87171; background: rgba(248, 113, 113, 0.1); }

.hcard-scope {
  font-size: 0.875rem;
  color: var(--fg-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.hcard-footer {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* ============================================================
   Detail Page
   ============================================================ */
.detail-main {
  padding: 2.5rem;
  max-width: 860px;
  margin: 0 auto;
}

.detail-back {
  margin-bottom: 1.5rem;
}

.back-link {
  font-size: 0.875rem;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.back-link:hover { color: var(--fg); }

.job-scope-box {
  background: var(--card-bg);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.scope-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
  font-family: 'Space Grotesk', sans-serif;
}

.scope-text {
  font-size: 0.9rem;
  color: var(--fg);
  line-height: 1.6;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
  .generator-layout {
    grid-template-columns: 1fr;
    min-height: unset;
  }

  .form-panel {
    border-right: none;
    border-bottom: 1px solid var(--surface-border);
  }

  .results-panel {
    padding: 2rem 1.25rem;
  }

  .form-panel {
    padding: 2rem 1.25rem;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 1rem;
  }

  .output-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .output-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .output-summary {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .supply-item {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }

  .item-pricing {
    grid-column: 2;
    align-items: flex-start;
    flex-direction: row;
    gap: 0.5rem;
  }

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

  .history-main,
  .detail-main {
    padding: 1.5rem 1rem;
  }
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
  .app-header,
  .output-actions,
  .output-footer .btn-new-list,
  .detail-back,
  .app-nav {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .output-badge,
  .item-spec {
    border: 1px solid #ccc;
    background: #f5f5f5;
    color: #333;
  }

  .supply-item:hover {
    background: none;
  }

  .category-header {
    border-bottom: 1px solid #ccc;
  }

  .detail-main,
  .output-summary {
    background: white;
    border-color: #ccc;
  }
}
