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

/* garante que o atributo hidden sempre vença regras de display */
[hidden] {
  display: none !important;
}

/* ============================================================
   Temas de cores — o tema ativo é definido pelo atributo
   data-theme no <html> (gerenciado pelo themeService.js).
   Padrão: paleta oficial Drogaria Retiro (extraída do site).
   ============================================================ */

:root,
:root[data-theme="retiro"] {
  --primary: #007845;
  --primary-dark: #005a34;
  --bg: #f4faf7;
  --surface: #ffffff;
  --text: #12291c;
  --muted: #5c7268;
  --border: #d2eadc;
  --success: #00a441;
  --error: #e20613;
  --topbar-bg: linear-gradient(135deg, #39ab56, #007845);
  --topbar-text: #ffffff;
}

:root[data-theme="roxo"] {
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --bg: #f5f3ff;
  --surface: #ffffff;
  --text: #1e1b2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #16a34a;
  --error: #dc2626;
  --topbar-bg: linear-gradient(135deg, #7c3aed, #5b21b6);
  --topbar-text: #ffffff;
}

:root[data-theme="azul"] {
  --primary: #006dd1;
  --primary-dark: #0053a3;
  --bg: #f0f7ff;
  --surface: #ffffff;
  --text: #10233a;
  --muted: #5b7189;
  --border: #d6e6f7;
  --success: #16a34a;
  --error: #dc2626;
  --topbar-bg: linear-gradient(135deg, #2f8fe0, #0053a3);
  --topbar-text: #ffffff;
}

:root[data-theme="escuro"] {
  --primary: #39ab56;
  --primary-dark: #2c8a44;
  --bg: #101613;
  --surface: #1a231e;
  --text: #e6efe9;
  --muted: #93a89b;
  --border: #2c3a32;
  --success: #4ade80;
  --error: #f87171;
  --topbar-bg: linear-gradient(135deg, #123a26, #0b241a);
  --topbar-text: #e6efe9;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s, color 0.25s;
}

/* ---------- Cabeçalho ---------- */

.topbar {
  background: var(--topbar-bg);
  color: var(--topbar-text);
  padding: 1.4rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  height: 52px;
  background: #ffffff;
  border-radius: 10px;
  padding: 6px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.brand-text h1 {
  font-size: 1.6rem;
  line-height: 1.2;
}

.brand-text p {
  opacity: 0.85;
  margin-top: 0.15rem;
}

.theme-picker {
  display: flex;
  gap: 0.5rem;
}

.theme-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.theme-dot:hover {
  transform: scale(1.15);
}

.theme-dot.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.45);
}

/* ---------- Layout com barra lateral ---------- */

.layout {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  width: min(1100px, 96vw);
  margin: 1.5rem auto;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
  background: var(--surface);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.side-nav a:hover {
  background: var(--bg);
}

.side-nav a.active {
  background: var(--primary);
  color: #fff;
}

.side-note {
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
}

main {
  flex: 1;
  min-width: 0;
}

.route-hint {
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ---------- Grade de ferramentas ---------- */

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1rem;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.tool-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tool-icon {
  font-size: 1.7rem;
}

.tool-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.tool-card h3 {
  font-size: 1rem;
}

.tool-card p {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- Painel da ferramenta ---------- */

.tool-panel .back {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 0.8rem;
}

.tool-panel .back:hover {
  text-decoration: underline;
}

#tool-title {
  margin-bottom: 0.3rem;
}

.tool-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.dropzone {
  background: var(--surface);
  border: 2px dashed var(--primary);
  border-radius: 16px;
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.dropzone.dragover {
  background: var(--bg);
  transform: scale(1.01);
}

.dz-icon {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.dz-file {
  margin-top: 0.8rem;
  font-weight: 600;
  color: var(--primary);
}

button.link {
  background: none;
  border: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

.convert-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1rem;
  background: var(--surface);
  padding: 1rem;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

select {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--text);
}

button.primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.6rem 1.6rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

button.primary:hover {
  background: var(--primary-dark);
}

button.primary:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ---------- Jobs ---------- */

.jobs-title {
  margin-top: 1.5rem;
  font-size: 1.1rem;
}

.jobs {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.job-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.job-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-status {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.job-status.done { color: var(--success); }
.job-status.error { color: var(--error); }

.progress-track {
  background: var(--border);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  background: var(--primary);
  height: 100%;
  width: 0;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.job-card.done .progress-fill { background: var(--success); }
.job-card.error .progress-fill { background: var(--error); }

.job-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

a.download {
  display: inline-block;
  margin-top: 0.6rem;
  background: var(--success);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  padding: 0.45rem 1.1rem;
  border-radius: 8px;
}

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.2rem;
}

/* ---------- Responsivo ---------- */

@media (max-width: 720px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    position: static;
  }

  .side-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .side-nav a {
    padding: 0.45rem 0.7rem;
  }

  .side-note {
    border-top: none;
    padding-top: 0;
  }
}
