/* ==========================================================================
   tudoparamd — estilos do conversor (só na página inicial)
   Usa os tokens de cor definidos em site.css.
   ========================================================================== */

/* Cartão que envolve o conversor */
.tool {
  margin-top: 36px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 14px;
}

/* Estado vazio: área de soltar arquivos */
.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 52px 24px 44px;
  border: 2px dashed var(--border-strong); border-radius: 14px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
  display: flex; align-items: center; justify-content: center;
  width: 68px; height: 68px; margin-bottom: 4px;
  border-radius: 18px; background: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-md);
}
.dropzone-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.dropzone-text { color: var(--text-muted); }
.dropzone-hint { color: var(--text-muted); font-size: 14px; }
.format-chips { display: flex; gap: 8px; padding: 0; margin: 8px 0 0; list-style: none; }

.steps {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  padding: 0; margin: 12px 0 0; list-style: none;
}
.step { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; }
.step strong { display: block; font-size: 15px; }
.step span:not(.step-number) { display: block; font-size: 14px; color: var(--text-muted); }
.step-number {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); font-weight: 700; font-size: 14px;
}

/* Área de trabalho: lista à esquerda, resultado à direita */
.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 14px; align-items: start; text-align: left; }
.sidebar { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 80px; }
.panel { background: var(--surface-2); border-radius: 12px; padding: 14px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.panel-title { font-family: var(--font); font-size: 15px; font-weight: 700; letter-spacing: 0; }
.panel-hint { margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.count-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--surface-3); color: var(--text-muted);
  font-size: 12px; font-weight: 700; vertical-align: 1px;
}

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 46vh; overflow-y: auto; }
.file-item { position: relative; display: flex; align-items: center; border-radius: 10px; }
.file-item:hover { background: var(--surface); }
.file-item.is-selected { background: var(--surface); box-shadow: var(--shadow-sm); }
.file-item.is-selected::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent);
}
.file-select {
  position: relative; flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 6px 10px 12px;
  border: 0; border-radius: 10px; background: transparent; text-align: left; cursor: pointer;
}
.file-info { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-size: 14.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-status { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); }
.file-status span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-status svg { flex: none; }
.status-done .file-status svg { color: var(--success); }
.status-error .file-status { color: var(--danger); }
.status-converting .file-status svg { color: var(--accent); animation: spin 1s linear infinite; }
.file-progress { position: absolute; left: 12px; right: 6px; bottom: 3px; height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.file-progress::after {
  content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--progress, 0));
  background: var(--accent); transition: transform .2s;
}
.file-remove { flex: none; margin-right: 4px; opacity: .7; }
.file-item:hover .file-remove, .file-remove:focus-visible { opacity: 1; }

.options summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; border-radius: 4px; }
.options summary::-webkit-details-marker { display: none; }
.options summary::after {
  content: ""; width: 8px; height: 8px; margin-right: 4px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg); transition: transform .15s;
}
.options[open] summary::after { transform: rotate(-135deg); }
.options-group { border: 0; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 8px; cursor: pointer; }
.option:hover { background: var(--surface); }
.option input { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); cursor: pointer; }
.option strong { display: block; font-size: 14.5px; font-weight: 600; }
.option small { display: block; font-size: 13px; color: var(--text-muted); line-height: 1.45; }

.sidebar-actions { display: flex; flex-direction: column; gap: 8px; }
#clear-all { white-space: normal; text-align: center; line-height: 1.3; }
#clear-all.is-armed { color: var(--danger); background: var(--danger-soft); }

