/* Reset y variables CSS */
:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --success-color: #10b981;
  --success-hover: #059669;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --warning-color: #f59e0b;
  --warning-bg: #fef3c7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --border-radius: 0.5rem;
  --transition: all 0.2s ease-in-out;
}

* {
  box-sizing: border-box;
}

#seccion-pedidos,
#seccion-clientes,
#seccion-usuarios,
#seccion-editar-usuario,
#seccion-crear-usuario,
#seccion-notificaciones,
#seccion-observaciones,
#seccion-editar-pedido {
  display: none;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
}

.label {
  margin-left: 0.6rem;
  display: inline;
}

/* Estilos para la información del pedido */
.pedido-info,
.estadisticas-info {
  background: var(--white);
  padding: 1.5rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.pedido-info p {
  margin: 0.5rem 0;
  font-size: 0.875rem;
}

.pedido-info ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.pedido-info li {
  margin: 0.25rem 0;
  font-size: 0.875rem;
}

.eyelashes {
  margin-bottom: 15px;
}

.eyelashes a {
  text-decoration: none;
  padding: 5px 10px;
  margin-right: 5px;
  color: var(--gray-600);
}

.eyelashes a:hover,
.eyelashes a.active {
  border-bottom: solid 3px #2563eb;
}

/* Estilos adicionales para los formularios en el sidebar */
.userEdit,
.userCreate {
  margin-top: 1.5rem;
  padding: 1rem;
}

.sidebar label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--gray-700);
}

.sidebar .buscador {
  margin-bottom: 1rem;
  display: block;
}

.sidebar select {
  min-width: 200px;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  transition: var(--transition);
  background-color: var(--white);
}

.sidebar select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.hidden {
  display: none;
}

/* Dashboard Layout - Mobile First */
.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Sidebar - Mobile */
.sidebar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem;
  padding-bottom: 44px;
  box-shadow: var(--shadow-sm);
}

.sidebar-user {
  margin-bottom: 1.5rem;
}

.sidebar-user .user-name {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-weight: 600;
  color: var(--gray-900);
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
}

.sidebar-user .user-name i {
  color: var(--primary-color);
  font-size: 2rem;
}

.sidebar-user .user-type {
  color: var(--gray-600);
  margin: 0;
}

.sidebar p {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--gray-600);
}

.sidebar p:first-child {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 1.6rem;
  margin-bottom: 0px;

}

.sidebar form {
  margin: 1rem 0;
}

.sidebar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem solid red;
}

.sidebar nav a {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--gray-100);
  color: var(--gray-700);
  text-decoration: none;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar nav a:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* Content Area */
.content {
  flex: 1;
  padding: 1rem;
  min-width: 300px;
  overflow-x: auto;
  /* Activa el desplazamiento horizontal cuando sea necesario */

}

.content h1 {
  margin: 0 0 1.5rem 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
}

/* Buscador */
.buscador {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.buscador input {
  flex: 1;
  min-width: 200px;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  transition: var(--transition);
}

.buscador textarea {
  width: 100%;
}

.buscador input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

/* Botones */
button,
.btn {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  transition: var(--transition);
  line-height: 1;
}

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

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

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

.btn-success:hover {
  background: var(--success-hover);
}

.btn-danger {
  background: var(--danger-color);
  color: var(--white);
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.sidebar button {
  background: var(--gray-600);
  color: var(--white);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.sidebar button:hover {
  background: var(--gray-700);
}

/* Alertas */
.alert {
  padding: 1rem;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #b5cffa;
  border-color: var(--primary-color);
  color: black;
}

.alert-warning a:hover {
  color: white;
}

.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #166534;
}

/* Tabla - Mobile First */
table {
  width: 100%;
  table-layout: fixed;
  background: var(--white);
  border-radius: var(--border-radius);
  /*overflow: hidden;*/
  box-shadow: var(--shadow-sm);
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

.table-container {
  max-height: 550px;
  overflow-y: auto;
}

.table-container th {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  text-align: center;
  padding: 0.75rem;
  font-size: 0.9rem;
}

/* Mobile First: anchos base */
thead th:nth-child(1) {
  width: 100px;
}

/* N° de remito */
thead th:nth-child(2) {
  width: 160px;
}

/* Cliente */
thead th:nth-child(3) {
  width: 100px;
}

/* Estado */
thead th:nth-child(4) {
  width: 120px;
}

/* Fecha de envío */
thead th:nth-child(5) {
  width: 60px;
}

/* Detalle */

/* Acciones para tipo corralón */
thead th:nth-child(6),
thead th:nth-child(7),
thead th:nth-child(8) {
  width: 100px;
}

/* 🖥️ Breakpoint para pantallas medianas en adelante */
@media (min-width: 768px) {
  thead th:nth-child(1) {
    width: 120px;
  }

  thead th:nth-child(2) {
    width: 200px;
  }

  thead th:nth-child(3) {
    width: 120px;
  }

  thead th:nth-child(4) {
    width: 140px;
  }

  thead th:nth-child(5) {
    width: 80px;
  }

  thead th:nth-child(6),
  thead th:nth-child(7),
  thead th:nth-child(8) {
    width: 140px;
  }
}

@media (max-width: 480px) {
  .label {
    display: none;
  }
}

/* En mobile, ocultamos la tabla y mostramos cards */
@media (max-width: 768px) {

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tr {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: var(--shadow-sm);
  }

  td {
    min-height: 50px;
    border: none;
    position: relative;
    padding: 0.5rem 0;
    padding-left: 40%;
    border-bottom: 1px solid var(--gray-100);
  }

  td:last-child {
    border-bottom: none;
  }

  td:before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 35%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
  }

  #lista-notificaciones,
  .tabla-observaciones-container {
    overflow-x: auto;
    width: 100%;
  }

  .tabla-observaciones-container tr td {
    padding-left: 0;
    word-break: break-word;
  }

  td.sin-boton {
    display: none;
  }

  .search-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
  }

  .paginacion {
    display: flex;
    justify-content: center;
  }

  .logo-container {
    display: flex;
    justify-content: center;
  }

  .logo-container img {
    width: 150px;
    height: auto;
  }

  .divider {
    width: 80%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.1);
    /* gris muy suave */
    margin: 1rem auto;
  }
}

