/* =====================================================
   OPERADOR - Componentes específicos
   ===================================================== */

/* ----- Header ----- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 22, 35, 0.85);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--divider);
}
.app-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  height: 56px;
  padding: 0 var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-mark {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px var(--border-default), 0 4px 12px rgba(0,0,0,0.3);
}
.brand-icon i { color: var(--accent); font-size: 14px; }
.brand-text-name { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; line-height: 1.1; }
.brand-text-sub { font-size: 11px; color: var(--text-quaternary); line-height: 1; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-tertiary);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-in-out);
  font-size: 13px;
}
.icon-btn:hover { background: rgba(255,255,255,0.04); color: var(--text-primary); border-color: var(--border-default); }
.icon-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: rgba(239,68,68,0.25); }

/* ----- Page container ----- */
.page-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--s-6) var(--s-5) var(--s-12);
}

/* ----- Section header (título de seção dentro de tab) ----- */
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.section-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-weight: 400;
}

/* ----- Field (label + input) ----- */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}
.field-help { font-size: 12px; color: var(--text-quaternary); margin-top: var(--s-1); }

/* ----- Select cards (escolha de tipo de documento) ----- */
.select-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-2);
}
@media (min-width: 480px) {
  .select-grid { grid-template-columns: repeat(2, 1fr); }
}
.select-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-input);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-in-out);
  text-align: left;
  min-height: 60px;
}
.select-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-default);
  transform: translateY(-1px);
}
.select-card.is-active,
.select-card.selected {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.select-card-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-in-out);
}
.select-card.is-active .select-card-icon,
.select-card.selected .select-card-icon {
  background: var(--accent);
  color: var(--text-on-accent);
}
.select-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.select-card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  line-height: 1.2;
}
.select-card-desc {
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.3;
}
.select-card.is-active .select-card-label,
.select-card.selected .select-card-label { color: var(--accent); }
.select-card.is-active .select-card-desc,
.select-card.selected .select-card-desc { color: var(--accent-light); }

/* ----- Method cards (Camera/PDF/Manual no Step 2) ----- */
.method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-3);
}
.method-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-3);
  background: var(--bg-input);
  border: 1px solid var(--divider);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-in-out);
  text-align: center;
}
.method-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-default);
  transform: translateY(-1px);
}
.method-card.selected {
  background: var(--accent-soft);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.method-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--r-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  font-size: 18px;
  color: var(--text-tertiary);
  transition: all var(--dur-fast) var(--ease-in-out);
}
.method-card.selected .method-card-icon {
  background: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 4px 12px -2px rgba(212, 165, 48, 0.4);
}
.method-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.method-card-sub {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
}
.method-card.selected .method-card-title { color: var(--accent); }
.method-card.selected .method-card-sub { color: var(--accent-light); }

/* ----- Dropzone ----- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border-default);
  border-radius: var(--r-lg);
  padding: var(--s-10) var(--s-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--dur-base) var(--ease-in-out);
  background: rgba(255, 255, 255, 0.015);
}
.dropzone:hover {
  border-color: var(--border-strong);
  background: var(--accent-soft);
}
.dropzone.is-dragging {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}
.dropzone-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--s-3);
}
.dropzone-icon i { font-size: 22px; color: var(--accent); }
.dropzone-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: var(--s-1); }
.dropzone-help { font-size: 13px; color: var(--text-tertiary); }

/* ----- Queue items (fila de processamento) ----- */
.queue-list { display: flex; flex-direction: column; gap: var(--s-2); }
.queue-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  transition: all var(--dur-fast) var(--ease-in-out);
}
.queue-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent);
}
.queue-item-info { flex: 1; min-width: 0; }
.queue-item-name { font-size: 13px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item-status { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.queue-item-actions { display: flex; gap: var(--s-1); }
.queue-item-btn {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  transition: all var(--dur-fast);
}
.queue-item-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.queue-item-btn.is-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* Status indicators na queue */
.queue-item.is-processing .queue-item-icon { background: var(--info-soft); color: var(--info); }
.queue-item.is-success .queue-item-icon { background: var(--success-soft); color: var(--success); }
.queue-item.is-error .queue-item-icon { background: var(--danger-soft); color: var(--danger); }
.queue-item.is-duplicate .queue-item-icon { background: var(--info-soft); color: var(--info); }

/* Progress bar dentro de queue item */
.queue-progress {
  height: 3px;
  background: var(--divider);
  border-radius: var(--r-full);
  margin-top: var(--s-2);
  overflow: hidden;
}
.queue-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--info), var(--accent));
  border-radius: var(--r-full);
  transition: width var(--dur-base);
}

