/*
 * Ported from shy_inventory's original app/assets/stylesheets/application.css
 * during the Rails-engine migration into shy_hub.
 *
 * Deliberately DROPPED from the original file: the global element resets
 * (body/a/h1-h3/p/small) and the whole page-shell/sidebar/nav/flash system
 * (.app-shell, .sidebar*, .nav-link, .nav-icon, .content, .flash*, etc).
 * Those assumed this stylesheet owned the entire page; now shy_hub's own
 * layout + Shared::NavComponent/Shared::FlashComponent own that chrome, and
 * this file (like every engine's own stylesheet) is pulled in globally via
 * `stylesheet_link_tag :all` -- letting element-level rules like `body {}`
 * survive here would leak into every other page in the app, including
 * shy_hub's own dashboard and any other engine's views.
 *
 * Known interim state: these component styles (tables, badges, forms, the
 * voice-command widget) still use their own original dark-theme custom
 * properties below, which don't match shy_hub's light `--shy-*` design
 * system yet. Functional, but visually inconsistent where inventory content
 * meets the shared chrome -- flagged as follow-up design-consolidation work,
 * not a Phase 1 blocker (see the shy_hub migration plan).
 */
:root {
  --bg: #0a0a0c;
  --surface: #111113;
  --surface-2: #17171a;
  --surface-3: #202024;
  --border: #26262b;
  --border-strong: #35353c;

  --text: #f4f4f5;
  --text-dim: #a1a1aa;
  --text-faint: #6b6b74;

  --accent: #7c6df2;
  --accent-strong: #9a8dff;
  --accent-bg: rgba(124, 109, 242, 0.14);
  --accent-border: rgba(124, 109, 242, 0.35);

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.28);

  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --warn-border: rgba(251, 191, 36, 0.28);

  --danger: #fb7185;
  --danger-bg: rgba(251, 113, 133, 0.12);
  --danger-border: rgba(251, 113, 133, 0.28);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

.text-faint { color: var(--text-faint); }
.field small { display: block; margin-top: 0.35rem; font-size: 0.78rem; }

/* iOS Safari zooms the page on focusing any input smaller than 16px. */
@media (max-width: 860px) {
  .field input, .field select, .field textarea,
  .bulk-table input, .weight-field input, .colorway-name-input {
    font-size: 16px;
  }

  .stat-row, .form-row { flex-direction: column; }
}
/* Badges */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge-reorder { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge-alert { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge-ok { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }

/* Stat tiles / cards */

.stat-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  flex: 1;
  min-width: 190px;
  box-shadow: var(--shadow);
}

.stat h3 {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0 0 0.85rem;
  font-weight: 600;
}

.stat .value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .label {
  color: var(--text-faint);
  font-size: 0.78rem;
  margin-top: 0.2rem;
}

/* Forms */

form.inline { display: inline; }

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

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

.field textarea { resize: vertical; min-height: 4.5rem; }

.actions { margin-top: 1.1rem; }

.actions button,
.actions input[type="submit"],
input[type="submit"],
button[type="submit"] {
  padding: 0.55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.05s ease;
}

.actions button:hover,
.actions input[type="submit"]:hover,
input[type="submit"]:hover,
button[type="submit"]:hover {
  background: var(--accent-strong);
}

.actions button:active,
.actions input[type="submit"]:active,
input[type="submit"]:active,
button[type="submit"]:active {
  transform: translateY(1px);
}

/* Delete buttons (button_to) get no wrapping .actions class; give them a
   quieter, ghost danger treatment instead of the default filled button. */
form.inline button[type="submit"],
button.inline[type="submit"] {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-border);
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
}

form.inline button[type="submit"]:hover,
button.inline[type="submit"]:hover {
  background: var(--danger-bg);
}

.error-messages {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.85rem;
}
.error-messages ul { margin: 0; padding-left: 1.1rem; }

/* Bulk row entry */

.bulk-table td { vertical-align: top; }