/* Tabla - Desktop */
@media (min-width: 769px) {

  .tabla-observaciones-container tr td {
    padding-left: 0;
    word-break: break-word;
  }

  .tabla-observaciones-container {
    overflow-x: auto;
    width: 100%;
  }

  .tabla-observaciones .th-obs,
  .td-obs {
    text-align: left !important;
  }

  th,
  td {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid var(--gray-200);
  }

  .tdCliente {
    text-align: left;
  }

  th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  td {
    font-size: 0.875rem;
  }

  tr:hover {
    background: var(--gray-50);
  }

  .search-page {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
  }

  .logo-container {
    display: flex;
    justify-content: center;

  }

  .logo-container img {
    width: 150px;
    height: auto;
  }

  .divider {
    width: 100%;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.1);
    margin: 1rem auto;
  }
}

/* Enlaces en tabla */
table a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

table a:hover {
  text-decoration: underline;
}

/* Botones en tabla */
table button,
table .btn {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  margin: 0.125rem;
}

/* Paginación */
.paginacion {
  gap: 0.5rem;
  flex-wrap: wrap;
}

.paginacion a,
.paginacion span {
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--primary-color);
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  transition: var(--transition);
}

.paginacion a:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.paginacion strong {
  color: var(--gray-600);
  border-color: var(--primary-color);
}


/* Responsive - Tablet y Desktop */
@media (min-width: 768px) {
  .dashboard {
    flex-direction: row;
  }

  .pedido-info {
    display: flex;
    gap: 2.5rem;
  }

  .sidebar {
    width: 280px;
    min-height: 100vh;
    border-bottom: none;
    border-right: 1px solid var(--gray-200);
    padding: 2rem 1.5rem;
  }

  .sidebar nav {
    flex-direction: column;
    gap: 0.75rem;
  }

  .sidebar nav a {
    padding: 0.75rem 1rem;
  }

  .content {
    padding: 2rem;
  }

  .content h1 {
    font-size: 2rem;
  }

  .buscador {
    max-width: 400px;
  }

}

@media (min-width: 1024px) {
  .content {
    padding: 2.5rem;
  }

  .sidebar {
    width: 320px;
    padding: 2.5rem 2rem;
  }

}

/* Estados de los pedidos */
td:nth-child(3) {
  font-weight: 700;
}


/* Colores para estados */
.estado-pendiente {
  color: var(--warning-color);
}

.estado-confirmado {
  color: var(--primary-color);
}

.estado-en-transito {
  color: #8b5cf6;
}

.estado-entregado {
  color: var(--success-color);
}

.estado-cancelado {
  color: var(--danger-color);
}

/* Mejoras de accesibilidad */
button:focus,
.btn:focus,
input:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Animaciones suaves */
* {
  transition: var(--transition);
}

/* Scroll suave en mobile para tablas anchas */
@media (max-width: 768px) {
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.text-danger {
  color: red;
  font-size: 0.9em;
  margin-top: 4px;
}