:root {
  /* Cores */
  --color-bg: #f9fafb;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;

  /* Acentos */
  --color-primary: #1a73e8;
  --color-primary-hover: #1557b0;
  --color-success: #188038;
  --color-danger: #d93025;

  /* Tipografia */
  --font-family: system-ui, sans-serif;
  --font-size-base: 16px;
  --line-height: 1.6;

  /*  Bordas  */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Espaçamento */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.1);

  /* Transições */
  --transition: 0.2s ease;
}

/* =========================================
   Reset e Base
   ========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

/* =========================================
   Componentes Globais
   ========================================= */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition);

  &:hover {
    color: var(--color-primary-hover);
  }
}

button {
  cursor: pointer;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  padding: var(--space-sm) var(--space-md);
  font: inherit;
  transition: background var(--transition);

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

input,
select {
  font: inherit;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  width: 100%;
}

/* =========================================
   Estrutura Principal
   ========================================= */
main {
  width: 100dvw;
  height: 100dvh;
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  align-items: center;
  flex-direction: column;

  h1 {
    text-transform: uppercase;
    padding-inline: var(--space-lg);
    text-align: center;
  }

  /* Formulário */
  form {
    display: flex;
    border: 4px solid var(--color-border);
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-sm);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: var(--space-lg);
    width: 90%;
    max-width: 400px;
    min-height: 50%;
    max-height: auto;
    padding: var(--space-lg);

    /* Grupo de Campos */
    .field-group {
      width: 100%;
      display: flex;
      gap: var(--space-md);
      align-items: start;
      justify-content: center;
      flex-direction: column;
      align-self: center;
      flex: 1;

      .field {
        width: 100%;
        display: flex;
        align-items: start;
        justify-content: center;
        flex-direction: column;
        align-self: center;

        label {
          color: var(--color-text-muted);
        }

        select {
          padding: var(--space-sm);
          border-radius: var(--radius-md);
        }
      }

      #qr-code {
        width: 25%;
      }
    }

    /* Modal (Dialog) */
    dialog[open] {
      margin: auto;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column-reverse;
      border-radius: var(--radius-lg);
      border: 4px solid var(--color-text-muted);
      gap: var(--space-sm);
      padding: var(--space-xs);
      width: 24rem;

      button {
        margin-bottom: 0.5rem;
      }

      ::backdrop {
        background-image: linear-gradient(
          45deg,
          var(--color-surface),
          var(--color-text-muted)
        );
        opacity: 0.75;
      }
    }

    /* Estado do botão */
    button:disabled {
      cursor: not-allowed;
      background-color: var(--color-text-muted);
    }

    /* Área do QR Code */
    #qr-code {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      width: 80%;

      #qr-svg {
        width: 100%;
        height: auto;
        display: block;
        margin: auto;
        max-width: 250px;
        cursor: pointer;
      }

      #pix-copia {
        font-family: monospace;
        cursor: pointer;
        max-width: 100%;
        font-size: calc(var(--font-size-base) / 1.5);
        word-break: break-all;
      }
    }
  }
}
