/* ================================================================
   CALCULADORA DE CHURRASCO PMG — Design System CSS
   PriceModel Group | pricemodelgroup.com
   ================================================================ */

/* ================================================================
   1. VARIÁVEIS CSS (Design Tokens)
   ================================================================ */

:root {
  /* Paleta de Cores */
  --color-navy:        #1A2B4A;
  --color-gold:        #C8973A;
  --color-white:       #FFFFFF;
  --color-bg:          #F5F5F5;
  --color-error:       #D32F2F;
  --color-text:        #333333;
  --color-text-light:  #666666;
  --color-border:      #DDDDDD;
  --color-warning-bg:  #FFF8E1;

  /* Espaçamentos */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-xxl: 48px;

  /* Tipografia */
  --font-display: 'Playfair Display', serif;
  --font-body:    'Open Sans', sans-serif;

  /* Bordas */
  --radius-sm: 4px;
  --radius-md: 8px;

  /* Sombras */
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ================================================================
   2. RESET CSS
   ================================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.5;
  min-width: 360px;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

fieldset {
  border: none;
}

ul {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* ================================================================
   3. TIPOGRAFIA
   ================================================================ */

h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.2;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: var(--space-xs);
}

h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: var(--space-sm);
}

legend {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-navy);
  padding-bottom: var(--space-sm);
  width: 100%;
}

label {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-light);
  display: block;
  margin-bottom: var(--space-xs);
}

p {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
}

/* ================================================================
   4. LAYOUT — CONTAINER
   ================================================================ */

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-md);
}

main {
  padding: var(--space-lg) 0 var(--space-xxl);
}

/* ================================================================
   5. HEADER
   ================================================================ */

#app-header {
  position: static;
  background: var(--color-navy);
  color: var(--color-white);
  padding: var(--space-md);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

#app-header img {
  height: 48px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

/* ================================================================
   6. SELEÇÃO DE MODO
   ================================================================ */

#section-mode {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  margin-top: var(--space-lg);
}

.mode-card {
  flex: 1;
  width: 50%;
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-white);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mode-card.active {
  border-color: var(--color-navy);
  background: var(--color-navy);
  color: var(--color-white);
}

.mode-card:hover:not(.active) {
  border-color: var(--color-navy);
  background: rgba(26, 43, 74, 0.05);
}

/* ================================================================
   7. FORMULÁRIO
   ================================================================ */

#section-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

fieldset {
  background: var(--color-white);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
}

/* Grupo de campo (label + input + error) */
.field-group {
  margin-bottom: var(--space-md);
}

.field-group:last-child {
  margin-bottom: 0;
}

/* Campos inline (dentro do row-talher) */
.field-inline {
  margin-bottom: 0;
}

/* ================================================================
   8. CAMPOS DE FORMULÁRIO (inputs, selects)
   ================================================================ */

input[type="text"],
input[type="number"],
select {
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-sm);
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-white);
  width: 100%;
  transition: border-color 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: 2px solid var(--color-navy);
  outline-offset: 2px;
  border-color: var(--color-navy);
}

input.is-invalid,
select.is-invalid {
  border-color: var(--color-error);
}

input.is-invalid:focus,
select.is-invalid:focus {
  outline-color: var(--color-error);
}

/* Mensagens de erro de campo */
.field-error {
  color: var(--color-error);
  font-size: 0.8125rem;
  font-family: var(--font-body);
  display: none;
  margin-top: var(--space-xs);
}

.field-error.visible {
  display: block;
}

/* ================================================================
   9. LINHA ESPECIAL: PRATINHO/TALHER
   ================================================================ */

.talher-row {
  background: rgba(26, 43, 74, 0.03);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.ingredient-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-navy);
  margin-bottom: var(--space-sm);
}

.talher-fields {
  display: flex;
  gap: var(--space-sm);
}

.talher-fields .field-inline {
  flex: 1;
}

/* ================================================================
   10. LINHAS DINÂMICAS (ingredientes e custos)
   ================================================================ */

.ingredient-row,
.cost-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: flex-end;
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

.ingredient-row:last-child,
.cost-row:last-child {
  border-bottom: none;
}

.ingredient-row .field-group,
.cost-row .field-group {
  flex: 1;
  min-width: 80px;
  margin-bottom: 0;
}

.ingredient-row .field-group.field-name,
.cost-row .field-group.field-name {
  flex: 2;
  min-width: 140px;
}

.ingredient-row .row-error,
.cost-row .row-error {
  width: 100%;
  flex-basis: 100%;
}

/* ================================================================
   11. BOTÕES
   ================================================================ */

/* Base comum de botões */
.btn-navy,
.btn-gold,
.btn-secondary,
.btn-remove-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  min-height: 44px;
  padding: var(--space-sm) var(--space-md);
  transition: opacity 0.2s ease, background 0.2s ease;
  text-decoration: none;
  cursor: pointer;
}

