/* ========================================
   ESTILOS - MÓDULO PEDIDOS
   ======================================== */

/* Header */
.pedidos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
  gap: var(--spacing-md);
}

.pedidos-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
}

.pedidos-header p {
  color: var(--gray-500);
  font-size: var(--font-size-sm);
}

/* Filtros */
.pedidos-filters {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  flex-wrap: wrap;
  align-items: center;
}

.pedidos-search {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.pedidos-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--gray-400);
}

.pedidos-search .form-input {
  padding-left: 36px;
}

.pedidos-filters select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--gray-700);
  background: white;
  cursor: pointer;
  min-width: 150px;
}

.pedidos-filters select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.pedidos-count {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-bottom: var(--spacing-md);
}

/* Tabla */
.pedidos-table-wrapper {
  overflow-x: auto;
}

.pedidos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.pedidos-table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}

.pedidos-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-600);
  white-space: nowrap;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pedidos-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.pedidos-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.pedidos-table tbody tr:hover {
  background: var(--gray-50);
}

/* Badge estado pedido */
.badge-estado-pedido {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.badge-estado-pedido .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.badge-estado-pedido.pendiente {
  background: #fef3c7;
  color: #92400e;
}

.badge-estado-pedido.pendiente .dot {
  background: #f59e0b;
}

.badge-estado-pedido.en_preparacion {
  background: #dbeafe;
  color: #1e40af;
}

.badge-estado-pedido.en_preparacion .dot {
  background: #2563eb;
}

.badge-estado-pedido.en_ruta {
  background: #ede9fe;
  color: #5b21b6;
}

.badge-estado-pedido.en_ruta .dot {
  background: #7c3aed;
}

.badge-estado-pedido.entregado {
  background: #dcfce7;
  color: #166534;
}

.badge-estado-pedido.entregado .dot {
  background: #16a34a;
}

.badge-estado-pedido.cancelado {
  background: var(--gray-100);
  color: var(--gray-500);
}

.badge-estado-pedido.cancelado .dot {
  background: var(--gray-400);
}

.badge-estado-pedido.con_incidencia {
  background: #fee2e2;
  color: #991b1b;
}

.badge-estado-pedido.con_incidencia .dot {
  background: #dc2626;
}

/* Número de pedido */
.pedido-numero {
  font-weight: 600;
  color: var(--primary);
  font-family: monospace;
  font-size: var(--font-size-sm);
}

/* Detalle del pedido - modal */
.pedido-detalle-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.pedido-detalle-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.pedido-meta-card {
  padding: 0.75rem 1rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
}

.pedido-meta-card .label {
  font-size: var(--font-size-xs);
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.pedido-meta-card .value {
  font-weight: 600;
  color: var(--gray-800);
}

/* Tabla de productos en pedido */
.pedido-productos-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
  margin-bottom: var(--spacing-md);
}

.pedido-productos-table thead {
  background: var(--gray-50);
}

.pedido-productos-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: var(--font-size-xs);
  color: var(--gray-600);
  text-transform: uppercase;
}

.pedido-productos-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
}

.pedido-productos-table tfoot td {
  border-top: 2px solid var(--gray-200);
  font-weight: 700;
  padding-top: 0.75rem;
}

/* Selector de productos en el form */
.producto-selector {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 0.5rem;
}

.producto-selector-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.producto-selector-header input {
  flex: 1;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
  font-size: var(--font-size-sm);
}

.productos-seleccionados {
  max-height: 300px;
  overflow-y: auto;
}

.producto-linea {
  display: grid;
  grid-template-columns: 1fr 80px 100px 100px 40px;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: var(--font-size-sm);
}

.producto-linea:last-child {
  border-bottom: none;
}

.producto-linea .producto-nombre-linea {
  font-weight: 500;
}

.producto-linea .producto-nombre-linea small {
  color: var(--gray-500);
  font-weight: 400;
}

.producto-linea input {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  text-align: right;
}

.producto-linea .subtotal-linea {
  font-weight: 600;
  text-align: right;
  color: var(--gray-700);
}

.producto-linea .btn-remove-prod {
  background: transparent;
  color: var(--gray-400);
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.producto-linea .btn-remove-prod:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.producto-linea .btn-remove-prod svg {
  width: 16px;
  height: 16px;
}

/* Lista desplegable de productos para agregar */
.producto-dropdown {
  max-height: 360px;
  overflow-y: auto;
  border-top: 1px solid var(--gray-200);
}

.prod-sin-stock {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--warning, #f59e0b);
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  white-space: nowrap;
}

.producto-dropdown-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: background var(--transition-fast);
}

.producto-dropdown-item:hover {
  background: var(--primary-light);
}

.producto-dropdown-item .prod-info {
  font-weight: 500;
}

.producto-dropdown-item .prod-info small {
  color: var(--gray-500);
  font-weight: 400;
}

.producto-dropdown-item .prod-precio {
  color: var(--gray-600);
  font-weight: 500;
}

/* Total del pedido */
.pedido-total-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  margin-top: var(--spacing-md);
}

.pedido-total-bar .total-label {
  font-weight: 600;
  color: var(--gray-600);
}

.pedido-total-bar .total-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--gray-800);
}

/* Cambiar estado inline */
.estado-selector {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.estado-selector button {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  background: var(--gray-100);
  color: var(--gray-600);
  transition: all var(--transition-fast);
}

.estado-selector button:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.estado-selector button.active {
  background: var(--primary);
  color: white;
}

/* Empty state */
.pedidos-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}

.pedidos-empty svg {
  width: 64px;
  height: 64px;
  color: var(--gray-300);
  margin: 0 auto 1rem;
}

.pedidos-empty h3 {
  font-size: var(--font-size-lg);
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
  .pedidos-header {
    flex-direction: column;
    align-items: stretch;
  }

  .pedidos-filters {
    flex-direction: column;
  }

  .pedidos-search {
    min-width: 100%;
  }

  .pedidos-filters select {
    min-width: 100%;
  }

  .pedido-detalle-meta {
    grid-template-columns: 1fr;
  }

  .producto-linea {
    grid-template-columns: 1fr 60px 80px 80px 32px;
    font-size: var(--font-size-xs);
  }

  .pedido-detalle-header {
    flex-direction: column;
  }

  .estado-selector {
    width: 100%;
  }

  .estado-selector button {
    flex: 1;
    text-align: center;
  }
}
