/* ============================================================
   1. Reset de Estilos Básicos
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================================
   2. Estilos Globales
   ============================================================ */
body {
  font-family: Arial, sans-serif;
  background-color: #f4f4f4;
  margin: 0;
  padding: 20px;
}

.container {
  max-width: 1200px;
  margin: auto;
  padding: 0 15px; /* Añadido para evitar que el contenido toque los bordes en pantallas pequeñas */
}

/* ============================================================
   3. Estilos de Encabezados
   ============================================================ */
h1, h2, h3 {
  text-align: center;
  margin-bottom: 20px;
}

h1 {
  font-size: 2em;
}

h2 {
  font-size: 1.5em;
}

h3 {
  font-size: 1.2em;
}

/* ============================================================
   4. Estilos de Componentes Principales
   ============================================================ */
.field-manager,
.label-generator,
.label-preview {
  background: #fff;
  padding: 20px;
  margin-bottom: 20px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); /* Añadido para mejorar la estética */
}

/* ============================================================
   5. Estilos de Formularios
   ============================================================ */
form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

input[type="text"],
input[type="number"],
select {
  padding: 8px;
  font-size: 14px; /* Reducido de 16px a 14px */
  border: 1px solid #ccc; /* Añadido borde */
  border-radius: 3px; /* Añadido borde redondeado */
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #007bff; /* Color de borde al enfocarse */
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); /* Sombra al enfocarse */
}

/* ============================================================
   6. Estilos de Botones
   ============================================================ */
button {
  padding: 10px;
  background: #28a745;
  color: #fff;
  border: none;
  cursor: pointer;
  border-radius: 3px;
  font-size: 14px; /* Reducido de 16px a 14px */
  transition: background 0.3s ease, transform 0.2s ease;
}

button:hover {
  background: #218838;
  transform: translateY(-2px); /* Efecto de elevación al pasar el cursor */
}

button:active {
  transform: translateY(0); /* Restaurar posición al hacer clic */
}

/* Botones Específicos */
.add-parent-button {
  background: #007bff;
}

.add-parent-button:hover {
  background: #0069d9;
}

.generate-label-button {
  background: #17a2b8;
}

.generate-label-button:hover {
  background: #138496;
}

.print-label-button {
  background: #ffc107;
  color: #000;
  margin-top: 10px;
}

.print-label-button:hover {
  background: #e0a800;
}

.export-pdf-button {
  background: #6c757d;
  color: #fff;
  margin-top: 10px;
}

.export-pdf-button:hover {
  background: #5a6268;
}

/* Botones de Exportar e Importar Configuración */
.export-config-button,
.import-config-button {
  background: #17a2b8; /* Color diferente para distinguirlos */
  margin-top: 10px;
}

.export-config-button:hover,
.import-config-button:hover {
  background: #138496;
}

/* ============================================================
   7. Estilos de Listas
   ============================================================ */
.parents-list,
.children-list {
  list-style: none;
  padding: 0;
  margin-top: 10px;
}

.parent-item,
.child-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #ddd;
}

.parent-details,
.child-details {
  display: flex;
  flex-direction: column;
}

/* ============================================================
   8. Estilos de Acciones en Listas
   ============================================================ */
.actions {
  display: flex;
  gap: 5px;
}

.actions button {
  padding: 5px 8px;
  font-size: 12px; /* Reducido de 14px a 12px */
  transition: background 0.3s ease, transform 0.2s ease;
}

.actions button:hover {
  transform: translateY(-1px);
}

.actions button:active {
  transform: translateY(0);
}

/* ============================================================
   9. Estilos de la Etiqueta
   ============================================================ */
.label {
  width: 45mm; /* Reducido de 50mm a 45mm */
  height: 25mm; /* Reducido de 30mm a 25mm */
  border: 1px solid #000;
  padding: 1mm; /* Reducido de 2mm a 1mm */
  position: relative;
  background: #fff;
  display: flex;
  flex-direction: column; /* Divs uno después del otro */
  justify-content: space-around;
  align-items: center;
}

.label-header {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px; /* Espacio inferior entre el header y el resto de la etiqueta */
}

.label-header .product-name {
  flex: 2;
  text-align: left; /* Opcional: alinear el texto a la izquierda */
  font-weight: 700; /* Asegura que el título sea negrita */
}

.label-header .price {
  flex: 1;
  text-align: right; /* Opcional: alinear el texto a la derecha */
  font-weight: 900; /* Asegura que el precio sea más negrita */
  font-size: medium; /* Tamaño de fuente para el precio */
}

.label-section {
  width: 100%;
  text-align: center;
}

.product-name {
  font-size: 10pt; /* Reducido de 12pt a 10pt */
  margin-bottom: 5px;
}

.price {
  /* Ya manejado en .label-header */
}

.barcode {
  /* Estilos adicionales para el código de barras si es necesario */
}

.sku {
  font-size: 8pt; /* Reducido de 10pt a 8pt */
  text-transform: uppercase;
}

/* ============================================================
   10. Estilos de Formularios de Campos Hijos
   ============================================================ */