/* Painel do resultado */
.preview {
  display: flex; flex-direction: column; min-height: 560px;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface);
}
.preview-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 18px 12px; }
.preview-heading { min-width: 0; flex: 1 1 240px; }
.preview-title { font-family: var(--font); font-size: 17px; font-weight: 700; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.notice { margin: 0 18px 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.notice-warning { background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--text); }
.notice-warning strong { color: var(--warning); display: block; margin-bottom: 4px; }
.notice ul { margin: 0; padding-left: 18px; }
.notice li + li { margin-top: 4px; }

.preview-ready { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.tab {
  position: relative; padding: 10px 14px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: transparent;
  color: var(--text-muted); font-weight: 600; font-size: 14.5px; cursor: pointer; border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { flex: 1; display: flex; min-height: 0; }
.md-editor {
  flex: 1; width: 100%; min-height: 58vh; padding: 20px; border: 0; resize: none;
  background: var(--surface-2); color: var(--text);
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; tab-size: 4;
}
.md-editor:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }

.preview-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 48px 24px; text-align: center;
}
.preview-state-title { font-size: 16px; font-weight: 600; }
.preview-state-text { color: var(--text-muted); max-width: 520px; }
.preview-state-error .state-icon {
  display: flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 50%; background: var(--danger-soft); color: var(--danger);
}
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.progress { width: min(320px, 80%); height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Visualização do Markdown */
.markdown-body { flex: 1; padding: 24px 32px 40px; overflow-wrap: anywhere; max-width: 860px; font-size: 15.5px; line-height: 1.7; }
.markdown-body > :first-child { margin-top: 0; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
  font-family: var(--font); letter-spacing: -0.01em; line-height: 1.3; margin: 1.6em 0 .6em;
}
.markdown-body h1 { font-size: 1.8em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 1.4em; padding-bottom: .25em; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 1.2em; }
.markdown-body p, .markdown-body ul, .markdown-body ol, .markdown-body blockquote, .markdown-body table, .markdown-body pre { margin: 0 0 1em; }
.markdown-body ul, .markdown-body ol { padding-left: 1.6em; }
.markdown-body li + li { margin-top: .25em; }
.markdown-body blockquote { padding: .5em 1em; border-left: 4px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted); border-radius: 0 6px 6px 0; margin-left: 0; }
.markdown-body blockquote > :last-child { margin-bottom: 0; }
.markdown-body code { font-size: .88em; padding: .15em .4em; border-radius: 4px; background: var(--surface-3); }
.markdown-body pre { padding: 14px 16px; border-radius: 8px; background: var(--surface-3); overflow-x: auto; }
.markdown-body pre code { padding: 0; background: none; }
.markdown-body table { display: block; width: max-content; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.markdown-body th, .markdown-body td { padding: 6px 12px; border: 1px solid var(--border); vertical-align: top; }
.markdown-body th { background: var(--surface-2); font-weight: 600; text-align: left; }
.markdown-body img { max-width: 100%; height: auto; border-radius: 4px; }
.markdown-body hr { height: 1px; margin: 2em 0; border: 0; background: var(--border); }

/* Sobreposição ao arrastar arquivos */
.drop-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  backdrop-filter: blur(2px); pointer-events: none;
}
.drop-overlay-box {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 32px 48px; border: 2px dashed var(--accent); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--accent); box-shadow: var(--shadow-lg);
  font-family: var(--font-display); font-size: 20px; font-weight: 700;
}

/* Avisos rápidos (toasts) */
.toast-region {
  position: fixed; z-index: 75;
  right: var(--gutter-r); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 8px 12px 14px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-lg);
  font-size: 14.5px; animation: toast-in .2s ease-out;
}
.toast > svg { flex: none; margin-top: 2px; }
.toast > span { flex: 1; }
.toast-success > svg { color: var(--success); }
.toast-error > svg { color: var(--danger); }
.toast-info > svg { color: var(--accent); }
.toast-close {
  flex: none; width: 26px; height: 26px; margin-top: -3px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.toast-close:hover { background: var(--surface-2); }
.toast-leaving { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; }
  .file-list { max-height: 260px; }
  .preview { min-height: 70vh; }
}
@media (max-width: 640px) {
  .tool { padding: 8px; margin-top: 28px; border-radius: 16px; }
  .dropzone { padding: 34px 16px 30px; }
  .dropzone-title { font-size: 20px; }
  .steps { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .step { padding: 8px 10px; }
  .preview-header { padding: 14px 14px 10px; }
  .preview-actions { width: 100%; }
  .preview-actions .btn { flex: 1; }
  .tabs { padding: 0 10px; }
  .notice { margin: 0 14px 12px; }
  .md-editor { padding: 16px; font-size: 13px; min-height: 55vh; }
  .markdown-body { padding: 18px 16px 32px; }
  .toast-region { left: var(--gutter-l); max-width: none; }
}
