/**
 * Barcode Label Printing System Styles
 */

/* Modal Overlay */
.barcode-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  overflow: auto;
}

.barcode-modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* Modal Container */
.barcode-modal {
  background: white;
  border-radius: 8px;
  width: 95%;
  max-width: 1400px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Modal Header */
.barcode-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid #ddd;
}

.barcode-modal-header h2 {
  margin: 0;
  color: #333;
}

.barcode-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.barcode-modal-close:hover {
  color: #000;
}

/* Modal Body - Two Panel Layout */
.barcode-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Configuration Panel */
.barcode-config-panel {
  width: 400px;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.barcode-config-section {
  padding: 20px;
  border-bottom: 1px solid #eee;
}

.barcode-config-section h3 {
  margin: 0 0 15px 0;
  font-size: 16px;
  color: #333;
}

/* Product Selector */
.barcode-product-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
}

.barcode-product-item {
  display: flex;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid #eee;
}

.barcode-product-item:last-child {
  border-bottom: none;
}

.barcode-product-checkbox {
  margin-right: 10px;
}

.barcode-product-info {
  flex: 1;
  min-width: 0;
}

.barcode-product-name {
  font-weight: 500;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.barcode-product-code {
  font-size: 12px;
  color: #666;
  font-family: monospace;
}

.barcode-product-quantity {
  width: 60px;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
}

.barcode-selection-buttons {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.barcode-btn {
  padding: 8px 16px;
  border: 1px solid #ddd;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.barcode-btn:hover {
  background: #f5f5f5;
}

.barcode-btn.primary {
  background: #007bff;
  color: white;
  border-color: #007bff;
}

.barcode-btn.primary:hover {
  background: #0056b3;
}

.barcode-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Label Configuration */
.barcode-config-field {
  margin-bottom: 15px;
}

.barcode-config-field label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #333;
}

.barcode-config-field input[type="number"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.barcode-config-field input[type="checkbox"] {
  margin-right: 8px;
}

.barcode-config-error {
  color: #dc3545;
  font-size: 12px;
  margin-top: 4px;
}

/* Preview Panel */
.barcode-preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f5f5f5;
}

.barcode-preview-container {
  flex: 1;
  overflow: auto;
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

/* A4 Sheet */
.a4-sheet {
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
}

/* Individual Label */
.barcode-label {
  border: 1px solid black;
  box-sizing: border-box;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
}

.label-product-name {
  font-weight: bold;
  font-size: 14px;
  text-align: center;
  margin-bottom: 4px;
  word-wrap: break-word;
  width: 100%;
  color: black;
}

.label-price {
  font-size: 12px;
  text-align: center;
  margin-bottom: 4px;
  color: black;
}

.label-barcode-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 4px 0;
}

.label-barcode-container svg {
  max-width: 100%;
  height: auto;
}

.label-barcode-number {
  font-size: 10px;
  font-family: monospace;
  text-align: center;
  margin-top: 2px;
  color: black;
}

/* Action Buttons */
.barcode-modal-footer {
  padding: 20px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  color: white;
}

.loading-spinner {
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top: 4px solid white;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-overlay p {
  margin-top: 20px;
  font-size: 18px;
}

/* Responsive Layout */
@media (max-width: 1024px) {
  .barcode-modal-body {
    flex-direction: column;
  }

  .barcode-config-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #ddd;
    max-height: 50vh;
  }

  .barcode-preview-panel {
    min-height: 400px;
  }
}

@media (max-width: 768px) {
  .barcode-modal {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }

  .barcode-config-panel {
    max-height: 40vh;
  }
}

/* Print Styles */
@media print {
  /* Oculta tudo exceto a folha A4 */
  body * {
    visibility: hidden;
  }

  .a4-sheet,
  .a4-sheet * {
    visibility: visible;
  }

  .a4-sheet {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    min-height: 297mm;
    box-shadow: none;
    margin: 0;
    padding: 5mm;
    transform: none !important;
    transform-origin: initial !important;
  }

  /* Remove o fundo cinza do container de preview */
  .barcode-preview-panel,
  .barcode-preview-container {
    background: white !important;
    padding: 0 !important;
  }

  /* Remove backgrounds de todos os containers */
  .barcode-modal-overlay,
  .barcode-modal,
  .barcode-modal-body {
    background: white !important;
  }

  @page {
    size: A4;
    margin: 0;
  }
}

/* Alert Modal */
.barcode-alert-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
  animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.barcode-alert-modal {
  background: white;
  border-radius: 12px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.barcode-alert-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

.barcode-alert-modal.error .barcode-alert-icon {
  color: #dc3545;
}

.barcode-alert-modal.success .barcode-alert-icon {
  color: #28a745;
}

.barcode-alert-modal.info .barcode-alert-icon {
  color: #007bff;
}

.barcode-alert-message {
  font-size: 16px;
  color: #333;
  margin-bottom: 20px;
  line-height: 1.5;
}

.barcode-alert-btn {
  background: #007bff;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 10px 30px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.barcode-alert-btn:hover {
  background: #0056b3;
}

.barcode-alert-modal.error .barcode-alert-btn {
  background: #dc3545;
}

.barcode-alert-modal.error .barcode-alert-btn:hover {
  background: #c82333;
}

.barcode-alert-modal.success .barcode-alert-btn {
  background: #28a745;
}

.barcode-alert-modal.success .barcode-alert-btn:hover {
  background: #218838;
}
