:root { --ticket-width: 302px; }
* { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; background: #f0f4f8; color: #1e293b; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #e2e8f0; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 3px; }

/* ── LAYOUT ── */
#control-panel {
  width: 480px; min-width: 380px; height: 100vh;
  overflow-y: auto; background: #ffffff;
  border-right: 1px solid #cbd5e1; flex-shrink: 0;
}
#preview-area {
  flex: 1; display: flex; align-items: flex-start;
  justify-content: center; padding: 2rem; overflow-y: auto; background: #f0f4f8;
  background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
  background-size: 20px 20px;
}
#ticket-preview-wrapper {
  background: #3b82f6; /* Blue slot like in the mockup */
  border-radius: 12px; padding: 1.5rem 1.5rem 2rem 1.5rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.1); position: sticky; top: 2rem;
  position: relative;
}
#ticket-preview-wrapper::before {
  content: '';
  position: absolute;
  top: 15px; left: 10%; right: 10%;
  height: 8px;
  background: #0f172a;
  border-radius: 4px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}
#ticket-preview {
  width: var(--ticket-width); min-height: 200px; background: #ffffff;
  color: #000000; font-family: 'Courier New', Courier, monospace;
  font-size: 12px; padding: 8px 6px; line-height: 1.4; overflow: hidden;
  margin-top: 15px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* ── BLOQUES ── */
.block-item {
  background: #ffffff; border: 1px solid #e2e8f0; border-radius: 8px;
  margin-bottom: 8px; cursor: grab; transition: border-color .15s, box-shadow .15s;
}
.block-item:active { cursor: grabbing; }
.block-item.drag-over { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.3); }
.block-item.dragging { opacity: .4; }
.block-header { display: flex; align-items: center; padding: 8px 12px; gap: 8px; user-select: none; }
.block-body { padding: 0 12px 12px; display: none; }
.block-body.open { display: block; }

/* ── CONTROLES ── */
.ctrl-input {
  width: 100%; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px;
  color: #0f172a; padding: 6px 10px; font-size: 13px; outline: none; transition: border-color .15s;
}
.ctrl-input:focus { border-color: #2563eb; background: #ffffff; }
.ctrl-input::placeholder { color: #94a3b8; }
.ctrl-select {
  width: 100%; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px;
  color: #0f172a; padding: 6px 10px; font-size: 13px; outline: none; cursor: pointer;
}
.ctrl-label {
  font-size: 11px; font-weight: 600; color: #475569;
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; display: block;
}

/* ── BOTONES ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px;
  border-radius: 7px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s;
}
.btn-primary { background: #3b82f6; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { background: #f1f5f9; color: #1e293b; border: 1px solid #e2e8f0; }
.btn-ghost:hover { background: #e2e8f0; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-scan { background: linear-gradient(135deg, #38bdf8, #3b82f6); color: #fff; }
.btn-scan:hover { opacity: .9; transform: translateY(-1px); }

/* ── BOTÓN FLOTANTE ── */
#btn-print-float {
  position: fixed; bottom: 2rem; right: 2rem; z-index: 100;
  padding: 14px 28px; font-size: 16px; border-radius: 50px;
  background: linear-gradient(135deg, #60a5fa, #3b82f6); color: #fff; border: none;
  cursor: pointer; box-shadow: 0 8px 20px rgba(37,99,235,.4);
  font-weight: 700; transition: all .2s; display: flex; align-items: center; gap: 10px;
}
#btn-print-float:hover { transform: translateY(-2px); box-shadow: 0 12px 25px rgba(37,99,235,.5); }

/* ── TABLA PRODUCTOS ── */
.product-row {
  display: grid; grid-template-columns: 60px 1fr 90px 80px 28px;
  gap: 4px; align-items: center; margin-bottom: 4px;
}

/* ── BADGES ── */
.badge-block {
  font-size: 10px; padding: 2px 7px; border-radius: 20px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}
.badge-logo    { background: #fef08a; color: #713f12; }
.badge-text    { background: #bfdbfe; color: #1e3a5f; }
.badge-spacer  { background: #d9f99d; color: #14532d; }
.badge-sep     { background: #fecaca; color: #7f1d1d; }
.badge-barcode { background: #e9d5ff; color: #4c1d95; }
.badge-products{ background: #fed7aa; color: #7c2d12; }

/* ══════════════════════════════════════════════════
   MODAL DE ESCANEO
══════════════════════════════════════════════════ */
#scan-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center; padding: 1rem;
}
#scan-modal.open { display: flex; }
#scan-modal-box {
  background: #ffffff; border: 1px solid #cbd5e1; border-radius: 16px;
  width: 100%; max-width: 820px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 80px rgba(0,0,0,.2);
}

/* ── ZONA DE DROP ── */
#scan-drop-zone {
  border: 2px dashed #94a3b8; border-radius: 12px; padding: 2.5rem;
  text-align: center; cursor: pointer; transition: all .2s; background: #f8fafc;
}
#scan-drop-zone.dragover { border-color: #2563eb; background: rgba(37,99,235,.05); }
#scan-drop-zone:hover { border-color: #64748b; }

/* ── PROGRESO OCR ── */
#ocr-progress-bar {
  height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden;
}
#ocr-progress-fill {
  height: 100%; background: linear-gradient(90deg, #2563eb, #0ea5e9);
  border-radius: 3px; transition: width .3s; width: 0%;
}

/* ── RESULTADO PARSEADO ── */
.parsed-row {
  display: grid; grid-template-columns: 48px 1fr 80px 32px;
  gap: 4px; align-items: center; margin-bottom: 3px;
}
.parsed-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px;
  padding: 3px 8px; font-size: 11px; color: #475569; cursor: pointer;
  transition: border-color .15s;
}
.parsed-chip:hover { border-color: #2563eb; color: #1e293b; }
.parsed-chip.selected { border-color: #10b981; background: rgba(16,185,129,.1); color: #059669; }

/* ── SECCIÓN COLAPSABLE ── */
.section-toggle { cursor: pointer; user-select: none; }

/* ── @MEDIA PRINT — MOTOR TÉRMICO ── */
@media print {
  body * { visibility: hidden !important; }
  #ticket-preview, #ticket-preview * { visibility: visible !important; }
  body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  @page { size: 80mm auto; margin: 0mm; }
  #ticket-preview {
    position: fixed !important; top: 0 !important; left: 0 !important;
    width: 80mm !important; min-height: auto !important; max-width: 80mm !important;
    background: #ffffff !important; color: #000000 !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 10pt !important; padding: 2mm 3mm !important;
    margin: 0 !important; border: none !important; box-shadow: none !important;
    overflow: visible !important; page-break-after: avoid; break-after: avoid;
  }
  #ticket-preview * {
    background: transparent !important; color: #000 !important;
    border-color: #000 !important; box-shadow: none !important;
    font-family: 'Courier New', Courier, monospace !important;
  }
  #ticket-preview svg { max-width: 100% !important; height: auto !important; }
}
