/* System Design System & Variables (Coerente com o projeto pai) */
:root {
  --font-sans: 'Inter', sans-serif;
  --font-mono: 'Roboto Mono', monospace;

  /* Theme: Dark (Default) */
  --bg-app: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.7);
  --bg-input: #0f172a;
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --secondary: #6366f1;
  --secondary-hover: #4f46e5;
  --success: #10b981;
  
  /* Thermal Label Colors - ALWAYS Black on White */
  --label-bg: #ffffff;
  --label-text: #000000;
  --label-border: #000000;

  --card-blur: blur(16px);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
body.light-theme {
  --bg-app: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-input: #ffffff;
  --border-color: rgba(15, 23, 42, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --secondary: #4f46e5;
  --secondary-hover: #3730a3;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.05);
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo-svg {
  width: 48px;
  height: 48px;
  background: #ffffff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.1);
  padding: 5px;
}

.logo-area h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-area p {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Header Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
  transition: var(--transition);
}

.btn-back:hover {
  transform: translateX(-3px);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.15);
}

/* Theme Toggle Button */
.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1.1rem;
}

.btn-icon:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}

/* Main Layout Grid */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 2rem;
  flex: 1;
}

@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* Card Styling */
.card {
  background-color: var(--bg-card);
  backdrop-filter: var(--card-blur);
  -webkit-backdrop-filter: var(--card-blur);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.card-header > div:first-child,
.card-header > i:first-child {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-header i {
  font-size: 1.3rem;
  color: var(--primary);
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

/* Size Tabs in Preview Card */
.size-tabs {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.35rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.2);
}

/* Form Styles */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group.full-width {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full-width {
    grid-column: span 1;
  }
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-group label i {
  color: var(--primary);
  font-size: 0.95rem;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-group input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* Settings Panel */
.settings-panel {
  border-top: 1px solid var(--border-color);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
}

.settings-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.settings-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-group label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.checkbox-group input[type="checkbox"]:checked + label {
  color: var(--text-primary);
}

/* Preview Panel & Thermal Label Styling */
.preview-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.preview-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1.5rem;
  background-color: rgba(15, 23, 42, 0.25);
  border-radius: 15px;
  border: 1px inset var(--border-color);
  flex: 1;
  margin-bottom: 1.5rem;
  min-height: 400px;
  overflow: auto;
}

/* -------------------------------------------------------------
   THERMAL LABEL BASE - Black on White for physical simulation
   ------------------------------------------------------------- */
.thermal-label {
  background-color: var(--label-bg);
  color: var(--label-text);
  padding: 16px 20px;
  border-radius: 0;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  position: relative;
  transition: all 0.3s ease;
  user-select: none;
  font-family: var(--font-sans);
  box-sizing: border-box;
}

/* Layout validation outline */
.thermal-label.show-border {
  outline: 2px dashed #94a3b8;
  outline-offset: -2px;
}

/* Label Layout Container */
.label-layout-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* --- Layout Elements & Hide/Show behaviors based on size --- */

/* Logo & Header */
.label-header {
  display: flex;
  align-items: center;
  justify-content: center; /* Centralizado sem texto */
  gap: 12px;
  border-bottom: 3px solid var(--label-text);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.label-logo-container {
  width: 44px;
  height: 44px;
}

.label-logo {
  width: 100%;
  height: 100%;
}

/* Código de Barras */
.label-barcode {
  font-family: 'Libre Barcode 39', sans-serif;
  font-size: 28px;
  line-height: 1;
  margin: 1px 0 5px 0;
  display: block;
  color: var(--label-text);
  letter-spacing: 1px;
}

/* Product Name */
.label-product-name {
  font-weight: 800;
  text-transform: uppercase;
  color: var(--label-text);
  word-break: break-word;
}

/* Main Content Area */
.label-main-content {
  display: flex;
  flex-grow: 1;
}

/* Details Group */
.label-data-group {
  display: flex;
  flex-direction: column;
}

.label-data-item {
  font-family: var(--font-mono);
  display: flex;
  align-items: baseline;
  white-space: nowrap;
}

.label-tag {
  font-weight: 700;
}

.label-value {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hidden labels configuration styling */
.hide-labels .label-tag {
  display: none !important;
}

/* QR Code Area */
.label-qrcode-area {
  display: flex;
  align-items: center;
  justify-content: center;
}

.label-qrcode-area canvas {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 1 / 1;
}

/* Footer */
.label-footer {
  text-transform: uppercase;
  opacity: 0.7;
  font-weight: 700;
}

/* -------------------------------------------------------------
   100x50 mm Format (Horizontal, Compact)
   ------------------------------------------------------------- */
.thermal-label.size-100x50 {
  width: 500px;
  height: 250px;
  padding: 14px 18px;
}

.thermal-label.size-100x50 .label-header {
  display: flex !important;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--label-text);
  padding-bottom: 4px;
  margin-bottom: 6px;
}

.thermal-label.size-100x50 .label-logo-container {
  width: 24px;
  height: 24px;
}

.thermal-label.size-100x50 .label-header-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.thermal-label.size-100x50 .label-product-name {
  font-size: 15px;
  line-height: 1.15;
  border-bottom: 2px solid var(--label-text);
  padding-bottom: 3px;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thermal-label.size-100x50 .label-main-content {
  display: grid;
  grid-template-columns: 63% 37%;
  align-items: center;
  flex-grow: 1;
}

.thermal-label.size-100x50 .label-data-group {
  gap: 3px;
}

.thermal-label.size-100x50 .label-data-item {
  font-size: 10px;
}

.thermal-label.size-100x50 .label-tag {
  margin-right: 4px;
}

.thermal-label.size-100x50 .label-value {
  font-size: 12px;
}

.thermal-label.size-100x50 .label-qrcode-area {
  padding-left: 6px;
  height: 100%;
}

.thermal-label.size-100x50 .label-qrcode-area canvas {
  max-width: 145px;
  max-height: 145px;
}

.thermal-label.size-100x50 .label-footer {
  font-size: 7.5px;
  border-top: 1px solid var(--label-text);
  padding-top: 3px;
  margin-top: 4px;
}

/* -------------------------------------------------------------
   100x150 mm Format (Vertical, Spaced)
   ------------------------------------------------------------- */
.thermal-label.size-100x150 {
  width: 400px;
  height: 600px;
  padding: 24px 20px;
}

.thermal-label.size-100x150 .label-header {
  display: flex !important;
}

.thermal-label.size-100x150 .label-product-name {
  font-size: 22px;
  line-height: 1.2;
  border-bottom: 2px solid var(--label-text);
  padding-bottom: 6px;
  margin-bottom: 12px;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.thermal-label.size-100x150 .label-main-content {
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  flex-grow: 1;
}

.thermal-label.size-100x150 .label-data-group {
  width: 100%;
  gap: 8px;
  margin-bottom: 15px;
}

.thermal-label.size-100x150 .label-data-item {
  font-size: 13px;
  border-bottom: 1px dashed rgba(0,0,0,0.15);
  padding-bottom: 4px;
}

.thermal-label.size-100x150 .label-tag {
  min-width: 90px;
  display: inline-block;
}

.thermal-label.size-100x150 .label-value {
  font-size: 15px;
}

.thermal-label.size-100x150 .label-barcode {
  font-size: 38px;
  margin: 2px 0 8px 0;
}

.thermal-label.size-100x150 .label-qrcode-area {
  width: 100%;
  flex-grow: 1;
  padding: 10px 0;
}

.thermal-label.size-100x150 .label-qrcode-area canvas {
  max-width: 220px;
  max-height: 220px;
}

.thermal-label.size-100x150 .label-footer {
  font-size: 9px;
  border-top: 2px solid var(--label-text);
  padding-top: 6px;
  text-align: center;
  margin-top: 10px;
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.85rem 1.5rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.25);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.35);
  background: linear-gradient(135deg, var(--primary-hover), var(--secondary-hover));
}

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

.btn-secondary:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.02);
  color: var(--primary);
}

/* Footer Styling */
.app-footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Animations */
.animate-fade-in {
  animation: fadeIn 0.6s ease forwards;
}

.animate-fade-in-delay {
  animation: fadeIn 0.6s ease 0.2s forwards;
  opacity: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* -------------------------------------------------------------
   PRINT STYLES - Optimized for Thermal Label Printers
   ------------------------------------------------------------- */
@media print {
  /* Hide standard page elements */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
  }

  .app-container, 
  .app-header, 
  .control-panel, 
  .preview-panel .card-header, 
  .action-buttons, 
  .app-footer {
    display: none !important;
  }

  .preview-panel {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    display: block !important;
  }

  .preview-container {
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    background: transparent !important;
    display: block !important;
  }

  .thermal-label {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    border: none !important; /* Nunca imprime bordas pontilhadas no produto final */
    outline: none !important;
    background: #ffffff !important;
    box-shadow: none !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    page-break-inside: avoid !important;
  }

  /* Print specific sizes */
  body.print-100x50 {
    height: 50mm !important;
    width: 100mm !important;
  }

  body.print-100x50 .thermal-label {
    width: 100mm !important;
    height: 50mm !important;
    padding: 3mm 4mm !important;
  }

  body.print-100x50 .thermal-label.size-100x50 {
    display: flex !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-header {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 2mm !important;
    border-bottom: 2px solid #000000 !important;
    padding-bottom: 1mm !important;
    margin-bottom: 1.5mm !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-logo-container {
    width: 6mm !important;
    height: 6mm !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-product-name {
    font-size: 14pt !important;
    line-height: 1.1 !important;
    border-bottom: 2px solid #000000 !important;
    padding-bottom: 1mm !important;
    margin-bottom: 1.5mm !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-data-group {
    gap: 1.5mm !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-data-item {
    font-size: 10pt !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-value {
    font-size: 11pt !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-barcode {
    font-family: 'Libre Barcode 39' !important;
    font-size: 24pt !important;
    line-height: 1 !important;
    margin: 0.5mm 0 1.5mm 0 !important;
    display: block !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-qrcode-area canvas {
    max-width: 38mm !important;
    max-height: 38mm !important;
  }

  body.print-100x50 .thermal-label.size-100x50 .label-footer {
    font-size: 7.5pt !important;
    border-top: 1px solid #000000 !important;
    padding-top: 1mm !important;
  }

  /* Print 100x150 */
  body.print-100x150 {
    height: 150mm !important;
    width: 100mm !important;
  }

  body.print-100x150 .thermal-label {
    width: 100mm !important;
    height: 150mm !important;
    padding: 5mm 6mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 {
    display: flex !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-header {
    border-bottom: 3px solid #000000 !important;
    padding-bottom: 2mm !important;
    margin-bottom: 3mm !important;
    justify-content: center !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-logo-container {
    width: 12mm !important;
    height: 12mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-product-name {
    font-size: 20pt !important;
    line-height: 1.2 !important;
    border-bottom: 2.5px solid #000000 !important;
    padding-bottom: 2mm !important;
    margin-bottom: 4mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-data-group {
    gap: 3mm !important;
    margin-bottom: 4mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-data-item {
    font-size: 12pt !important;
    padding-bottom: 1.5mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-tag {
    min-width: 32mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-value {
    font-size: 14pt !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-barcode {
    font-family: 'Libre Barcode 39' !important;
    font-size: 34pt !important;
    line-height: 1 !important;
    margin: 1mm 0 3mm 0 !important;
    display: block !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-qrcode-area canvas {
    max-width: 60mm !important;
    max-height: 60mm !important;
  }

  body.print-100x150 .thermal-label.size-100x150 .label-footer {
    font-size: 8.5pt !important;
    border-top: 2px solid #000000 !important;
    padding-top: 2mm !important;
  }
}
