/* =========================================================
   Magatzem Pirotecnia — sistema de diseño
   Paleta: negro carbon / brasa (evoca polvora, noche, foc)
   Tipografia: Oswald (titulares tipo estarcido de caja de material)
               Inter (texto)
               JetBrains Mono (contadores de stock)
   ========================================================= */

:root {
  --bg: #15100d;
  --surface: #201a16;
  --surface-2: #2a2119;
  --border: #3a2e26;
  --text: #f5efe6;
  --text-muted: #a6968a;

  --accent: #ff7a29;       /* brasa / naranja principal */
  --accent-dark: #c75a15;
  --accent-2: #c7391f;     /* rojo intenso (bestia / restar) */
  --ok: #4c9a6a;           /* verde (general / sumar) */
  --info: #3fa7d6;         /* azul (infantil) */
  --warn: #e0a63a;

  --wh-color: var(--accent);

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);

  --font-display: 'Oswald', 'Arial Narrow', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, rgba(255, 122, 41, 0.07), transparent 45%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin: 0 0 4px;
}

h1 { font-size: 1.9rem; font-weight: 600; }
h2 { font-size: 1.1rem; font-weight: 600; color: var(--text); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.topbar__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #1a1310;
  font-weight: 700;
  font-size: 0.85rem;
}

.topbar__nav {
  display: flex;
  gap: 18px;
  flex: 1;
}

.topbar__nav a {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.92rem;
}

.topbar__nav a:hover {
  color: var(--accent);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ---------- Layout ---------- */
.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.page--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 80px;
}

.page__header {
  margin-bottom: 24px;
}

.page__header--warehouse {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}

.page__subtitle {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.95rem;
}

.back-link {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

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

/* ---------- Login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 30px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card__mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #1a1310;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 700;
}

.login-card__title {
  font-size: 1.3rem;
}

.login-card__subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 6px 0 24px;
}

/* ---------- Forms ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.form--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

.field--full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type='text'],
input[type='password'],
input[type='number'],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}

.form__actions {
  display: flex;
  gap: 10px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text);
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--accent);
  color: #1a1310;
}

.btn--primary:hover {
  background: var(--accent-dark);
}

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

.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn--small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn--block {
  width: 100%;
}

/* ---------- Alerts / badges / states ---------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
}

.alert--error {
  background: rgba(199, 57, 31, 0.15);
  border: 1px solid var(--accent-2);
  color: #ff9d85;
}

.alert--warning {
  background: rgba(224, 166, 58, 0.15);
  border: 1px solid var(--warn);
  color: #f2c877;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.badge--warning {
  border-color: var(--warn);
  color: var(--warn);
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px 0;
}

.stat-pill {
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.stat-pill--warning {
  background: rgba(224, 166, 58, 0.18);
  color: var(--warn);
}

/* ---------- Warehouse cards (etiqueta de caja estarcida) ---------- */
.warehouse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.warehouse-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--wh-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.warehouse-card:hover {
  transform: translateY(-2px);
  border-left-color: var(--wh-color);
  box-shadow: var(--shadow);
}

.warehouse-card__stamp {
  position: absolute;
  top: 14px;
  right: 14px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--wh-color);
  border: 1px solid var(--wh-color);
  border-radius: 4px;
  padding: 2px 6px;
  transform: rotate(3deg);
}

.warehouse-card__name {
  font-size: 1.15rem;
  padding-right: 40px;
}

.warehouse-card__desc {
  color: var(--text-muted);
  font-size: 0.86rem;
  margin: 0;
  flex: 1;
}

.warehouse-card__stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- Panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}

.panel--collapsible {
  border-color: var(--accent);
}

/* ---------- Search ---------- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.search-bar input {
  flex: 1;
}

/* ---------- Product list ---------- */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.product-row__info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 180px;
}

.product-row__name {
  font-weight: 600;
}

.product-row__info:hover .product-row__name {
  color: var(--accent);
}

/* ---------- Stepper: contador tipo caja registradora ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.stepper__btn {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.stepper__btn:hover {
  background: var(--accent);
  color: #1a1310;
}

.stepper__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 2.4em;
  text-align: center;
  transition: color 0.2s ease;
}

.stepper__unit {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-right: 6px;
}

.stepper--large .stepper__value {
  font-size: 1.6rem;
  min-width: 3em;
}

.stepper--large .stepper__btn {
  width: 38px;
  height: 38px;
  font-size: 1.4rem;
}

.stepper--custom {
  background: transparent;
  border: none;
  padding: 0;
}

.stepper--custom input {
  width: 80px;
  padding: 8px 10px;
}

.qty-flash {
  color: var(--accent);
}

.qty-loading {
  opacity: 0.5;
}

.aviso-error {
  position: absolute;
  bottom: -22px;
  right: 16px;
  font-size: 0.75rem;
  color: var(--accent-2);
}

/* ---------- Product detail ---------- */
.product-detail__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 14px;
}

.product-detail__description {
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.6;
}

.definition-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  font-size: 0.88rem;
  margin: 14px 0 0;
}

.definition-list dt {
  color: var(--text-muted);
}

.definition-list dd {
  margin: 0;
}

/* ---------- History ---------- */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.87rem;
}

.history-item__amount {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 3em;
  text-align: right;
}

.history-item__amount--up { color: var(--ok); }
.history-item__amount--down { color: var(--accent-2); }

.history-item__detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item__date {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.history-item__result {
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ---------- Table (admin) ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th, .table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
}

.table th {
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .page {
    padding: 20px 14px 48px;
  }
  .form--grid {
    grid-template-columns: 1fr;
  }
  .product-row {
    flex-direction: column;
    align-items: stretch;
  }
  .stepper--custom {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
