/*!
 * Tibor2 — DTF por Metros (Pliego optimizado)
 * Estilos del optimizador de gang sheet.
 */

:root {
  --t2-primary: #1a1a2e;
  --t2-accent:  #0b3989;
  --t2-bg:      #f8f9fb;
  --t2-bg-w:    #ffffff;
  --t2-border:  #e2e8f0;
  --t2-text:    #2d3748;
  --t2-muted:   #718096;
  --t2-radius:  8px;
  --t2-radius-sm: 5px;
  --t2-transition: .18s ease;
}

.t2-gs {
  font-family: 'Inter', Arial, sans-serif;
  color: var(--t2-text);
  font-size: 14px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px 16px;
  box-sizing: border-box;
}
.t2-gs *, .t2-gs *::before, .t2-gs *::after { box-sizing: inherit; }

/* ── Header ─────────────────────────────────────────────────── */
.t2-header { margin-bottom: 20px; }
.t2-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--t2-primary);
  margin: 0 0 6px;
}
.t2-sub {
  color: var(--t2-muted);
  font-size: .92rem;
  margin: 0;
  line-height: 1.5;
}

/* ── Dropzone ───────────────────────────────────────────────── */
.t2-dropzone {
  border: 2px dashed var(--t2-border);
  border-radius: var(--t2-radius);
  background: var(--t2-bg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t2-transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.t2-dropzone:hover,
.t2-dropzone.drag-over {
  border-color: var(--t2-accent);
  background: #fff7f3;
}
.t2-dropzone-icon { font-size: 2rem; }
.t2-dropzone-text strong { display: block; color: var(--t2-primary); font-size: 1rem; }
.t2-dropzone-text span   { color: var(--t2-muted); font-size: .82rem; }

/* ── Mensaje de error ───────────────────────────────────────── */
.t2-err {
  margin-top: 14px;
  padding: 10px 14px;
  background: #ffebee;
  color: #c62828;
  border-left: 4px solid #e53e3e;
  border-radius: var(--t2-radius-sm);
  font-size: .85rem;
}

/* ── Lista de archivos ──────────────────────────────────────── */
.t2-files-wrap { margin-top: 24px; }
.t2-files-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.t2-files-title {
  font-weight: 700;
  color: var(--t2-primary);
  font-size: .95rem;
}
.t2-files-count {
  color: var(--t2-muted);
  font-size: .82rem;
}
.t2-files-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.t2-file {
  display: grid;
  grid-template-columns: 64px 1fr auto 28px;
  gap: 14px;
  align-items: center;
  background: var(--t2-bg-w);
  border: 1px solid var(--t2-border);
  border-radius: var(--t2-radius);
  padding: 10px 12px;
}
.t2-file-thumb {
  width: 64px; height: 64px;
  object-fit: contain;
  background: var(--t2-bg);
  border-radius: var(--t2-radius-sm);
  border: 1px solid var(--t2-border);
}
.t2-file-name {
  font-weight: 600;
  color: var(--t2-primary);
  font-size: .9rem;
  word-break: break-word;
}
.t2-file-dims {
  font-size: .8rem;
  color: var(--t2-muted);
  margin-top: 2px;
}
.t2-file-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--t2-border);
  border-radius: var(--t2-radius-sm);
  overflow: hidden;
  background: var(--t2-bg-w);
}
.t2-qty-btn {
  width: 32px; height: 36px;
  border: none;
  background: transparent;
  color: var(--t2-primary);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t2-transition);
  font-family: inherit;
}
.t2-qty-btn:hover { background: var(--t2-bg); color: var(--t2-accent); }
.t2-qty-input {
  border: none;
  width: 50px; height: 36px;
  text-align: center;
  background: transparent;
  font-weight: 600;
  color: var(--t2-primary);
  -moz-appearance: textfield;
  padding: 0;
  font-family: inherit;
}
.t2-qty-input::-webkit-outer-spin-button,
.t2-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.t2-file-remove {
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--t2-muted);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--t2-transition);
  line-height: 1;
}
.t2-file-remove:hover { background: #fee; color: #dc2626; }

/* ── Parámetros ─────────────────────────────────────────────── */
.t2-params {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 28px;
  align-items: center;
  padding: 16px 18px;
  background: var(--t2-bg);
  border-radius: var(--t2-radius);
}
.t2-param { display: flex; flex-direction: column; gap: 6px; }
.t2-param-label {
  font-size: .78rem;
  color: var(--t2-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: .04em;
}
.t2-param-input {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--t2-border);
  border-radius: var(--t2-radius-sm);
  background: var(--t2-bg-w);
  padding: 0 10px;
}
.t2-margin-input {
  border: none;
  background: transparent;
  width: 64px;
  height: 38px;
  text-align: right;
  font-weight: 600;
  color: var(--t2-primary);
  font-family: inherit;
  font-size: .95rem;
  outline: none;
}
.t2-margin-input::-webkit-outer-spin-button,
.t2-margin-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.t2-param-suffix {
  color: var(--t2-muted);
  font-size: .85rem;
  padding-left: 6px;
}
.t2-param-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: .9rem;
  color: var(--t2-text);
}
.t2-param-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--t2-accent); }

