/* =====================================================
   CONSOLIDADOR INTELIGENTE DE PEDIDOS — ESTILOS
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0e1a;
  --surface: #111527;
  --surface-2: #171c31;
  --surface-3: #1e243d;
  --border: rgba(255,255,255,0.07);
  --border-accent: rgba(99,102,241,0.35);
  --primary: #6366f1;
  --primary-light: #818cf8;
  --secondary: #8b5cf6;
  --accent: #22d3ee;
  --accent-green: #34d399;
  --accent-yellow: #fbbf24;
  --accent-red: #f87171;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(99,102,241,0.15);
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* === BACKGROUND ORBS === */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  animation: float 20s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: var(--primary); top: -200px; left: -200px; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: var(--secondary); bottom: -150px; right: -150px; animation-delay: -7s; }
.orb-3 { width: 400px; height: 400px; background: var(--accent); top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -14s; }

@keyframes float {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(30px,-30px) scale(1.05); }
  66% { transform: translate(-20px,20px) scale(0.95); }
}

/* === APP CONTAINER === */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* === HEADER === */
.app-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 40px;
  padding: 28px 32px;
  background: var(--surface);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glow), var(--shadow);
}

.header-icon svg {
  width: 56px;
  height: 56px;
  filter: drop-shadow(0 0 16px rgba(99,102,241,0.5));
}

.header-text h1 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-text p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

/* === UPLOAD SECTION === */
.upload-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.upload-zone {
  border: 2px dashed rgba(99,102,241,0.4);
  border-radius: var(--radius);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  background: rgba(99,102,241,0.03);
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: rgba(99,102,241,0.08);
  transform: scale(1.005);
  box-shadow: 0 0 30px rgba(99,102,241,0.1);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  color: var(--primary-light);
}

.upload-zone h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-hint {
  display: inline-block;
  margin: 12px 0;
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(34,211,238,0.1);
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(34,211,238,0.2);
}

.btn-upload {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  position: relative;
  z-index: 1;
}

.btn-upload svg { width: 18px; height: 18px; }
.btn-upload:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99,102,241,0.5); }

/* === FILE LIST === */
.file-list {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.file-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #22d3ee22, #6366f122);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.file-icon svg { width: 18px; height: 18px; }

.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.9rem; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: color var(--transition);
  display: flex;
}

.file-remove:hover { color: var(--accent-red); }
.file-remove svg { width: 16px; height: 16px; }

/* === PROCESS ACTIONS === */
.process-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

.btn-process {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}

.btn-process svg { width: 18px; height: 18px; }
.btn-process:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(99,102,241,0.6); }
.btn-process:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-clear {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 24px;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-clear svg { width: 16px; height: 16px; }
.btn-clear:hover { color: var(--accent-red); border-color: var(--accent-red); }

/* === PROGRESS === */
.progress-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.progress-bar-wrap {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.4s ease;
  box-shadow: 0 0 12px rgba(99,102,241,0.5);
}

.progress-label {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* === RESULTS === */
.results-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* === TABS === */
.tabs-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  background: var(--surface-2);
  gap: 4px;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
}

.tab-btn svg { width: 16px; height: 16px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 10px;
  background: rgba(248,113,113,0.2);
  color: var(--accent-red);
}

.badge.hidden { display: none; }

.tab-content { display: none; padding: 24px; }
.tab-content.active { display: block; }

/* === CATALOG SECTION === */
.sheet-section {
  margin-bottom: 32px;
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.sheet-header .btn-export {
  font-size: 0.8rem;
  padding: 8px 14px;
}

.sheet-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, rgba(34,211,238,0.2), rgba(99,102,241,0.2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.sheet-icon svg { width: 16px; height: 16px; }
.sheet-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.sheet-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* === BLOCK SECTION === */
.block-section {
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
}

.block-name { font-size: 0.9rem; font-weight: 600; color: var(--primary-light); }
.block-price { font-size: 0.82rem; color: var(--accent-green); font-weight: 500; }

/* === TABLE === */
.data-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead tr {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(99,102,241,0.04); }

tbody td {
  padding: 10px 14px;
  color: var(--text);
}

.td-product { font-weight: 500; }
.td-color { color: var(--text-dim); }
.td-qty { text-align: center; font-weight: 600; color: var(--accent); }
.td-price { text-align: right; color: var(--accent-green); font-weight: 500; font-family: 'JetBrains Mono', monospace; }
.td-total { text-align: right; color: var(--text-dim); }

/* === STATS GRID === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  animation: fadeUp 0.4s ease both;
}

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

.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }

/* === CONSOLIDATED HEADER === */
.consolidated-header {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.export-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 10px rgba(99,102,241,0.3);
}

.btn-export svg { width: 16px; height: 16px; }
.btn-export:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.5); }
.btn-export.secondary {
  background: transparent;
  border: 1px solid var(--border-accent);
  color: var(--primary-light);
  box-shadow: none;
}
.btn-export.secondary:hover { background: rgba(99,102,241,0.08); }

/* === DIVERGENCES === */
.divergence-section {
  margin-bottom: 20px;
}

.divergence-card {
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius-sm);
  background: rgba(248,113,113,0.04);
  margin-bottom: 12px;
  overflow: hidden;
}

.divergence-card-header {
  padding: 12px 16px;
  background: rgba(248,113,113,0.08);
  border-bottom: 1px solid rgba(248,113,113,0.2);
  display: flex;
  align-items: center;
  gap: 10px;
}

.divergence-icon { color: var(--accent-red); flex-shrink: 0; }
.divergence-icon svg { width: 16px; height: 16px; }
.divergence-product { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.divergence-color { font-size: 0.8rem; color: var(--text-muted); }

.divergence-card-body { padding: 12px 16px; }
.divergence-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.83rem; }
.divergence-row:last-child { border-bottom: none; }
.divergence-sheet { color: var(--text-dim); }
.divergence-price { color: var(--accent-yellow); font-weight: 600; }
.divergence-qty { color: var(--accent); }

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* === ALERT CARDS === */
.alert-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.alert-card.info { background: rgba(34,211,238,0.08); border: 1px solid rgba(34,211,238,0.2); color: var(--accent); }
.alert-card.warn { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.2); color: var(--accent-yellow); }
.alert-card.success { background: rgba(52,211,153,0.08); border: 1px solid rgba(52,211,153,0.2); color: var(--accent-green); }
.alert-card svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }

/* === SEARCH === */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  transition: border-color var(--transition);
  font-family: inherit;
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { outline: none; border-color: var(--primary); }

/* === FOOTER === */
.app-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .app-container { padding: 16px 12px 40px; }
  .app-header { flex-direction: column; text-align: center; padding: 20px; }
  .header-text h1 { font-size: 1.3rem; }
  .tabs-header { padding: 0 12px; }
  .tab-btn { padding: 14px 12px; font-size: 0.8rem; }
  .tab-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* === LOADING SPINNER === */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === COLOR PILL === */
.color-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px 2px 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 0.82rem;
}

.color-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
}
