/* ============================================================
   226ERS IMPORTADOR — PREMIUM B&W + RED B2B PORTAL DESIGN (ROUNDED)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Modern soft color palette */
  --bg-app: #f4f6f9;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  
  /* Brand Primary (Blue instead of Red) */
  --brand: #2563eb;
  --red-primary: #2563eb;
  --red-hover: #1d4ed8;
  --red-light: #eff6ff;
  --red-border: #bfdbfe;
  
  /* Borders & Shadows */
  --border-color: #e2e8f0;
  --border-focus: #cbd5e1;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 12px 24px -4px rgba(0, 0, 0, 0.06), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
  
  /* Border Radius (Rounded Style) */
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;
  
  --sidebar-w: 360px;
  --header-h: 100px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── HEADER ──────────────────────────────────────────────── */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  width: 100%;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.back-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  background: var(--bg-app);
  color: var(--text-muted);
  transition: all 0.2s ease;
  text-decoration: none;
}

.back-link:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.back-link svg {
  width: 20px;
  height: 20px;
}

.logo-mark {
  width: 40px;
  height: 40px;
  background: var(--red-primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(227, 6, 19, 0.2);
}
.logo-mark svg {
  width: 22px;
  height: 22px;
  stroke: white;
}

.logo-brand-container {
  display: flex;
  flex-direction: column;
}

.logo-main-text {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-main);
}

.logo-sub-text {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 1px;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 6px 16px;
  border-radius: 100px;
  background: var(--bg-app);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  display: inline-block;
  transition: all 0.3s;
}
.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}
.status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.layout {
  display: flex;
  width: 100%;
  height: calc(100vh - var(--header-h));
  gap: 0;
}

/* ── SIDEBAR (Rounded Card Style) ───────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden; /* Prevent scrollbar completely */
}

.sidebar-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.sidebar-content {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto; /* Allow scrolling when screen is small */
  overflow-x: hidden;
  flex-grow: 1;
}

/* Form Sections */
.form-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-step {
  color: var(--red-primary);
  font-weight: 800;
}

.detected-type-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f1f5f9;
  border: 1px dashed var(--border-color);
  color: var(--text-muted);
  padding: 12px;
  border-radius: var(--r-md);
  font-size: 0.9rem;
  font-weight: 600;
  width: 100%;
  transition: var(--transition);
}

.detected-type-badge.active {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}

.detected-type-badge svg {
  stroke-width: 2.5;
}

/* Suffix Control */
.suffix-control {
  display: flex;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  padding: 4px;
  border-radius: var(--r-md);
  width: 100%;
}

.suffix-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 8px 0;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: calc(var(--r-md) - 2px);
  cursor: pointer;
  transition: var(--transition);
}

.suffix-btn:hover {
  color: var(--text-main);
}

.suffix-btn.active {
  background: var(--bg-card);
  color: var(--red-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Filter Subtabs (Pills) */
.filter-subtabs {
  display: flex;
  gap: 6px;
}

.subtab-btn {
  padding: 5px 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 100px;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.subtab-btn:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.subtab-btn.active {
  border-color: var(--red-primary);
  background: var(--red-light);
  color: var(--red-primary);
}

.subtab-btn.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
}
.subtab-btn.icon-btn svg {
  width: 13px;
  height: 13px;
}

/* Smooth Rounded Inputs */
.input-text, .input-select {
  width: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s;
}

.input-text:focus, .input-select:focus {
  border-color: var(--red-primary);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.08);
}

.input-text::placeholder {
  color: #a0aec0;
}

.input-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M4 6l4 4 4-4' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  padding-right: 40px;
}

.selected-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-light);
  border: 1px solid var(--red-border);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--red-primary);
}
.selected-badge svg {
  width: 14px;
  height: 14px;
  stroke: var(--red-primary);
}

.error-message {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--red-primary);
  background: #fdf2f2;
  border: 1px solid #fde2e2;
  border-radius: var(--r-sm);
  padding: 10px 14px;
}

/* Rounded Soft Dropzone */
.compact-dropzone {
  border: 1px dashed var(--border-focus);
  padding: 24px;
  border-radius: var(--r-md);
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.compact-dropzone:hover, .compact-dropzone.drag-over {
  border-color: var(--red-primary);
  background: var(--red-light);
}

.compact-dropzone svg {
  width: 28px;
  height: 28px;
  stroke: var(--text-muted);
  transition: stroke 0.2s;
}
.compact-dropzone:hover svg {
  stroke: var(--red-primary);
}

.dropzone-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

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

/* File Display Chip */
.file-display-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--red-border);
  background: var(--red-light);
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--red-primary);
}
.file-display-chip svg {
  width: 16px;
  height: 16px;
  stroke: var(--red-primary);
}
.file-name-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-remove-file {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  padding: 2px;
  transition: color 0.15s;
}
.btn-remove-file:hover {
  color: var(--red-primary);
}

/* Sidebar Footer (Red Rounded Action Button) */
.sidebar-footer {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
}

.btn-action-primary {
  width: 100%;
  background: var(--red-primary);
  color: #ffffff;
  border: none;
  padding: 11px;
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 10px rgba(227, 6, 19, 0.15);
  transition: all 0.2s ease;
}

.btn-action-primary svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.btn-action-primary:hover {
  background: var(--red-hover);
  box-shadow: 0 6px 20px rgba(227, 6, 19, 0.3);
}
.btn-action-primary:active {
  transform: scale(0.98);
}
.btn-action-primary:disabled {
  opacity: 0.35;
  background: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* ── MAIN WORKSPACE ───────────────────────────────────── */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  height: 100%;
  padding: 24px;
}