/* ── Botón Calcular ─────────────────────────────────────────── */
.t2-btn-calc {
  margin-top: 22px;
  width: 100%;
  padding: 16px 24px;
  background: var(--t2-accent);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: var(--t2-radius);
  cursor: pointer;
  transition: background var(--t2-transition);
  font-family: inherit;
}
.t2-btn-calc:hover:not(:disabled) { background: #c73c09; }
.t2-btn-calc:disabled { opacity: .5; cursor: not-allowed; }

/* ════════════════════════════════════════════════════════════
   PASO 2 — preview + precio
   ════════════════════════════════════════════════════════════ */
.t2-preview-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 900px) {
  .t2-preview-layout { grid-template-columns: 1fr; }
}

/* ── Canvas ─────────────────────────────────────────────────── */
.t2-canvas-wrap {
  background: var(--t2-bg-w);
  border: 1px solid var(--t2-border);
  border-radius: var(--t2-radius);
  overflow: hidden;
}
.t2-canvas-label {
  padding: 12px 16px;
  font-size: .75rem;
  font-weight: 700;
  color: var(--t2-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--t2-border);
  background: var(--t2-bg);
}
.t2-canvas-container {
  overflow-x: auto;
  overflow-y: hidden;
  height: 320px;
  background: #e5e7eb;
}
.t2-canvas-container canvas { display: block; max-width: none; }
.t2-canvas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  font-size: .78rem;
  color: var(--t2-muted);
  border-top: 1px solid var(--t2-border);
  background: var(--t2-bg);
}
.t2-canvas-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.t2-canvas-legend > span::before {
  content: '';
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
}
.t2-legend-billing::before { background: #f5a623; }
.t2-legend-meter::before   { background: #cbd5e0; border: 1px dashed #999; }
.t2-legend-cut::before     { background: #15803d; }

/* ── Panel de precio ────────────────────────────────────────── */
.t2-price-panel {
  background: var(--t2-bg-w);
  border: 1px solid var(--t2-border);
  border-radius: var(--t2-radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.t2-badge {
  display: inline-block;
  background: var(--t2-accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  align-self: flex-start;
}

/* Resumen archivos en el pliego */
.t2-summary-title {
  font-size: .78rem;
  font-weight: 700;
  color: var(--t2-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.t2-summary-files {
  background: var(--t2-bg);
  border-radius: var(--t2-radius-sm);
  padding: 10px 12px;
  max-height: 260px;
  overflow-y: auto;
}
.t2-summary-row {
  display: grid;
  grid-template-columns: 32px 1fr auto 22px;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: .85rem;
  border-bottom: 1px solid var(--t2-border);
}
.t2-summary-row:last-child { border-bottom: none; }
.t2-summary-thumb {
  width: 32px; height: 32px;
  object-fit: contain;
  background: var(--t2-bg-w);
  border-radius: 3px;
  border: 1px solid var(--t2-border);
}
.t2-summary-name {
  color: var(--t2-text);
  word-break: break-word;
  line-height: 1.25;
}
.t2-summary-qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--t2-border);
  border-radius: var(--t2-radius-sm);
  overflow: hidden;
  background: var(--t2-bg-w);
}
.t2-summary-qty-btn {
  width: 26px; height: 28px;
  border: none;
  background: transparent;
  color: var(--t2-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--t2-transition);
  font-family: inherit;
  padding: 0;
  line-height: 1;
}
.t2-summary-qty-btn:hover:not(:disabled) { background: var(--t2-bg); color: var(--t2-accent); }
.t2-summary-qty-btn:disabled { opacity: .35; cursor: not-allowed; }
.t2-summary-qty-val {
  min-width: 28px;
  text-align: center;
  font-weight: 700;
  color: var(--t2-primary);
  font-size: .88rem;
  padding: 0 2px;
  user-select: none;
}
.t2-summary-remove {
  width: 22px; height: 22px;
  border: none;
  background: transparent;
  color: var(--t2-muted);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all var(--t2-transition);
  line-height: 1;
  padding: 0;
  font-family: inherit;
}
.t2-summary-remove:hover { background: #fee; color: #dc2626; }
.t2-summary-files.is-busy { opacity: .55; pointer-events: none; }

/* Stats */
.t2-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.t2-stat {
  background: var(--t2-bg);
  border-radius: var(--t2-radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.t2-stat-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--t2-primary);
}
.t2-stat-lbl {
  font-size: .7rem;
  color: var(--t2-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}

/* Desglose */
.t2-breakdown {
  border-top: 1px solid var(--t2-border);
  padding-top: 12px;
}
.t2-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: .9rem;
}
.t2-row-lbl { color: var(--t2-text); }
.t2-row-val { color: var(--t2-primary); font-weight: 600; }
.t2-row-total {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--t2-border);
  background: var(--t2-primary);
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--t2-radius-sm);
  font-weight: 700;
}
.t2-row-total span:first-child { font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.t2-row-total .t2-val-total { font-size: 1.1rem; color: #fff; }

/* Portes */
.t2-shipping {
  padding: 10px 14px;
  border-radius: var(--t2-radius-sm);
  background: #e3f2fd;
  color: #1565c0;
  font-size: .85rem;
  text-align: center;
}
.t2-shipping.free { background: #e8f5e9; color: #2e7d32; }

/* Interruptor de la reorganización inteligente (paso 2, junto al pliego) */
.t2-switch-row {
  padding-top: 12px;
  border-top: 1px dashed var(--t2-border);
}
.t2-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.t2-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.t2-switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background var(--t2-transition);
  flex: none;
}
.t2-switch-dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform var(--t2-transition);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.t2-switch input:checked + .t2-switch-track { background: var(--t2-accent); }
.t2-switch input:checked + .t2-switch-track .t2-switch-dot { transform: translateX(18px); }
.t2-switch input:focus-visible + .t2-switch-track {
  outline: 2px solid var(--t2-accent);
  outline-offset: 2px;
}
.t2-switch-txt  { font-size: .88rem; font-weight: 700; }
.t2-switch-help {
  display: block;
  margin-top: 6px;
  font-size: .76rem;
  color: var(--t2-muted);
  line-height: 1.4;
}

/* Aviso verde: solo cuando de verdad ahorra metros */
.t2-smart-note {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: var(--t2-radius-sm);
  background: #e8f5e9;
  color: #2e7d32;
  font-size: .85rem;
  font-weight: 600;
  text-align: center;
}

/* Botón añadir al carrito */
.t2-btn-cart {
  margin-top: 4px;
  padding: 16px 24px;
  background: var(--t2-accent);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  border-radius: var(--t2-radius);
  cursor: pointer;
  transition: background var(--t2-transition);
  font-family: inherit;
}
.t2-btn-cart:hover:not(:disabled) { background: #c73c09; }
.t2-btn-cart:disabled { opacity: .65; cursor: wait; }

/* ── Nav paso 2 ─────────────────────────────────────────────── */
.t2-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 10px 0;
}
.t2-btn-back {
  background: transparent;
  border: 1px solid var(--t2-border);
  color: var(--t2-text);
  padding: 10px 18px;
  border-radius: var(--t2-radius-sm);
  cursor: pointer;
  font-weight: 600;
  font-size: .88rem;
  transition: all var(--t2-transition);
  font-family: inherit;
}
.t2-btn-back:hover { background: var(--t2-bg); border-color: var(--t2-primary); color: var(--t2-primary); }
.t2-nav-info { color: var(--t2-muted); font-size: .82rem; }
