/* =========================================================================
   CopiaMaster PRO - Stylesheet Principal
   Diseño de Alta Gama para Mostradores de Centros de Copiado e Imprentas
   ========================================================================= */

:root {
  --bg-dark: #080c14;
  --bg-card: #0f172a;
  --bg-sidebar: #0b1120;
  --border-color: #1e293b;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

input, textarea, select {
  user-select: text;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* =========================================================================
   BARRA SUPERIOR (TOPBAR)
   ========================================================================= */
.topbar {
  background: #060a12;
  border-bottom: 1px solid var(--border-color);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  z-index: 100;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #030712;
  font-size: 1.25rem;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.4);
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
}

.brand-name span {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-left: 4px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.brand-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Navegación de Pestañas */
.nav-tabs {
  display: flex;
  gap: 6px;
  background: #0a0f1d;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.3);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.caja-quick-pill {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cbd5e1;
}

.caja-quick-pill strong {
  color: var(--accent-gold);
  font-size: 0.95rem;
}

.btn-icon-subtle {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 0.75rem;
}

.btn-icon-subtle:hover { color: #f87171; }

.badge-license {
  border: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.badge-pro {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #34d399;
}

/* =========================================================================
   CONTENEDOR DE PESTAÑAS (TAB CONTENT)
   ========================================================================= */
.app-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.tab-pane {
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.tab-pane.active {
  display: flex;
}

/* =========================================================================
   MÓDULO 1: TALLER DE FOTOCOPIAS & LIENZO DE PAPEL
   ========================================================================= */
#tab-taller-fotos {
  display: none;
  flex-direction: row;
}
#tab-taller-fotos.active {
  display: flex;
}

.sidebar-tools {
  width: 320px;
  min-width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-cyan);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}

.sidebar-header h3 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.paper-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.btn-paper {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: 0.15s;
}

.btn-paper.active {
  background: var(--accent-cyan);
  color: #030712;
  border-color: var(--accent-cyan);
}

.preset-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-preset {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  transition: 0.2s;
}

.btn-preset:hover {
  background: #1e293b;
  border-color: var(--accent-cyan);
  transform: translateX(3px);
}

.btn-preset i {
  font-size: 1.2rem;
  color: var(--accent-cyan);
  min-width: 22px;
}

.btn-preset strong {
  display: block;
  font-size: 0.82rem;
}

.btn-preset small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.input-measure-row {
  display: flex;
  gap: 6px;
  align-items: flex-end;
}

.input-field {
  flex: 1;
}

.input-field span {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 2px;
}

.input-field input {
  width: 100%;
  background: #090e18;
  border: 1px solid #334155;
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.btn-apply-size {
  background: #0284c7;
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-filter {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  padding: 8px 6px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.2s;
}

.btn-filter:hover {
  background: #1e293b;
  border-color: var(--accent-cyan);
}

.btn-filter.active {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.action-buttons-row {
  display: flex;
  gap: 6px;
}

.btn-secondary {
  flex: 1;
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-secondary:hover { background: #334155; }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #f87171;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

/* Área Central de Trabajo / Canvas */
.canvas-workspace-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #05080f;
  overflow: hidden;
}

.workspace-toolbar {
  height: 52px;
  background: #0a0e18;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-upload-file {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.3);
}

.btn-tool-icon {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #94a3b8;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-tool-icon:hover { color: #fff; background: #1e293b; }

.paper-info-badge {
  font-size: 0.8rem;
  color: #64748b;
  font-family: monospace;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #0f172a;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.zoom-controls button {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
}

.btn-primary-print {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-primary-print:hover { transform: scale(1.02); }

/* Visor con Regla */
.paper-viewport {
  flex: 1;
  overflow: auto;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px;
  background: radial-gradient(circle, #0e1726 10%, #05080f 90%);
}

/* Hoja Virtual a Escala Real (Carta: 215.9mm x 279.4mm -> ~816px x 1056px a 96DPI) */
.virtual-sheet {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.05);
  position: relative;
  transition: transform 0.2s ease;
  overflow: hidden;
}

.sheet-carta {
  width: 816px;
  height: 1056px;
  min-width: 816px;
  min-height: 1056px;
}

.sheet-oficio {
  width: 816px;
  height: 1344px;
  min-width: 816px;
  min-height: 1344px;
}

.sheet-a4 {
  width: 794px;
  height: 1123px;
  min-width: 794px;
  min-height: 1123px;
}

.canvas-dropzone {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.drop-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #94a3b8;
  pointer-events: none;
}

.drop-hint i {
  font-size: 3.5rem;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.drop-hint h4 {
  font-size: 1.1rem;
  color: #475569;
  margin-bottom: 6px;
}

.drop-hint p {
  font-size: 0.85rem;
  color: #94a3b8;
}

/* Cajas de Imágenes en el Lienzo (Draggable & Resizable) */
.canvas-item-box {
  position: absolute;
  cursor: move;
  box-sizing: border-box;
  border: 1.5px dashed rgba(6, 182, 212, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  transition: box-shadow 0.15s;
}

.canvas-item-box.selected {
  border: 2px solid #0284c7;
  box-shadow: 0 0 15px rgba(2, 132, 199, 0.4);
}

.canvas-item-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

/* Manillas de Redimensionamiento */
.box-resizer {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #0284c7;
  border: 2px solid #fff;
  border-radius: 50%;
  z-index: 10;
}

.resizer-br { right: -6px; bottom: -6px; cursor: se-resize; }
.resizer-tr { right: -6px; top: -6px; cursor: ne-resize; }
.resizer-bl { left: -6px; bottom: -6px; cursor: sw-resize; }
.resizer-tl { left: -6px; top: -6px; cursor: nw-resize; }

.box-dimension-tag {
  position: absolute;
  bottom: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #38bdf8;
  font-size: 0.65rem;
  font-weight: 700;
  font-family: monospace;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.box-cut-lines {
  position: absolute;
  top: -10px; left: -10px; right: -10px; bottom: -10px;
  border: 1px dashed #cbd5e1;
  pointer-events: none;
}

/* =========================================================================
   MÓDULO 2: GESTOR Y EXTRACTOR DE PDFS
   ========================================================================= */
.pdf-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.pdf-top-bar {
  height: 60px;
  background: #0a0f1d;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.pdf-actions-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pdf-meta-badge {
  background: #0f172a;
  border: 1px solid #334155;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #38bdf8;
  font-weight: 700;
}

.pdf-layout-select {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.pdf-layout-select select {
  background: #0f172a;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 6px 8px;
  border-radius: 6px;
}

.pdf-grid-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
  background: #05080f;
}

.pdf-pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.empty-pdf-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-pdf-state i {
  font-size: 4rem;
  color: #ef4444;
  margin-bottom: 15px;
}

.pdf-page-card {
  background: #0f172a;
  border: 2px solid #1e293b;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdf-page-card:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-3px);
}

.pdf-page-card.selected {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

.pdf-thumb-wrapper {
  width: 100%;
  aspect-ratio: 1 / 1.35;
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-thumb-wrapper canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.pdf-page-footer {
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  width: 100%;
  color: #cbd5e1;
}

.pdf-badge-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #10b981;
  color: #030712;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.pdf-page-card.selected .pdf-badge-check {
  display: flex;
}

/* =========================================================================
   MÓDULO 3: GENERADOR EXPRESS DE CURRÍCULUM VITAE (CV)
   ========================================================================= */
.cv-module-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
}

.cv-form-pane {
  width: 480px;
  min-width: 440px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.cv-form-header {
  height: 60px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cv-form-header h3 {
  font-size: 1rem;
  font-weight: 800;
}

.cv-template-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.cv-template-picker select {
  background: #090e18;
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 0.8rem;
}

.cv-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cv-section-block {
  background: #090e1a;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px;
}

.cv-section-block h4 {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.cv-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.cv-grid-2 label, .cv-section-block label {
  display: block;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-bottom: 2px;
}

.cv-grid-2 input, .cv-section-block input, .cv-section-block textarea {
  width: 100%;
  background: #060912;
  border: 1px solid #1e293b;
  color: #fff;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.cv-grid-2 input:focus, .cv-section-block input:focus, .cv-section-block textarea:focus {
  border-color: var(--accent-cyan);
  outline: none;
}

.btn-add-item {
  background: #0284c7;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

.cv-item-card {
  background: #0d1424;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  position: relative;
}

.cv-item-card .btn-remove-item {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
}

.btn-subtle {
  background: transparent;
  border: 1px solid #334155;
  color: #94a3b8;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
}

/* Vista Previa del CV */
.cv-preview-pane {
  flex: 1;
  background: #05080f;
  display: flex;
  flex-direction: column;
}

.cv-preview-toolbar {
  height: 60px;
  background: #0a0f1d;
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cv-sheet-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  justify-content: center;
}

/* Hoja Carta para CV */
.cv-sheet {
  width: 816px;
  min-height: 1056px;
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  font-family: "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
}

/* Temas de CV */
.cv-theme-moderno {
  display: flex;
}

.cv-moderno-sidebar {
  width: 270px;
  background: #0f172a;
  color: #f8fafc;
  padding: 35px 25px;
}

.cv-moderno-main {
  flex: 1;
  padding: 40px 35px;
  color: #334155;
}

.cv-theme-clasico {
  padding: 45px 50px;
}

/* =========================================================================
   MÓDULO 4: REFERENCIAS & CARTAS
   ========================================================================= */
.letters-module-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
}

.letters-sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  padding: 18px;
}

.letters-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
}

.btn-letter-type {
  background: #0f172a;
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
  transition: 0.2s;
}

.btn-letter-type:hover {
  background: #1e293b;
  color: #fff;
}

.btn-letter-type.active {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #fff;
  border-color: #0284c7;
}

.letters-form-area {
  width: 380px;
  min-width: 350px;
  background: #090e18;
  border-right: 1px solid var(--border-color);
  padding: 20px;
  overflow-y: auto;
}

.letters-form-card label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  margin-top: 10px;
  margin-bottom: 2px;
}

.letters-form-card input, .letters-form-card textarea {
  width: 100%;
  background: #05080f;
  border: 1px solid #1e293b;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
}

.letters-preview-area {
  flex: 1;
  background: #05080f;
  display: flex;
  flex-direction: column;
}

.letters-preview-header {
  height: 60px;
  background: #0a0f1d;
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.letter-sheet-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  display: flex;
  justify-content: center;
}

.letter-sheet {
  width: 816px;
  min-height: 1056px;
  background: #ffffff;
  color: #0f172a;
  padding: 80px 75px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  font-family: "Times New Roman", Times, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  box-sizing: border-box;
}

/* =========================================================================
   MÓDULO 5: CAJA & TARIFAS
   ========================================================================= */
.caja-module-wrapper {
  width: 100%;
  height: 100%;
  padding: 30px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 25px;
}

.caja-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 24px;
}

.caja-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.caja-card-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-accent {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
}

.caja-grid-calc {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.caja-counter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #090e18;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #1e293b;
}

.caja-counter-item label {
  font-size: 0.88rem;
  font-weight: 600;
  color: #cbd5e1;
  flex: 1;
}

.counter-control {
  display: flex;
  align-items: center;
  gap: 4px;
}

.counter-control button {
  width: 32px;
  height: 32px;
  background: #1e293b;
  border: 1px solid #334155;
  color: #fff;
  border-radius: 6px;
  font-size: 1.1rem;
  cursor: pointer;
}

.counter-control input {
  width: 50px;
  text-align: center;
  background: #05080f;
  border: 1px solid #334155;
  color: #fff;
  padding: 6px 0;
  border-radius: 6px;
  font-weight: 700;
}

.subtotal-item {
  min-width: 80px;
  text-align: right;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent-gold);
}

.caja-total-bar {
  margin-top: 20px;
  background: #090d16;
  border: 2px solid var(--accent-gold);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.caja-big-total {
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--accent-gold);
  line-height: 1;
  margin-top: 4px;
}

.btn-clear-caja {
  background: #1e293b;
  border: 1px solid #334155;
  color: #f87171;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

.rates-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rates-form-grid label {
  display: block;
  font-size: 0.78rem;
  color: #94a3b8;
  margin-bottom: 2px;
}

.rates-form-grid input {
  width: 100%;
  background: #090e18;
  border: 1px solid #1e293b;
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 700;
}

.btn-save-rates {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

/* =========================================================================
   MODAL DE LICENCIA
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.modal-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 14px;
  width: 500px;
  max-width: 90%;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.5rem;
  cursor: pointer;
}

.machine-id-card {
  background: #090e18;
  border: 1px solid #1e293b;
  border-radius: 8px;
  padding: 12px;
  margin-top: 12px;
}

.machine-id-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.machine-id-row input {
  flex: 1;
  background: #05080f;
  border: 1px solid #334155;
  color: var(--accent-cyan);
  font-family: monospace;
  font-size: 1rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 6px;
}

.btn-copy {
  background: #0284c7;
  color: #fff;
  border: none;
  padding: 0 14px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.serial-input {
  width: 100%;
  background: #05080f;
  border: 2px solid #334155;
  color: #fff;
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 800;
  padding: 10px;
  border-radius: 8px;
  margin-top: 4px;
  text-align: center;
  letter-spacing: 2px;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
}

.btn-whatsapp {
  background: #25d366;
  color: #050505;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-activate {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

/* =========================================================================
   PROTECCIÓN COMERCIAL: MARCA DE AGUA EN MODO DEMOSTRACIÓN
   ========================================================================= */
.is-demo-mode .canvas-dropzone,
.is-demo-mode .cv-sheet,
.is-demo-mode .letter-sheet {
  position: relative !important;
}

.is-demo-mode .canvas-dropzone::before,
.is-demo-mode .cv-sheet::before,
.is-demo-mode .letter-sheet::before {
  content: "DEMO COPIAMASTER PRO · COPIA DE PRUEBA · MISPROGRAMAS.LIVE";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 24px;
  font-weight: 900;
  color: rgba(220, 38, 38, 0.25) !important;
  text-transform: uppercase;
  letter-spacing: 3px;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  border: 3px dashed rgba(220, 38, 38, 0.35);
  padding: 14px 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.35);
}

/* Botón Guardar en PDF */
.btn-secondary-pdf:hover {
  background: #1e293b !important;
  color: #7dd3fc !important;
  border-color: #38bdf8 !important;
  transform: scale(1.02);
}

/* =========================================================================
   MÓDULO DE AVISOS, CARTELES & PAGO MÓVIL
   ========================================================================= */
.template-category-tabs {
  display: flex;
  background: #0f172a;
  border-bottom: 1px solid var(--border-color);
  padding: 8px 12px;
  gap: 6px;
  overflow-x: auto;
}

.btn-template-cat {
  background: transparent;
  border: 1px solid transparent;
  color: #94a3b8;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-template-cat:hover { color: #fff; background: #1e293b; }
.btn-template-cat.active {
  background: #0284c7;
  color: #fff;
  border-color: #38bdf8;
}

.template-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.template-card {
  background: #0f172a;
  border: 1.5px solid #334155;
  border-radius: 8px;
  padding: 10px 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.template-card:hover {
  border-color: #38bdf8;
  transform: translateY(-2px);
}

.template-card.active {
  border-color: #38bdf8;
  background: rgba(2, 132, 199, 0.15);
  box-shadow: 0 0 12px rgba(2, 132, 199, 0.4);
}

.card-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.card-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cbd5e1;
  line-height: 1.2;
}

.form-group-row {
  margin-bottom: 12px;
}

.form-group-row label {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.form-group-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.form-group-row-2col label {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}

.input-tpl {
  width: 100%;
  background: #1e293b;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 8px 10px;
  color: #fff;
  font-size: 0.85rem;
  box-sizing: border-box;
}

.input-tpl:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

/* Hoja del Cartel */
.poster-sheet {
  width: 816px;
  height: 1056px;
  background: #ffffff;
  color: #000000;
  box-shadow: 0 10px 35px rgba(0,0,0,0.6);
  padding: 24px;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
}

.poster-card-wrapper {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.poster-header-bar {
  padding: 28px 20px;
  text-align: center;
}

.poster-body {
  flex: 1;
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.poster-business-name {
  font-size: 1.7rem;
  font-weight: 900;
  color: #0f172a;
  text-align: center;
  text-transform: uppercase;
  border-bottom: 3px solid #e2e8f0;
  padding-bottom: 12px;
  width: 100%;
}

.poster-data-grid {
  width: 100%;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.poster-data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  padding: 14px 24px;
  border-radius: 10px;
}

.poster-data-row .p-label {
  font-size: 1.15rem;
  font-weight: 900;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 10px;
}

.poster-data-row .p-val-large {
  font-size: 1.9rem;
  font-weight: 900;
  color: #0f172a;
  font-family: monospace;
  letter-spacing: 1px;
}

.poster-data-row .p-val-med {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
}

.poster-qr-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.poster-qr-box {
  background: #ffffff;
  padding: 10px;
  border: 3px solid #0f172a;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.poster-qr-caption {
  font-size: 0.85rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 1px;
}

.poster-footer-note {
  font-size: 1rem;
  font-weight: 800;
  color: #dc2626;
  text-align: center;
  padding-top: 10px;
}

/* Carteles Comerciales Gigantes */
.commercial-poster {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  padding: 0;
}

.commercial-header {
  padding: 40px 20px;
}

.comm-title-huge {
  font-size: 5rem;
  font-weight: 900;
  margin: 0;
  letter-spacing: 4px;
  line-height: 1;
  text-transform: uppercase;
}

.commercial-body {
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 30px;
  flex: 1;
}

.comm-subtitle {
  font-size: 2.2rem;
  font-weight: 800;
  color: #1e293b;
  text-transform: uppercase;
  line-height: 1.2;
}

.comm-phone-box {
  background: #fffbeb;
  padding: 24px;
  border-radius: 16px;
}

.comm-phone-label {
  font-size: 1.3rem;
  font-weight: 900;
  color: #b45309;
  margin-bottom: 8px;
}

.comm-phone-num {
  font-size: 4rem;
  font-weight: 900;
  color: #0f172a;
  font-family: monospace;
  letter-spacing: 2px;
}

.comm-extra-text {
  font-size: 1.4rem;
  font-weight: 700;
  color: #64748b;
}

.commercial-footer-bar {
  height: 35px;
  width: 100%;
}

/* Marcos de Fotos */
.frame-wrapper {
  background: #fff;
  padding: 24px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.frame-inner-border {
  border: 12px double #f59e0b;
  border-radius: 20px;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.frame-title {
  font-size: 3rem;
  font-weight: 900;
  color: #d97706;
  text-align: center;
  margin-bottom: 10px;
  font-family: 'Brush Script MT', cursive, sans-serif;
}

.frame-photo-container {
  width: 440px;
  height: 440px;
  border-radius: 16px;
  overflow: hidden;
  border: 6px solid #fef3c7;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  background: #0f172a;
}

.frame-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.frame-name {
  font-size: 2.2rem;
  font-weight: 900;
  color: #1e293b;
  text-align: center;
  margin-top: 15px;
}

.frame-msg {
  font-size: 1.15rem;
  font-style: italic;
  color: #64748b;
  text-align: center;
  max-width: 80%;
}

/* Toast flotante de notificaciones */
.copia-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1.5px solid #38bdf8;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100000;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.copia-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.copia-toast.toast-success { border-color: #10b981; }
.copia-toast.toast-info { border-color: #38bdf8; }
.copia-toast.toast-warning { border-color: #f59e0b; }

/* =========================================================================
   IMPRESIÓN PURA AL 100% SIN MÁRGENES PARÁSITOS (@media print)
   ========================================================================= */
@media print {
  @page {
    size: letter portrait;
    margin: 0 !important;
  }

  html, body {
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
    overflow: visible !important;
    height: auto !important;
    width: 100% !important;
  }

  /* 1. OCULTAR TODA LA INTERFAZ DE NAVEGACIÓN Y HERRAMIENTAS */
  header, nav, .topbar, .topbar-actions, .sidebar-tools, .workspace-toolbar, 
  .pdf-top-bar, .cv-form-pane, .cv-preview-toolbar, .letters-sidebar, 
  .letters-form-area, .letters-preview-header, .caja-module-wrapper, 
  .modal-backdrop, .drop-hint, .box-resizer, .box-dimension-tag, 
  .box-cut-lines, .badge-license, .caja-quick-pill, .pdf-pages-grid, .empty-pdf-state {
    display: none !important;
  }

  /* 2. OCULTAR TODAS LAS PESTAÑAS INACTIVAS */
  .tab-pane {
    display: none !important;
  }

  /* 3. SOLO MOSTRAR LA PESTAÑA QUE ESTÁ ACTIVA */
  .tab-pane.active {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app-main {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* 4. HOJA VIRTUAL DE FOTOCOPIAS (Ajuste milimétrico a 1 sola página) */
  .canvas-workspace-area,
  .paper-viewport {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  .virtual-sheet {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
    padding: 0 !important;
    transform: none !important; /* Anula cualquier zoom de pantalla */
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    overflow: hidden !important;
  }

  /* Dimensiones exactas milimétricas para la hoja física */
  .sheet-carta {
    width: 215.9mm !important;
    height: 279.4mm !important;
    max-width: 215.9mm !important;
    max-height: 279.4mm !important;
  }
  .sheet-oficio {
    width: 215.9mm !important;
    height: 355.6mm !important;
  }
  .sheet-a4 {
    width: 210mm !important;
    height: 297mm !important;
  }

  .canvas-item-box {
    border: none !important;
    box-shadow: none !important;
  }

  /* 5. HOJA DE CURRÍCULUM VITAE (1 sola página) */
  .cv-module-wrapper,
  .cv-preview-pane,
  .cv-sheet-wrapper {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    width: 100% !important;
    height: auto !important;
  }

  .cv-sheet,
  .poster-sheet {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
    width: 215.9mm !important;
    height: 279.4mm !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* 6. HOJA DE REFERENCIAS Y CARTAS (1 sola página) */
  .letters-module-wrapper,
  .letters-preview-area,
  .letter-sheet-viewport {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    width: 100% !important;
    height: auto !important;
  }

  .letter-sheet {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
    width: 215.9mm !important;
    height: 279.4mm !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  /* Marca de agua en modo demo durante impresión */
  .is-demo-mode .canvas-dropzone::before,
  .is-demo-mode .cv-sheet::before,
  .is-demo-mode .letter-sheet::before {
    display: block !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) rotate(-45deg) !important;
    font-size: 26px !important;
    font-weight: 900 !important;
    color: rgba(180, 20, 20, 0.35) !important;
    border: 3px dashed rgba(180, 20, 20, 0.45) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    z-index: 99999 !important;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