.child-form {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 10px;
}

.child-form input[type="text"] {
  font-size: 14px;
}

/* ============================================================
   11. Estilos de la Sección de Generar Etiqueta
   ============================================================ */
.dynamic-fields {
  margin-top: 10px;
}

.dynamic-fields h3 {
  margin-bottom: 10px;
}

.custom-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.custom-field label {
  margin-bottom: 5px;
  font-weight: bold;
}

.custom-field select {
  padding: 8px;
  font-size: 14px; /* Reducido de 16px a 14px */
  border: 1px solid #ccc; /* Añadido borde */
  border-radius: 3px; /* Añadido borde redondeado */
}

.custom-field select:focus {
  outline: none;
  border-color: #007bff; /* Color de borde al enfocarse */
  box-shadow: 0 0 5px rgba(0, 123, 255, 0.5); /* Sombra al enfocarse */
}

/* ============================================================
   12. Estilos para SVG del Código de Barras
   ============================================================ */
svg#barcode {
  max-width: 100%;
}

/* ============================================================
   13. Estilos para el Historial de Etiquetas
   ============================================================ */
.label-history {
  margin-top: 20px;
  border-top: 1px solid #ddd;
  padding-top: 20px;
}

.history-container {
  margin: 15px 0;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  margin-bottom: 10px;
  background-color: #f9f9f9;
}

.history-item-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.history-date {
  font-size: 12px;
  color: #666;
}

.history-actions {
  display: flex;
  gap: 5px;
}

.empty-history-message {
  text-align: center;
  color: #666;
  font-style: italic;
}

.save-to-history-button {
  background-color: #17a2b8;
  margin-top: 10px;
}

.save-to-history-button:hover {
  background-color: #138496;
}

.customize-label-button {
  background-color: #6f42c1;
  margin-top: 10px;
}

.customize-label-button:hover {
  background-color: #5a32a3;
}

.clear-history-button {
  background-color: #dc3545;
  color: white;
  margin-top: 10px;
}

.clear-history-button:hover {
  background-color: #c82333;
}

/* ============================================================
   14. Estilos de Impresión
   ============================================================ */
@media print {
  body * {
    visibility: hidden;
  }

  #label,
  #label * {
    visibility: visible;
  }

  #label {
    position: absolute;
    left: 0;
    top: 0;
    width: 45mm; /* Reducido de 50mm a 45mm */
    height: 25mm; /* Reducido de 30mm a 25mm */
    margin: 0;
    padding: 0;
    border: none;
  }

  #print-label,
  #export-pdf,
  #export-config,
  #import-config-button {
    display: none;
  }
}

/* ============================================================
   14. Estilos para el Editor de Diseño
   ============================================================ */

.design-editor {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.editor-container {
  display: flex;
  gap: 15px;
  width: 100%;
  height: 80vh;
  overflow: hidden;
}

.editor-column {
  flex: 1;
  min-width: 250px;
  max-height: 100%;
  overflow-y: auto;
  background-color: #f8f9fa;
  padding: 15px;
  border-radius: 5px;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}

.editor-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 20px;
}

.editor-section {
  margin-bottom: 20px;
  border-bottom: 1px solid #ddd;
  padding-bottom: 15px;
}

.editor-section h4 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #333;
}

.editor-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-group label {
  font-weight: bold;
  font-size: 0.9em;
}

.control-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.control-row label {
  min-width: 80px;
}

.control-row input[type="number"] {
  width: 60px;
}

.control-row input[type="color"] {
  width: 40px;
  height: 25px;
  padding: 0;
  border: none;
}

