/* ============================================================================
   Receiving Form - dark theme (App Styling Playbook)
   Source of truth: /home/clawdbot/clawd/shared/fba-design-system.css
   ============================================================================ */

:root {
  /* Backgrounds */
  --bg-body:        #0f172a;
  --bg-card:        #1e293b;
  --bg-input:       #0f172a;
  --border-default: #1e293b;
  --border-card:    #334155;
  --border-input:   #334155;

  /* Text */
  --text-bright:    #f8fafc;
  --text-heading:   #f1f5f9;
  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-dim:       #475569;
  --text-faint:     #334155;

  /* Accent */
  --accent-blue:      #60a5fa;
  --accent-blue-dark: #3b82f6;
  --accent-indigo:    #6366f1;

  /* Semantic */
  --color-success: #4ade80;
  --color-success-dark: #059669;
  --color-warning: #fbbf24;
  --color-danger:  #f87171;
  --color-danger-dark: #dc2626;
  --color-info:    #38bdf8;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;

  /* Transitions */
  --transition-fast:   0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow:   0.3s ease;

  /* Layout */
  --container-max: 640px;
  --card-radius:   12px;
  --input-radius:  8px;
  --badge-radius:  9999px;
}

/* ============================================================================
   Reset & Base
   ============================================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  padding: var(--space-md);
  padding-top: var(--space-xl);
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
}

/* ============================================================================
   Typography
   ============================================================================ */
.brand-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
  text-align: center;
  margin-bottom: var(--space-lg);
}

h1 {
  font-size: 18px;
  color: var(--text-heading);
  text-align: center;
  margin-bottom: var(--space-lg);
}

h2 {
  font-size: 14px;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: var(--space-xl) 0 var(--space-md);
}

/* ============================================================================
   Tab Bar (Receiving / COA switcher)
   ============================================================================ */
.tab-bar {
  display: flex;
  border: 1px solid var(--border-card);
  border-radius: var(--input-radius);
  overflow: hidden;
  gap: 1px;
  background: var(--border-card);
  max-width: var(--container-max);
  margin: 0 auto var(--space-lg);
}

.tab-btn {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: none;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.tab-btn.active {
  background: var(--accent-blue-dark);
  color: white;
}

/* ============================================================================
   Card / Form Page
   ============================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--card-radius);
  padding: var(--space-lg);
}

.form-page {
  display: none;
}

.form-page.active {
  display: block;
}

/* ============================================================================
   Form Inputs
   ============================================================================ */
.form-group {
  margin-bottom: var(--space-md);
  position: relative;
}

label {
  display: block;
  margin-bottom: var(--space-xs);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

input,
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--input-radius);
  color: var(--text-primary);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-normal);
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input[type="file"] {
  padding: 8px;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  accent-color: var(--accent-blue-dark);
}

/* Checkbox / radio inline rows */
.check-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 500;
  text-transform: none;
  cursor: pointer;
}

.radio-row {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  padding-top: var(--space-xs);
}

.radio-option {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 400;
  text-transform: none;
  color: var(--text-primary);
  cursor: pointer;
}

/* Batch date row (month/year selects) */
.date-row {
  display: flex;
  gap: var(--space-sm);
}

.date-row select {
  flex: 1;
}

/* File upload group (COA, 2x2 grid) */
.file-upload-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

/* ============================================================================
   Autocomplete
   ============================================================================ */
.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--accent-blue);
  border-top: none;
  border-radius: 0 0 var(--input-radius) var(--input-radius);
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
  display: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

.autocomplete-suggestions.show {
  display: block;
}

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  transition: background var(--transition-fast);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: rgba(96, 165, 250, 0.1);
}

.autocomplete-item mark {
  background: rgba(251, 191, 36, 0.35);
  color: var(--text-heading);
  font-weight: 600;
  padding: 0 2px;
  border-radius: 2px;
}

.no-results {
  padding: 10px 12px;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  font-size: 13px;
}

/* ============================================================================
   Image Preview
   ============================================================================ */
.image-preview {
  display: none;
  margin-top: var(--space-sm);
}

.image-preview.show {
  display: block;
}

.image-preview img {
  max-width: 180px;
  max-height: 180px;
  border-radius: var(--input-radius);
  border: 1px solid var(--border-card);
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
  padding: 12px 16px;
  border-radius: var(--input-radius);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}

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

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-blue-dark));
  color: white;
  margin-top: var(--space-md);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(96, 165, 250, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

/* Inline loading spinner shown inside the submit button */
.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: var(--space-sm);
}

.btn.is-loading .btn-spinner {
  display: inline-block;
}

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

/* ============================================================================
   Toast Notifications
   ============================================================================ */
.toast-container {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  left: var(--space-md);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--input-radius);
  font-size: 13px;
  font-weight: 500;
  color: white;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: toastIn var(--transition-slow), toastOut var(--transition-slow) forwards;
  animation-delay: 0s, calc(var(--toast-life, 3s) - var(--transition-slow));
}

.toast-success { background: var(--color-success-dark); }
.toast-error   { background: var(--color-danger-dark); }
.toast-info    { background: var(--accent-blue-dark); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ============================================================================
   Footer
   ============================================================================ */
.form-footer {
  text-align: center;
  padding: var(--space-lg) 0;
  color: var(--text-dim);
  font-size: 12px;
}

.help-link {
  display: inline-block;
  margin-top: var(--space-xs);
  color: var(--text-secondary);
  text-decoration: underline;
  font-size: 12px;
}

.help-link:hover {
  color: var(--accent-blue);
}

/* ============================================================================
   Mobile Responsive
   ============================================================================ */
@media (max-width: 480px) {
  .file-upload-group {
    grid-template-columns: 1fr;
  }

  .radio-row {
    gap: var(--space-md);
  }

  body {
    padding: var(--space-sm);
    padding-top: var(--space-lg);
  }

  .card {
    padding: var(--space-md);
  }
}

/* ============================================================================
   Print
   ============================================================================ */
@media print {
  body { background: white; color: #1a1a1a; padding-top: 0; }
  .tab-bar, .toast-container, .btn { display: none; }
  .card {
    background: white;
    border: 1px solid #ccc;
    color: #1a1a1a;
  }
}