/* Rounded Cards */
.viewer-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1; /* Stretch to fill available space */
  min-height: 0; /* Allow card to shrink and scroll internally */
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.viewer-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.viewer-title-row svg {
  width: 18px;
  height: 18px;
  stroke: var(--text-main);
}

.viewer-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Rounded Tabs */
.viewer-tabs {
  display: flex;
  gap: 6px;
}

.vtab {
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  border-radius: 100px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.vtab:hover {
  border-color: var(--text-muted);
  color: var(--text-main);
}

.vtab.active {
  background: var(--red-light);
  border-color: var(--red-primary);
  color: var(--red-primary);
}

/* Empty State */
.empty-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 96px 24px;
  gap: 14px;
  text-align: center;
}

.empty-viewer svg {
  width: 48px;
  height: 48px;
  stroke: var(--text-muted);
  opacity: 0.5;
}

.empty-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.empty-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  max-width: 320px;
}

/* Excel View Table */
.viewer-body {
  overflow: auto;
  flex: 1;
}

.excel-table {
  border-collapse: collapse;
  font-size: 0.8rem;
  width: 100%;
}

.excel-table th, .excel-table td {
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  white-space: nowrap;
  vertical-align: middle;
}

.excel-table thead th {
  background: #f8fafc;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-main);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 2px solid var(--border-color);
}

.excel-table td.row-num, .excel-table th.row-num {
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-align: center;
  min-width: 40px;
  border-right: 2px solid var(--border-color);
  position: sticky;
  left: 0;
  z-index: 1;
}
.excel-table thead th.row-num {
  z-index: 3;
}

/* Cell Colors - Red Accent Highlights */
.xl-header {
  background: #1e293b !important;
  color: #ffffff !important;
  font-weight: 700;
}

.xl-category {
  background: #f1f5f9 !important;
  color: #0f172a !important;
  font-weight: 700;
}

/* Highlight quantity hits in soft red instead of green */
.xl-qty-hit {
  background: var(--red-light) !important;
  font-weight: 700;
  color: var(--red-primary) !important;
  border-left: 3px solid var(--red-primary) !important;
}

/* Selected Lines Summary */
.summary-pills {
  display: flex;
  gap: 8px;
}

.pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--red-primary);
  background: var(--red-light);
  border: 1px solid var(--red-border);
  padding: 4px 12px;
  border-radius: 100px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border-color);
  padding: 12px 18px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-main);
}

.data-table td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: #f8fafc;
}

.data-table td.code {
  font-family: var(--font-sans);
  font-weight: 600;
}

.data-table th.num, .data-table td.num {
  text-align: right;
}

.data-table td.qty {
  font-weight: 700;
  color: var(--red-primary);
}

.data-table tr.row-error td {
  background-color: #fef2f2 !important;
  color: #dc2626 !important;
  font-style: italic;
}
.data-table tr.row-error td.qty {
  color: #dc2626 !important;
}

.data-table tr.row-warning td {
  background-color: #fefce8 !important;
  color: #a16207 !important;
}
.data-table tr.row-warning td.code {
  font-weight: 700;
}

.data-table tr.row-missing td {
  background-color: #f8fafc !important;
  color: #94a3b8 !important;
  text-decoration: line-through;
}

/* Legend */
/* Legend Bar */
.products-legend-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 10px 16px;
  background-color: #f8fafc; /* slightly darker to distinguish from white table */
  border-bottom: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

.table-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.legend {
  display: flex;
  gap: 16px; /* slightly more gap */
  font-size: 0.9rem; /* larger font */
  font-family: var(--font-sans);
  color: var(--text-main);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px; /* more gap between color and text */
}

.legend-color {
  width: 16px; /* larger box */
  height: 16px; /* larger box */
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.15);
}

.legend-color.red { background-color: #fef2f2; }
.legend-color.yellow { background-color: #fefce8; }
.legend-color.grey { background-color: #f8fafc; position: relative; }
.legend-color.grey::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: #94a3b8;
}

/* Spinner & Toasts */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-color);
  border-top-color: var(--red-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  margin-left: 6px;
}

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

.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9999;
  padding: 12px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--r-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.info { border-left: 4px solid var(--text-main); color: var(--text-main); }
.toast.success { border-left: 4px solid #10b981; color: #0f766e; background: #f0fdf4; }
.toast.error { border-left: 4px solid var(--red-primary); color: var(--red-primary); background: var(--red-light); }

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

/* Autocomplete */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-items {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 99;
  max-height: 250px;
  overflow-y: auto;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: none;
}

.autocomplete-items div {
  padding: 10px 14px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.1s ease;
}

.autocomplete-items div:last-child {
  border-bottom: none;
}

.autocomplete-items div:hover {
  background-color: #f1f5f9;
}

.autocomplete-active {
  background-color: #e2e8f0 !important;
}

/* Responsive Layout */
@media (max-width: 1024px) {
  .layout {
    flex-direction: column;
    height: auto;
    margin: 12px auto;
  }
  .sidebar {
    width: 100%;
    height: auto;
    overflow: visible;
  }
  .content {
    height: auto;
  }
}

/* Custom Alert Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: white;
  padding: 32px;
  border-radius: var(--r-lg);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  max-width: 400px;
  width: 90%;
  text-align: center;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fefce8;
  color: #eab308;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.modal-icon svg {
  width: 28px;
  height: 28px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 12px 0;
}

.modal-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 24px 0;
}

.modal-btn {
  background-color: var(--brand);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.modal-btn:hover {
  background-color: #2b4b6f;
  transform: translateY(-1px);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes spin { 100% { transform: rotate(360deg); } }
.loader { display: inline-block; border-radius: 50%; border-style: solid; animation: spin 1s linear infinite; }


.btn-secondary {
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.2s ease;
}
.btn-secondary:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn-secondary:active:not(:disabled) {
  transform: scale(0.98);
}
.btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