.control-row select {
  flex: 1;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

.editor-actions button {
  padding: 8px 15px;
}

.save-design-button {
  background-color: #28a745;
}

.save-design-button:hover {
  background-color: #218838;
}

.reset-design-button {
  background-color: #dc3545;
}

.reset-design-button:hover {
  background-color: #c82333;
}

.design-preview {
  position: relative;
  width: 100%;
  height: 300px;
  border: 1px dashed #ccc;
  background-color: white;
  margin-bottom: 20px;
  overflow: hidden;
}

.design-element {
  position: absolute;
  cursor: move;
  padding: 5px;
  border: 1px dashed transparent;
  user-select: none;
}

.design-element:hover {
  border-color: #007bff;
}

.design-element.selected {
  border-color: #007bff;
  background-color: rgba(0, 123, 255, 0.1);
}

.design-templates {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.template-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.load-template-button, .save-template-button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

.load-template-button {
  background-color: #17a2b8;
  color: white;
}

.load-template-button:hover {
  background-color: #138496;
}

.save-template-button {
  background-color: #28a745;
  color: white;
}

.save-template-button:hover {
  background-color: #218838;
}

.export-button, .import-button {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

.export-button {
  background-color: #6c757d;
  color: white;
}

.export-button:hover {
  background-color: #5a6268;
}

.import-button {
  background-color: #6c757d;
  color: white;
}

.import-button:hover {
  background-color: #5a6268;
}

/* ============================================================
   15. Estilos para Modales y Edición
   ============================================================ */

/* Modal */
.modal {
  display: flex;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: #fff;
  padding: 20px;
  border-radius: 5px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: fit-content;
  position: relative;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
}

.edit-form {
  margin-top: 20px;
}

.warning-text {
  color: #dc3545;
  font-size: 0.9em;
  margin-top: 5px;
}

/* ============================================================
   15. Estilos para Nuevas Funcionalidades
   ============================================================ */

/* Estilos para el selector de idioma */
.language-selector {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 15px;
}

.language-selector label {
  margin-right: 10px;
  font-weight: bold;
}

.language-selector select {
  padding: 5px;
  border-radius: 3px;
  border: 1px solid #ccc;
  background-color: #f8f9fa;
}

/* Estilos para el historial de etiquetas */
.label-history {
  margin-top: 20px;
  border-top: 1px solid #ddd;
  padding-top: 20px;
}

.history-info {
  font-size: 0.9em;
  color: #666;
  margin-bottom: 10px;
  font-style: italic;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 10px 0;
}

.history-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px;
  margin-bottom: 10px;
  background-color: #f9f9f9;
}

.history-item input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.select-all-container {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  padding: 5px;
  background-color: #f0f0f0;
  border-radius: 5px;
}

.select-all-container input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.select-all-container label {
  cursor: pointer;
  font-weight: bold;
}

.history-item-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.history-date {
  font-size: 12px;
  color: #666;
}

.history-actions {
  display: flex;
  gap: 5px;
}

.history-actions-container {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.clear-history-button {
  background-color: #dc3545;
  color: white;
}

.clear-history-button:hover {
  background-color: #c82333;
}

.bulk-generate-button {
  background-color: #17a2b8;
  color: white;
}

.bulk-generate-button:hover {
  background-color: #138496;
}

/* Estilos para generación masiva - Oculto */
.bulk-generation {
  display: none; /* Ocultar la sección de impresión masiva */
}

.bulk-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.bulk-generate-button {
  background-color: #6610f2;
  color: white;
  margin-top: 10px;
}

.bulk-generate-button:hover {
  background-color: #520dc2;
}

/* Estilos para mensajes de error y éxito */
.error-message {
  background-color: #f8d7da;
  color: #721c24;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  border: 1px solid #f5c6cb;
}

.success-message {
  background-color: #d4edda;
  color: #155724;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  border: 1px solid #c3e6cb;
}

/* Estilos para noscript */
.noscript-message {
  background-color: #f8d7da;
  color: #721c24;
  padding: 20px;
  text-align: center;
  font-size: 18px;
  margin: 20px;
  border-radius: 5px;
  border: 1px solid #f5c6cb;
}

/* ============================================================
   15. Estilos Responsivos
   ============================================================ */

/* ------------------ Dispositivos Móviles ------------------ */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  .container {
    padding: 0 5px;
  }

  h1 {
    font-size: 1.5em;
  }

  h2 {
    font-size: 1.2em;
  }

  h3 {
    font-size: 1em;
  }

  .field-manager,
  .label-generator,
  .label-preview {
    padding: 15px 10px;
  }

  .label {
    width: 100%;
    height: auto;
    padding: 2mm;
  }

  .label-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .label-header .product-name,
  .label-header .price {
    text-align: left;
    flex: none;
  }

  .label-header .price {
    margin-top: 5px;
  }

  .actions {
    flex-direction: column;
    gap: 2px;
  }

  .actions button {
    width: 100%;
  }

  button {
    font-size: 12px;
    padding: 8px;
  }

  .child-form,
  .dynamic-fields {
    margin-top: 5px;
  }

  .custom-field {
    margin-bottom: 5px;
  }

  .custom-field select {
    font-size: 12px;
  }

  .product-name,
  .price,
  .sku {
    font-size: 8pt;
  }

  /* Estilos responsivos para nuevas funcionalidades */
  .language-container {
    justify-content: center;
    margin-bottom: 15px;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .history-item input[type="checkbox"] {
    margin-bottom: 10px;
  }

  .history-actions {
    margin-top: 10px;
    width: 100%;
    justify-content: space-between;
  }

  .select-all-container {
    flex-direction: row;
    align-items: center;
  }

  .bulk-form .field-group {
    flex-direction: column;
  }
}

/* ------------------ Tablets y Dispositivos Medianos ------------------ */
@media (min-width: 601px) and (max-width: 992px) {
  .label {
    width: 60mm;
    height: 35mm;
    padding: 1.5mm;
  }

  .label-header {
    flex-direction: row;
    align-items: center;
  }

  .label-header .product-name {
    flex: 2;
  }

  .label-header .price {
    flex: 1;
  }

  .product-name,
  .price {
    font-size: 12pt;
  }

  .sku {
    font-size: 10pt;
  }
}

/* ------------------ Escritorios Grandes ------------------ */
@media (min-width: 993px) {
  /* Puedes añadir estilos adicionales para pantallas grandes si es necesario */
}
