/**
 * PlacaSP
 */

/* ==========================================================================
   DESIGN TOKENS
   ========================================================================== */

:root {
  /* Cores */
  --color-primary: #CC0000;
  --color-text: #000000;
  --color-bg: #FFFFFF;
  --color-button: #302E91;
  --color-button-text: #FFFFFF;
  --color-border: #DDDDDD;
  --color-error-bg: #FFF5F5;
  --color-error-border: #E53E3E;

  /* Tipografia */
  --font-family-base: Verdana, Arial, Helvetica, sans-serif;
  --font-size-base: 0.625rem; /* 10px */
  --font-size-sm: 0.75rem;    /* 12px */
  --font-size-md: 0.8125rem;  /* 13px */
  --font-size-lg: 1rem;       /* 16px */
  --font-size-xl: 1.125rem;   /* 18px */

  /* Espaçamento */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 2.5rem;

  /* Layout */
  --max-width: 75rem;
  --sidebar-width: 22.5rem; /* 360px */
  --gutter: clamp(1rem, 3vw, 2.5rem);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  font-size: 100%; /* 16px base */
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: url(placaspbg.jpg);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: top left;
}

/* ==========================================================================
   TIPOGRAFIA
   ========================================================================== */

a {
  color: var(--color-text);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover,
a:focus {
  color: var(--color-primary);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.titulo {
  font-size: var(--font-size-md);
  color: var(--color-primary);
  font-weight: bold;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-sm);
}

/* Acessibilidade: esconde visualmente mas mantém para leitores de tela */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   LAYOUT GRID - MOBILE FIRST
   ========================================================================== */

/* Mobile: layout vertical (sidebar embaixo) */
body {
  display: grid;
  grid-template-areas:
    "main"
    "sidebar";
  grid-template-columns: 1fr;
  gap: var(--space-md);
  padding: var(--gutter);
  min-height: 100vh;
}

/* Tablet: sidebar à esquerda, largura fixa */
@media (min-width: 48em) {
  body {
    grid-template-areas: "sidebar main";
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: var(--space-lg);
    padding: var(--space-lg) var(--gutter);
  }
}

/* Desktop: aumenta espaçamento */
@media (min-width: 64em) {
  body {
    gap: var(--space-xl);
    padding: var(--space-xl) var(--gutter);
  }
}

/* ==========================================================================
   SIDEBAR (ex-.fixas)
   ========================================================================== */

.fixas,
.fixaexibe {
  grid-area: sidebar;
  font-size: var(--font-size-base);
  padding: var(--space-md);
  background-color: #FFF;
  border-radius: 0.5rem;
}

/* Em mobile, sidebar fica embaixo com altura automática */
@media (max-width: 47.9375em) {
  .fixas,
  .fixaexibe {
    order: 2;
  }
}

/* Em desktop, sidebar alinhada ao pé da página */
@media (min-width: 48em) {
  .fixas {
    align-self: end;
  }

  .fixaexibe {
    align-self: end;
  }
}

.fixas p,
.fixaexibe p {
  margin: 0 0 var(--space-sm) 0;
}

.fixas img,
.fixaexibe img {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */

.abertura,
.aberturaexibe {
  grid-area: main;
  font-size: var(--font-size-base);
  max-width: 50rem;
  background-color: rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   SEÇÕES
   ========================================================================== */

section {
  margin-bottom: var(--space-lg);
}

.center {
  text-align: center;
}

.center img {
  max-width: 100%;
  height: auto;
  display: inline-block;
}

/* ==========================================================================
   ANÚNCIOS
   ========================================================================== */

.ads-top,
.ads-middle,
.ads-bottom,
.ads-resultado {
  text-align: center;
  margin: var(--space-lg) 0;
  padding: var(--space-sm);
  background-color: rgba(240, 240, 240, 0.5);
  border-radius: 0.25rem;
}

/* ==========================================================================
   FORMULÁRIO
   ========================================================================== */

.form-placa {
  margin-top: var(--space-md);
}

fieldset {
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

legend {
  font-weight: bold;
  font-size: var(--font-size-md);
  padding: 0 var(--space-xs);
  color: var(--color-primary);
}

/* Radio buttons com labels clicáveis */
.radio-label {
  display: block;
  margin-bottom: var(--space-xs);
  cursor: pointer;
  user-select: none;
}

.radio-label:hover {
  color: var(--color-primary);
}

.radio-label input[type="radio"] {
  margin-right: var(--space-xs);
  cursor: pointer;
}

/* Form groups */
.form-group {
  margin-bottom: var(--space-md);
  position: relative;
}

.form-group label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: bold;
  font-size: var(--font-size-base);
}

.help-text {
  display: block;
  font-weight: normal;
  font-size: var(--font-size-sm);
  color: #666;
  margin-top: 0.25rem;
}

/* Inputs */
input[type="text"] {
  width: 50%;
  max-width: 25rem;
  padding: 0.5rem;
  font-size: var(--font-size-base);
  font-family: var(--font-family-base);
  border: 1px solid var(--color-border);
  border-radius: 0.25rem;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(204, 0, 0, 0.1);
}

input[type="text"]:invalid {
  border-color: var(--color-error-border);
}

/* Imagem exemplo flutuante */
.exemplo-img {
  display: block;
  margin-top: var(--space-sm);
  max-width: 100%;
  height: auto;
}

@media (min-width: 48em) {
  .exemplo-img {
    float: right;
    margin: 0 0 var(--space-sm) var(--space-sm);
    max-width: 15rem;
  }
}

/* Cores de regiões flutuante */
.cores-img {
  display: block;
  margin: 0 auto var(--space-sm);
  max-width: 100%;
  height: auto;
}

@media (min-width: 48em) {
  .cores-img {
    float: right;
    margin: 0 0 var(--space-sm) var(--space-sm);
  }
}

/* Botão */
.botao,
button[type="submit"] {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: var(--font-size-base);
  font-weight: bold;
  font-family: var(--font-family-base);
  color: var(--color-button-text);
  background-color: var(--color-button);
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
}

.botao:hover,
.botao:focus,
button[type="submit"]:hover,
button[type="submit"]:focus {
  background-color: #3E3BA8;
  color: var(--color-button-text);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.botao:active,
button[type="submit"]:active {
  transform: translateY(0);
}

.botao:focus-visible,
button[type="submit"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ==========================================================================
   PÁGINA DE RESULTADO
   ========================================================================== */

.resultado {
  text-align: center;
}

.resultado h1 {
  font-size: var(--font-size-xl);
  color: var(--color-primary);
  margin-bottom: var(--space-lg);
}

.placa-container {
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: inline-block;
}

.placa-gerada {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 0.25rem;
}

.instrucoes {
  margin: var(--space-lg) 0;
  font-size: var(--font-size-base);
  line-height: 1.8;
}

/* ==========================================================================
   MENSAGENS DE ERRO
   ========================================================================== */

.erros {
  background-color: var(--color-error-bg);
  border: 2px solid var(--color-error-border);
  border-radius: 0.5rem;
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.erros h3 {
  margin-top: 0;
  color: var(--color-error-border);
  font-size: var(--font-size-md);
}

.erros ul {
  margin: var(--space-sm) 0 0 0;
  padding-left: var(--space-md);
}

.erros li {
  margin-bottom: var(--space-xs);
  font-size: var(--font-size-base);
}

/* ==========================================================================
   RESPONSIVIDADE - AJUSTES FINOS
   ========================================================================== */

/* Mobile pequeno */
@media (max-width: 30em) {
  :root {
    --font-size-base: 0.875rem; /* 14px em mobile */
  }

  .ads-top,
  .ads-middle,
  .ads-bottom,
  .ads-resultado {
    overflow-x: auto;
  }
}

/* Tablet */
@media (min-width: 48em) and (max-width: 63.9375em) {
  .abertura,
  .aberturaexibe {
    font-size: var(--font-size-sm);
  }
}

/* Desktop grande */
@media (min-width: 80em) {
  :root {
    --font-size-base: 0.75rem; /* Volta para 12px em telas grandes */
  }

  body {
    max-width: var(--max-width);
    margin: 0 auto;
  }
}

/* ==========================================================================
   PRINT
   ========================================================================== */

@media print {
  body {
    background-image: none;
    display: block;
  }

  .fixas,
  .fixaexibe,
  .ads-top,
  .ads-middle,
  .ads-bottom,
  .ads-resultado {
    display: none;
  }

  .abertura,
  .aberturaexibe {
    margin: 0;
  }
}

/* ==========================================================================
   ACESSIBILIDADE - MOTION
   ========================================================================== */

/* Respeita preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   DARK MODE (opcional, mas moderno)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root {
    --color-text: #E0E0E0;
    --color-bg: #1A1A1A;
    --color-border: #444444;
    --color-error-bg: #3A1F1F;
  }

  body {
    background-image: none;
  }

  .fixas,
  .fixaexibe {
    background-color: transparent;
  }

  .placa-container {
    background-color: rgba(40, 40, 40, 0.95);
  }

  input[type="text"] {
    background-color: #2A2A2A;
    color: var(--color-text);
    border-color: var(--color-border);
  }

  fieldset {
    border-color: var(--color-border);
  }
}
