/* --- Geral e Layout --- */
:root {
  /* Cores do Tema Claro */
  --bg-color: #f0f2f5;
  --surface-color: #ffffff;
  --text-color: #1c1e21;
  --text-secondary-color: #606770;
  --border-color: #dddfe2;
  --hover-color: rgba(0, 0, 0, 0.05);
  --primary-color: #1877f2;
  --primary-hover-color: #166fe5;
  --danger-color: #fa383e;
  --danger-hover-color: #e82c31;
  --switch-bg: #ccc;
  --switch-thumb: white;
  --switch-icon: #1c1e21;
}

.dark-mode {
  /* Cores do Tema Escuro */
  --bg-color: #18191a;
  --surface-color: #242526;
  --text-color: #e4e6eb;
  --text-secondary-color: #b0b3b8;
  --border-color: #3a3b3c;
  --hover-color: rgba(255, 255, 255, 0.1);
  --primary-color: #2d88ff;
  --primary-hover-color: #3d91ff;
  --danger-color: #ff4d4d;
  --danger-hover-color: #ff6e6e;
  --switch-bg: #555;
  --switch-thumb: #333;
  --switch-icon: #e4e6eb;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.app-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wrapper {
  width: 100%;
  max-width: 900px;
}

.header,
.main-content {
  width: 100%;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 20px;
}

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

.main-content {
  background-color: var(--surface-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 25px;
  border: 1px solid var(--border-color);
}

.container {
  display: flex;
  gap: 30px;
}

.main {
  flex: 2;
}

.main h2 {
  text-align: center;
  padding: 0 0 10px 0;
}

.sidebar {
  flex: 1;
  border-left: 1px solid var(--border-color);
  padding-left: 20px;
}

/* --- Elementos da UI --- */
button {
  padding: 10px 15px;
  border: none;
  background-color: var(--primary-color);
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

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

.secondary-btn {
  background-color: var(--hover-color);
  color: var(--text-color);
  font-weight: normal;
}

.secondary-btn:hover {
  background-color: var(--border-color);
}

.danger-btn {
  background-color: var(--danger-color);
}

.danger-btn:hover {
  background-color: var(--danger-hover-color);
}

#qr-form {
  display: flex;
  gap: 10px;
  margin-bottom: 5px;
}

.error-message {
  color: var(--danger-color);
  font-size: 0.9em;
  height: 1.2em;
  margin-bottom: 10px;
}


#text-input {
  flex-grow: 1;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-size: 1rem;
}

#qrcode-container {
  width: 256px;
  height: 256px;
  box-sizing: content-box;
  margin: 20px auto;
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: 6px;
  background-color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-placeholder {
  width: 80%;
  height: 80%;
  opacity: 0.5;
  color: var(--border-color);
}

.export-options {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.checkbox-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

#include-footer-checkbox {
  cursor: pointer;
}

.checkbox-wrapper label {
  cursor: pointer;
  font-size: 0.9em;
  color: var(--text-secondary-color);
}

/* --- Histórico e Ações --- */
/* .history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
} */

.history-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#clear-history-btn {
  padding: 4px 8px;
  font-size: 0.8em;
}

#history-list {
  list-style: none;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-secondary-color);
}

#history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  word-break: break-all;
  border-radius: 4px;
  transition: background-color 0.2s;
}

#history-list li:hover {
  background-color: var(--hover-color);
}

#history-list li:last-child {
  border-bottom: none;
}

.history-item-text {
  flex-grow: 1;
  margin-right: 10px;
}

.delete-item-btn {
  background: none;
  border: none;
  color: var(--text-secondary-color);
  cursor: pointer;
  width: 24px;
  height: 24px;
  padding: 2px;
  flex-shrink: 0;
}

.delete-item-btn:hover {
  color: var(--danger-color);
  background-color: var(--hover-color);
}

/* --- Ícone de Informação e Tooltip (CSS Simplificado) --- */
.info-tooltip-container {
  position: relative;
}

.icon-btn {
  background: none;
  border: none;
  padding: 5px;
  width: 34px;
  height: 34px;
  color: var(--text-secondary-color);
}

.icon-btn:hover {
  background-color: var(--hover-color);
}

/* ATUALIZADO: CSS do tooltip simplificado, JS agora controla a posição */
.info-tooltip {
  position: fixed;
  /* Posição fixa na tela */
  background-color: #333;
  color: #fff;
  padding: 10px;
  border-radius: 6px;
  width: 90vw;
  /* Largura baseada na tela */
  max-width: 320px;
  /* Largura máxima */
  text-align: center;
  font-size: 0.9em;
  z-index: 10;
  display: none;
  /* Começa oculto */
  pointer-events: none;
  /* Impede que o mouse interaja com o tooltip */
}

.info-tooltip.visible {
  display: block;
  /* Classe que o JS usará para mostrar */
}


/* --- Modal de Confirmação --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background-color: var(--surface-color);
  padding: 25px;
  border-radius: 8px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}

.modal-content h3 {
  margin-bottom: 10px;
}

.modal-content p {
  margin-bottom: 20px;
  color: var(--text-secondary-color);
}

.modal-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

/* --- Responsividade --- */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
  }

  .controls {
    justify-content: center;
  }

  .main-content {
    padding: 15px;
  }

  .container {
    flex-direction: column;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border-color);
    padding-left: 0;
    padding-top: 20px;
    margin-top: 20px;
  }

  .main h2 {
    text-align: center;
  }

  .history-header {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
}

/* --- Switch de Tema --- */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--switch-bg);
  transition: .4s;
  border-radius: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5px;
}

.slider .icon {
  width: 24px;
  height: 24px;
  transition: opacity 0.4s;
  background-color: var(--switch-icon);
  mask-size: contain;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-repeat: no-repeat;
  mask-position: center;
  -webkit-mask-position: center;
}

.slider .icon.sun {
  opacity: 0;
  mask-image: url(./icons/light_mode.svg);
  -webkit-mask-image: url(./icons/light_mode.svg);
}

.slider .icon.moon {
  opacity: 1;
  mask-image: url(./icons/dark_mode.svg);
  -webkit-mask-image: url(./icons/dark_mode.svg);
}

.slider::before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: var(--switch-thumb);
  transition: .4s;
  border-radius: 50%;
  z-index: 2;
}

input:checked+.slider {
  background-color: var(--primary-color);
}

input:checked+.slider::before {
  transform: translateX(26px);
}

input:checked+.slider .icon.sun {
  opacity: 1;
}

input:checked+.slider .icon.moon {
  opacity: 0;
}

/* --- Rodapé --- */
.footer {
  width: 100%;
  max-width: 900px;
  padding: 20px;
  padding-top: 40px;
  text-align: center;
  color: var(--text-secondary-color);
  font-size: 0.9em;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.footer-icon {
  width: 1.2em;
  height: 1.2em;
  vertical-align: -0.15em;
  margin: 0 0.1em;
  fill: currentColor;
}

.footer a {
  color: var(--text-secondary-color);
  display: inline-flex;
  align-items: center;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--primary-color);
}