/* ═══════════════════════════════════════════════════════════════
   components.css — Botones, inputs, cards, badges, listas,
                    spinners, skeletons, toasts, quantity stepper
   ═══════════════════════════════════════════════════════════════ */

/* ── Botones ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: none;
  transition: background var(--transition), opacity var(--transition);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:disabled {
  opacity: .45;
  pointer-events: none;
}

.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Variantes */
.btn--primary {
  background: var(--color-primary);
  color: #fff;
}

.btn--primary:active {
  background: var(--color-primary-dark);
}

.btn--secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}

.btn--secondary:active {
  background: var(--color-border);
}

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

.btn--ghost:active {
  background: rgba(227, 24, 55, .08);
}

.btn--danger {
  background: var(--color-error);
  color: #fff;
}

.btn--danger:active {
  background: #a31f1f;
}

.btn--success {
  background: var(--color-success);
  color: #fff;
}

.btn--success:active {
  background: #1b5e20;
}

/* Tamaños */
.btn--sm {
  min-height: 36px;
  padding: 0 14px;
  font-size: .8125rem;
  border-radius: var(--radius-sm);
}

.btn--lg {
  min-height: 56px;
  padding: 0 28px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

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

/* Botón icon-only */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  color: var(--color-text);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.btn-icon:active {
  background: var(--color-bg);
}

.btn-icon svg {
  width: 22px;
  height: 22px;
}

/* ── Inputs y formularios ───────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
}

.field__label--required::after {
  content: " *";
  color: var(--color-primary);
}

.input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(227, 24, 55, .12);
}

.input::placeholder {
  color: var(--color-text-secondary);
  opacity: 1;
}

.input--error {
  border-color: var(--color-error);
}

.input--error:focus {
  box-shadow: 0 0 0 3px rgba(198, 40, 40, .12);
}

.input[type="password"] {
  letter-spacing: .1em;
}

.field__hint {
  font-size: .8125rem;
  color: var(--color-text-secondary);
  margin-top: 4px;
}

.field__error {
  font-size: .8125rem;
  color: var(--color-error);
  display: flex;
  align-items: center;
  gap: 4px;
}

.field__error svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card--interactive {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: box-shadow var(--transition);
}

.card--interactive:active {
  box-shadow: var(--shadow-md);
  background: #fafafa;
}

.card__body {
  padding: 16px;
}

.card__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
}

/* ── Card de producto ───────────────────────────────────────────── */
.product-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.product-card:active {
  background: var(--color-bg);
}

.product-card__img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
}

.product-card__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card__img svg {
  width: 28px;
  height: 28px;
  opacity: .4;
}

.product-card__info {
  flex: 1;
  min-width: 0;
}