.bulk-table input {
  width: 100%;
  padding: 0.45rem 0.6rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.bulk-table input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

.bulk-table input[type="number"] { text-align: right; }

.field-error {
  display: block;
  color: var(--danger);
  margin-top: 0.3rem;
  font-size: 0.72rem;
}

.row-remove {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  font-family: inherit;
}

.row-remove:hover {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.bulk-actions { display: flex; gap: 0.6rem; align-items: center; }

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

.actions button.btn-ghost:hover {
  background: var(--surface-3);
  border-color: var(--accent-border);
}

/* Sidebar section grouping */

.nav-section-label {
  margin: 1.1rem 0.7rem 0.35rem;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Inline field rows (e.g. batch number + date side by side) */

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .field { flex: 1; }

/* Wide tables (grids with many weight columns) scroll within themselves
   instead of pushing the page wider than the viewport. */

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.table-scroll table { margin-bottom: 0; }

.sub-th {
  background: var(--surface-2);
  color: var(--text-faint);
  font-weight: 500;
  font-size: 0.68rem;
  text-transform: none;
  letter-spacing: normal;
}

/* Colorway entry cards (batch production grid) */

.colorway-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

.colorway-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.colorway-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.65rem 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-3);
}

.colorway-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.35rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.colorway-name-input::placeholder { color: var(--text-faint); font-weight: 500; }

.colorway-name-input:focus {
  outline: none;
  background: var(--surface);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

.colorway-card-body { padding: 0.15rem 0.85rem; }

.weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
}

.weight-row:last-child { border-bottom: none; }

.weight-label {
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.weight-inputs { display: flex; gap: 0.5rem; flex-shrink: 0; }

.weight-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.weight-field span {
  font-size: 0.62rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.weight-field input {
  width: 60px;
  padding: 0.4rem;
  text-align: center;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.weight-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

/* Floating voice-command mic button */

.voice-widget {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
}

.voice-status {
  max-width: 260px;
  padding: 0.5rem 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.8rem;
  box-shadow: var(--shadow);
  text-align: right;
}

.voice-status:empty { display: none; }

.voice-active-link {
  padding: 0.35rem 0.7rem;
  background: var(--accent-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.voice-mic-btn {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(145deg, var(--accent), #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px -4px rgba(124, 109, 242, 0.6), var(--shadow);
  transition: transform 0.12s ease;
}

.voice-mic-btn svg { width: 24px; height: 24px; }

.voice-mic-btn:hover { transform: scale(1.05); }
.voice-mic-btn:active { transform: scale(0.96); }

.voice-mic-btn:disabled {
  background: var(--surface-3);
  color: var(--text-faint);
  cursor: not-allowed;
  box-shadow: none;
}

.voice-widget.listening .voice-mic-btn {
  background: linear-gradient(145deg, var(--danger), #e11d48);
  animation: voice-pulse 1.4s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.5), var(--shadow); }
  50% { box-shadow: 0 0 0 12px rgba(251, 113, 133, 0), var(--shadow); }
}

@media (max-width: 860px) {
  .voice-widget { right: 1rem; bottom: 1rem; }
}

/* Voice command conversation thread */

.turn {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.turn-transcript { font-style: italic; }

.turn-summary { color: var(--text-faint); margin-top: 0.4rem; }
.turn-summary > *:first-child { margin-top: 0; }
.turn-summary > *:last-child { margin-bottom: 0; }
.turn-summary p { margin: 0.5rem 0; }
.turn-summary ul, .turn-summary ol { margin: 0.5rem 0; padding-left: 1.4rem; }
.turn-summary li { margin: 0.2rem 0; }
.turn-summary strong { color: var(--text); font-weight: 600; }
.turn-summary code {
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}
.turn-log { margin-top: 0.6rem; }
.turn-log summary { cursor: pointer; color: var(--text-faint); font-size: 0.85rem; }

.turn-log-entries {
  margin-top: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.turn-log-entry { padding: 0.25rem 0; border-bottom: 1px dashed var(--border); }
.turn-log-entry:last-child { border-bottom: none; }

.spinner-row { display: flex; align-items: center; gap: 0.6rem; }

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent, var(--text));
  border-radius: 50%;
  animation: spinner-spin 0.7s linear infinite;
}

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