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

:root {
  --brand-primary: #cd2b39;
  --brand-primary-muted: rgba(205, 43, 57, 0.15);
  --brand-primary-border: rgba(205, 43, 57, 0.3);

  --status-success: #3e7e55;
  --status-success-bg: rgba(62, 126, 85, 0.1);
  --status-info: #4f46e5;
  --status-info-bg: rgba(79, 70, 229, 0.1);
  --status-error: #c62828;
  --status-error-bg: rgba(198, 40, 40, 0.1);
  --status-error-border: rgba(198, 40, 40, 0.3);

  --bg-canvas: #0b0b0b;
  --bg-surface: #141414;
  --bg-surface-raised: #1c1c1c;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-muted: rgba(255, 255, 255, 0.12);

  --text-primary: #e2e2e2;
  --text-secondary: #a3a3a3;
  --text-muted: #666666;

  --font-main: "Epilogue", system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;

  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.5;
  min-height: 100vh;
}

.oculto { display: none !important; }

/* ========== Login (tela cheia centralizada) ========== */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
  min-height: 100vh;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 40px 36px;
  width: 380px;
  max-width: 90vw;
  text-align: center;
}

.login-logo {
  width: 260px;
  max-width: 80%;
  margin-bottom: 32px;
}

.login-card h1 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-card form { text-align: left; }
.login-card form label {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
  margin-top: 16px;
}
.login-card form input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-main);
  outline: none;
}
.login-card form input:focus { border-color: var(--brand-primary); }
.login-card form button {
  width: 100%;
  margin-top: 24px;
  padding: 10px 0;
  background: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-main);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.login-card form button:hover { background: #b8242f; }

.erro {
  background: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 11px;
  color: var(--status-error);
  text-align: center;
}

/* ========== App layout (sidebar + main) ========== */
body.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo { height: 18px; }

.logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.logout:hover { color: var(--text-primary); }

.btn-nova {
  margin: 14px 14px 10px;
  padding: 9px 12px;
  background: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-main);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.btn-nova:hover { background: #b8242f; }

.sidebar-section-title {
  padding: 16px 16px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-top: 1px solid var(--border-subtle);
  margin-top: 4px;
}

.historico-lista {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
}

.historico-vazio {
  padding: 14px 8px;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
}

.historico-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.historico-item:hover {
  background: var(--bg-surface-raised);
  border-color: var(--border-subtle);
}
.historico-item.ativo {
  background: var(--brand-primary-muted);
  border-color: var(--brand-primary-border);
}

.historico-item-processando {
  position: relative;
  animation: pulse-border 1.8s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--brand-primary-border); }
  50% { border-color: var(--brand-primary); }
}

.dot-processando {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-primary);
  margin-right: 6px;
  vertical-align: middle;
  animation: blink 1s infinite;
}

.historico-nome {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.historico-data {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ========== Conteudo principal ========== */
.conteudo {
  padding: 40px;
  overflow-y: auto;
  min-height: 100vh;
}

.tela {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.tela-upload, .tela-resultado, .tela-erro {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 80px);
}
.tela-upload.oculto, .tela-resultado.oculto, .tela-erro.oculto { display: none; }

/* ========== Upload ========== */
.upload-area {
  background: var(--bg-surface);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 56px 80px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  max-width: 500px;
  width: 100%;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-muted);
}
.upload-icon {
  margin-bottom: 16px;
  opacity: 0.6;
}
.upload-area p {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
}
.formatos {
  font-size: 10px !important;
  color: var(--text-muted) !important;
  font-weight: 400 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 12px;
}

/* ========== Processo ========== */
.processo { width: 100%; }

.processo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progresso-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.progresso-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-primary);
  font-variant-numeric: tabular-nums;
}

.processo-acoes {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn-cancelar {
  background: transparent;
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-main);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-cancelar:hover {
  border-color: var(--status-error-border);
  color: var(--status-error);
}
.btn-cancelar:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.progress-bar-track {
  width: 100%;
  height: 3px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.status-line {
  color: var(--text-secondary);
  font-size: 11px;
  margin-bottom: 18px;
  min-height: 16px;
}

.log-box, .preview-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-top: 16px;
}

.log-title, .preview-title {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-raised);
  display: flex;
  align-items: center;
  gap: 8px;
}

.log-content {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-secondary);
  padding: 14px 16px;
  max-height: 280px;
  overflow-y: auto;
  background: #0a0a0a;
}
.log-line {
  white-space: pre-wrap;
  word-break: break-word;
}
.log-time {
  color: var(--text-muted);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.preview-content {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-primary);
  padding: 18px 22px;
  max-height: 420px;
  overflow-y: auto;
}
.preview-line {
  margin-bottom: 8px;
  animation: fadein 0.25s ease;
}
.preview-time {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-canvas);
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
.preview-cursor {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-primary);
  margin-left: 4px;
  animation: blink 1s infinite;
}

@keyframes fadein {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

/* ========== Resultado / Erro ========== */
.resultado-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 40px 36px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}

.sucesso {
  color: var(--status-success);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 22px;
}

.btn-download {
  display: inline-block;
  padding: 10px 28px;
  background: var(--brand-primary);
  border: 1px solid var(--brand-primary-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
}
.btn-download:hover { background: #b8242f; }

.voltar-link { margin-top: 18px; }
.voltar-link a {
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
}
.voltar-link a:hover { color: var(--text-secondary); }

.erro-msg {
  background: var(--status-error-bg);
  border: 1px solid var(--status-error-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 12px;
  color: var(--status-error);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ========== Visualizar histórico ========== */
.tela-visualizar { padding: 0; }

.visualizar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.visualizar-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70%;
}

.visualizar-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}

.btn-link {
  color: var(--text-secondary);
  font-size: 11px;
  text-decoration: none;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-main);
  padding: 4px 0;
}
.btn-link:hover { color: var(--text-primary); }
.btn-link-erro { color: var(--status-error); }
.btn-link-erro:hover { color: #ff5252; }

.visualizar-conteudo {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* ========== Mobile ========== */
@media (max-width: 720px) {
  body.app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    max-height: 220px;
  }
  .conteudo { padding: 20px; }
}