.product-card__name {
  font-size: .9375rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.product-card__code {
  font-size: .75rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.product-card__price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
}

.product-card__stock {
  font-size: .75rem;
  margin-top: 2px;
  text-align: right;
}

.product-card__stock--ok    { color: var(--color-success); }
.product-card__stock--low   { color: var(--color-warning); }
.product-card__stock--empty { color: var(--color-error); }

/* ── Card de cliente ────────────────────────────────────────────── */
.client-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.client-card:active {
  background: var(--color-bg);
}

.client-card__avatar {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.125rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.client-card__info {
  flex: 1;
  min-width: 0;
}

.client-card__name {
  font-size: .9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-card__nit {
  font-size: .8125rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.client-card__saldo {
  text-align: right;
  flex-shrink: 0;
}

.client-card__saldo-amount {
  font-size: .875rem;
  font-weight: 700;
  color: var(--color-warning);
}

.client-card__saldo-label {
  font-size: .6875rem;
  color: var(--color-text-secondary);
}

/* ── Quantity stepper (+/-) ─────────────────────────────────────── */
.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  overflow: hidden;
}

.stepper__btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--color-primary);
  background: transparent;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}

.stepper__btn:active {
  background: var(--color-bg);
}

.stepper__btn:disabled {
  color: var(--color-border);
  pointer-events: none;
}

.stepper__value {
  min-width: 44px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
  padding: 0 4px;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
  line-height: 44px;
}

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: .6875rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.badge--primary { background: var(--color-primary);  color: #fff; }
.badge--success { background: var(--color-success);  color: #fff; }
.badge--warning { background: var(--color-warning);  color: #fff; }
.badge--error   { background: var(--color-error);    color: #fff; }
.badge--neutral { background: var(--color-border);   color: var(--color-text-secondary); }

/* Estado del pedido */
.badge--draft     { background: #E3F2FD; color: #1565C0; }
.badge--sale      { background: #E8F5E9; color: var(--color-success); }
.badge--done      { background: #F3E5F5; color: #6A1B9A; }
.badge--cancel    { background: #FFEBEE; color: var(--color-error); }

/* ── Listas de pedido (carrito / historial) ─────────────────────── */
.order-list {
  background: var(--color-surface);
}

.order-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

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

.order-item__info {
  flex: 1;
  min-width: 0;
}

.order-item__name {
  font-size: .9375rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-item__code {
  font-size: .75rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.order-item__qty {
  font-size: .875rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.order-item__price {
  font-size: .9375rem;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
  min-width: 80px;
}

/* ── Resumen totales ────────────────────────────────────────────── */
.order-summary {
  background: var(--color-surface);
  border-radius: var(--radius);
  overflow: hidden;
}

.order-summary__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: .9375rem;
}

.order-summary__row:last-child {
  border-bottom: none;
}

.order-summary__row--total {
  background: var(--color-bg);
  font-size: 1.0625rem;
  font-weight: 700;
}

.order-summary__label {
  color: var(--color-text-secondary);
}

.order-summary__value {
  font-weight: 600;
}

/* ── Skeleton loaders ───────────────────────────────────────────── */
@keyframes skeleton-pulse {
  0%   { opacity: 1; }
  50%  { opacity: .4; }
  100% { opacity: 1; }
}

.skeleton {
  background: var(--color-border);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.skeleton-product {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.skeleton-product__img {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.skeleton-product__lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-product__name  { height: 16px; width: 70%; }
.skeleton-product__code  { height: 12px; width: 30%; }
.skeleton-product__price { height: 18px; width: 20%; align-self: flex-end; }

.skeleton-client {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}

.skeleton-client__avatar {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  flex-shrink: 0;
}

.skeleton-client__lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-client__name { height: 16px; width: 60%; }
.skeleton-client__nit  { height: 12px; width: 40%; }

/* ── Toast / notificación ───────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: calc(var(--navbar-h) + var(--safe-bottom) + 12px);
  left: 16px;
  right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: .9375rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toast-in 150ms ease;
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.toast--success { background: var(--color-success); color: #fff; }
.toast--error   { background: var(--color-error);   color: #fff; }
.toast--warning { background: var(--color-warning); color: #fff; }
.toast--info    { background: var(--color-text);    color: #fff; }

.toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ── Pantalla de login ──────────────────────────────────────────── */
.login-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 24px calc(24px + var(--safe-bottom));
  background: var(--color-surface);
}

.login-page__logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.login-page__logo-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.login-page__logo-icon svg {
  width: 40px;
  height: 40px;
}

.login-page__app-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

.login-page__company {
  font-size: .9375rem;
  color: var(--color-text-secondary);
}

.login-page__form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Dashboard saldo ────────────────────────────────────────────── */
.saldo-card {
  background: var(--color-primary);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saldo-card__label {
  font-size: .8125rem;
  opacity: .85;
  font-weight: 500;
}

.saldo-card__amount {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.saldo-card__sub {
  font-size: .8125rem;
  opacity: .85;
  margin-top: 4px;
}

/* ── Confirmación de pedido ─────────────────────────────────────── */
.confirm-icon {
  width: 72px;
  height: 72px;
  border-radius: 36px;
  background: #E8F5E9;
  color: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.confirm-icon svg {
  width: 40px;
  height: 40px;
}

/* ── Sección con título ─────────────────────────────────────────── */
.section-title {
  font-size: .8125rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 16px 16px 8px;
}