/* Botão primário navy (Calcular) */
.btn-navy {
  background: var(--color-navy);
  color: var(--color-white);
  border: 2px solid var(--color-navy);
  width: 100%;
}

.btn-navy:hover:not(:disabled) {
  opacity: 0.88;
}

.btn-navy:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Botão dourado (Gerar PDF) */
.btn-gold {
  background: var(--color-gold);
  color: var(--color-white);
  border: 2px solid var(--color-gold);
  width: 100%;
}

.btn-gold:hover:not(:disabled) {
  opacity: 0.88;
}

.btn-gold:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Botão secundário (Limpar, Adicionar) */
.btn-secondary {
  background: transparent;
  color: var(--color-navy);
  border: 2px solid var(--color-navy);
  width: auto;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(26, 43, 74, 0.05);
}

.btn-secondary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Botão remover linha (×) */
.btn-remove-row {
  background: transparent;
  color: var(--color-error);
  border: 2px solid var(--color-error);
  min-width: 44px;
  padding: var(--space-xs);
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  align-self: flex-end;
}

.btn-remove-row:hover {
  background: rgba(211, 47, 47, 0.06);
}

/* Botão "Adicionar" dentro de fieldset */
fieldset .btn-secondary {
  margin-top: var(--space-md);
}

/* ================================================================
   12. SEÇÃO DE RESULTADOS
   ================================================================ */

#section-results {
  margin-top: var(--space-xl);
}

/* Cards de resultado */
.result-card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.result-card.highlight {
  border-left: 4px solid var(--color-gold);
}

.result-card p {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-top: var(--space-xs);
  font-family: var(--font-display);
}

/* Detalhamento por ingrediente */
#result-ingredients-detail {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

#list-ingredient-costs li {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.9375rem;
  color: var(--color-text);
}

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

/* Tabela de departamentos */
#result-dept-breakdown {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

#result-dept-breakdown table td,
#result-dre table td {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.9375rem;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

#result-dept-breakdown table tr:last-child td,
#result-dre table tr:last-child td {
  border-bottom: none;
}

#result-dept-breakdown table td:last-child,
#result-dre table td:last-child {
  text-align: right;
  font-weight: 600;
  color: var(--color-navy);
}

/* DRE Simplificada */
#result-dre {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

/* Bloco de Venda */
#result-venda-block {
  margin-bottom: var(--space-md);
}

/* ================================================================
   13. AVISOS OBRIGATÓRIOS
   ================================================================ */

#result-warnings {
  background: var(--color-warning-bg);
  border-left: 4px solid var(--color-gold);
  padding: var(--space-md);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-lg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Este bloco NUNCA recebe display:none ou hidden */

#result-warnings p {
  font-size: 0.875rem;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
  line-height: 1.4;
}

#result-warnings p:last-child {
  margin-bottom: 0;
}

.warning-strong {
  font-weight: 700;
  font-family: var(--font-body);
  color: var(--color-navy) !important;
}

/* ================================================================
   14. FOOTER
   ================================================================ */

#app-footer {
  background: var(--color-navy);
  padding: var(--space-md);
  text-align: center;
}

.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
}

#app-footer a {
  color: var(--color-gold);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

#app-footer a:hover {
  opacity: 0.8;
  text-decoration: underline;
}

/* ================================================================
   15. ESTADOS DE VISIBILIDADE (gerenciados pelo app.js)
   ================================================================ */

/* #section-commercialization oculto por padrão (modo Churrasco) */
#section-commercialization {
  display: none;
}

/* #group-pratinhos-pessoa oculto por padrão (modo Churrasco) */
#group-pratinhos-pessoa {
  display: none;
}

/* ================================================================
   16. LAYOUT RESPONSIVO — BREAKPOINT 768px
   ================================================================ */

@media (min-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }

  #section-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
  }

  /* Seções que ocupam a largura total no desktop */
  #section-ingredients,
  #section-event-costs,
  #btn-calculate,
  #btn-clear {
    grid-column: 1 / -1;
  }

  /* Grid de resultados em duas colunas no desktop */
  #section-results .result-card {
    display: inline-block;
    width: 100%;
  }

  /* Botões de ação no desktop: não ocupam 100% da largura */
  .btn-navy,
  .btn-gold {
    width: auto;
    min-width: 200px;
  }

  #btn-calculate,
  #btn-generate-pdf {
    width: 100%;
  }

  .talher-fields {
    gap: var(--space-md);
  }

  .ingredient-row,
  .cost-row {
    flex-wrap: nowrap;
  }
}

/* ================================================================
   17. UTILITÁRIOS
   ================================================================ */

/* Acessibilidade: foco visível */
:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

/* Placeholder */
::placeholder {
  color: var(--color-text-light);
  opacity: 0.7;
}

/* Mensagem de limite de lista */
.list-limit-msg {
  font-size: 0.8125rem;
  color: var(--color-text-light);
  margin-top: var(--space-xs);
  font-style: italic;
}