/* ----- Progress bar global ----- */
.progress-track {
  width: 100%;
  height: 6px;
  background: var(--divider);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent));
  border-radius: var(--r-full);
  transition: width var(--dur-base);
}

/* ----- PDF preview ----- */
.pdf-preview-container {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: var(--s-3);
  overflow: hidden;
}
.pdf-preview-canvas { max-width: 100%; border-radius: var(--r-sm); }
.page-thumb {
  width: 70px;
  height: 90px;
  object-fit: cover;
  border: 1.5px solid var(--divider);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--dur-fast);
}
.page-thumb:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.thumb-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px; height: 20px;
  background: var(--danger);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
  color: white;
  border: 2px solid var(--bg-base);
}

/* ----- Camera ----- */
.camera-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
}
.camera-guide {
  position: absolute;
  top: 5%; left: 3%; right: 3%; bottom: 5%;
  border: 2px dashed rgba(255,255,255,0.4);
  border-radius: var(--r-sm);
  pointer-events: none;
}
.btn-camera {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

/* ----- Loading overlay ----- */
.load-step {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  font-size: 13px;
  color: var(--text-quaternary);
  transition: all var(--dur-base);
}
.load-step.is-active { color: var(--text-primary); font-weight: 600; }
.load-step.is-done { color: var(--text-tertiary); }

/* ----- Content preview (dados extraídos) ----- */
.content-preview {
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-input);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border-subtle);
  word-break: break-word;
  overflow-wrap: break-word;
}
.content-preview p { margin: 0 0 var(--s-3); line-height: 1.6; font-size: 13px; }
.content-preview p:last-child { margin-bottom: 0; }

/* ----- History card ----- */
.history-card {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  transition: all var(--dur-fast);
}
.history-card:hover { background: var(--bg-card-hover); border-color: var(--border-default); }

/* ----- Skeleton ----- */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

/* ----- Toast ----- */
.toast-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: slideUp var(--dur-base) var(--ease-out);
  font-size: 13px;
  font-weight: 500;
  max-width: 90vw;
}

/* ----- Step panel ----- */
.step-panel { transition: opacity var(--dur-base), transform var(--dur-base); }

/* ----- Login refinado ----- */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-brand {
  text-align: center;
  margin-bottom: var(--s-8);
}
.login-brand-mark {
  width: 64px;
  height: 64px;
  border-radius: var(--r-xl);
  margin: 0 auto var(--s-4);
  background: linear-gradient(145deg, var(--primary), var(--primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px var(--border-default), 0 16px 32px -8px rgba(0,0,0,0.5);
}
.login-brand-mark i { color: var(--accent); font-size: 26px; }
.login-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; margin-bottom: var(--s-1); }
.login-subtitle { font-size: 13px; color: var(--text-tertiary); }

/* Input com ícone */
.input-with-icon { position: relative; }
.input-with-icon i {
  position: absolute;
  left: var(--s-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-quaternary);
  font-size: 13px;
  pointer-events: none;
}
.input-with-icon .input { padding-left: var(--s-10); }

/* ----- Resumo (lote) - lista colapsável ----- */
.summary-panel {
  margin-top: var(--s-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-card);
}
.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-4);
  cursor: pointer;
  transition: background var(--dur-fast);
}
.summary-head:hover { background: var(--bg-card-hover); }
.summary-head-title { font-size: 13px; font-weight: 600; color: var(--text-primary); display: flex; align-items: center; gap: var(--s-2); }
.summary-body { max-height: 280px; overflow-y: auto; }

/* ----- Responsive helpers ----- */
@media (max-width: 640px) {
  .page-container { padding: var(--s-4) var(--s-4) var(--s-10); }
  .section-title { font-size: 19px; }
  .stat-card-value { font-size: 24px; }
  .step-label { display: none; }
  .step { padding: var(--s-2); }
  .step-line { width: 24px; }
}
