/* =========================================================================
   components.css — Botões, cards, formulários, tabelas, tags, estados,
   modais e mensagens. Reutilizados por todas as páginas.
   ========================================================================= */

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 22px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease),
    transform 0.15s var(--ease);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

/* Ação principal em tom neutro (grafite); sobre fundo escuro, cinza claro. */
.btn--primary {
  background: #3a3a3a;
  color: var(--c-white);
}

.btn--primary:hover:not(:disabled) {
  background: #1f1f1f;
}

.hero .btn--primary,
.modal--card .btn--primary,
.pwa-prompt .btn--primary {
  background: #e0e0e0;
  color: var(--c-ink);
}

.hero .btn--primary:hover:not(:disabled),
.modal--card .btn--primary:hover:not(:disabled),
.pwa-prompt .btn--primary:hover:not(:disabled) {
  background: var(--c-white);
}

/* Verde reservado ao card de sócio do nível Caravela. */
.btn--green {
  background: var(--c-green);
  color: var(--c-black);
}

.btn--green:hover:not(:disabled) {
  background: var(--c-green-hover);
}

.btn--yellow {
  background: var(--c-yellow);
  color: var(--c-black);
}

.btn--yellow:hover:not(:disabled) {
  background: var(--c-yellow-hover);
}

.btn--orange {
  background: var(--c-orange);
  color: var(--c-black);
}

.btn--orange:hover:not(:disabled) {
  background: var(--c-orange-hover);
}

/* Texto branco: o roxo do Turista é escuro demais para texto preto. */
.btn--purple {
  background: var(--c-purple);
  color: var(--c-white);
}

.btn--purple:hover:not(:disabled) {
  background: var(--c-purple-hover);
}

.btn--dark {
  background: var(--c-black);
  color: var(--c-white);
}

.btn--dark:hover:not(:disabled) {
  background: #2a2a2a;
}

.btn--outline {
  background: transparent;
  border-color: var(--c-black);
  color: var(--c-black);
}

.btn--outline:hover:not(:disabled) {
  background: var(--c-black);
  color: var(--c-white);
}

.btn--ghost {
  background: transparent;
  color: var(--c-black);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--c-gray-soft);
}

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

.btn--danger:hover:not(:disabled) {
  background: #a82420;
}

.btn--sm {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.75rem;
}

.btn--block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Destaque em texto (ex.: "cadastre-se para participar") */
.highlight-link {
  display: inline-block;
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  background: var(--c-gold);
  color: var(--c-black);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s var(--ease);
}

.highlight-link:hover {
  background: var(--c-gold-hover);
}

/* Sublinhado fino e neutro; escurece no hover. */
.text-link {
  color: var(--c-black);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.3);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s var(--ease);
}

.text-link:hover {
  text-decoration-color: currentColor;
}

/* ---------- Cards ---------- */
.card {
  background: var(--c-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.card--flat {
  box-shadow: none;
  border: 1px solid var(--c-line);
}

.card__title {
  font-size: 1.125rem;
  margin-bottom: 12px;
}

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.grid {
  display: grid;
  gap: 20px;
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

/* Lista de definição (dados de associação, perfil etc.) */
.data-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
}

.data-list dt {
  font-weight: 600;
  color: var(--c-muted);
}

.data-list dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------- Tags ---------- */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag--green {
  background: #d8ffd8;
  color: #005c00;
}

.tag--yellow {
  background: #fff3c4;
  color: #6b5400;
}

.tag--red {
  background: var(--c-red-soft);
  color: #8f1d1a;
}

.tag--gray {
  background: #e6e6e6;
  color: #333;
}

.tag--dark {
  background: var(--c-black);
  color: var(--c-white);
}

/* ---------- Formulários ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-row {
  display: grid;
  gap: 0 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 600;
}

.label .muted {
  font-weight: 500;
}

.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1.5px solid #9a9a9a;
  border-radius: var(--radius-sm);
  background: var(--c-white);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--c-black);
  box-shadow: 0 0 0 3px rgba(0, 255, 0, 0.45);
}

.input[readonly] {
  background: var(--c-gray-soft);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"] {
  border-color: var(--c-red);
}

.field-error {
  margin-top: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--c-red);
}

.hint {
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--c-muted);
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9375rem;
}

.check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--c-black);
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group .input {
  flex: 1;
  min-width: 0;
}

/* Autocomplete (admin de eventos) */
.autocomplete {
  position: relative;
}

.autocomplete__list {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
}

.autocomplete__list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
}

.autocomplete__list li[aria-selected="true"],
.autocomplete__list li:hover {
  background: var(--c-gray-soft);
}

.autocomplete__list img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

/* ---------- Tabelas (viram cartões no mobile) ---------- */
.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th,
.table td {
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #e3e3e3;
}

.table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--c-muted);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: #fafafa;
}

.table .actions {
  white-space: nowrap;
}

@media (max-width: 767px) {
  .table--responsive thead {
    display: none;
  }

  .table--responsive tr {
    display: block;
    padding: 12px 0;
    border-bottom: 1px solid #e3e3e3;
  }

  .table--responsive tbody tr:hover {
    background: none;
  }

  .table--responsive td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .table--responsive td::before {
    content: attr(data-label);
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--c-muted);
    text-align: left;
  }

  .table--responsive td[colspan] {
    display: block;
    text-align: center;
  }

  .table--responsive td[colspan]::before {
    content: none;
  }

  .table--responsive .actions {
    justify-content: flex-end;
    flex-wrap: wrap;
    white-space: normal;
  }

  /* Pagamentos (usuário): no celular, só data, tipo e valor até a pessoa pedir os detalhes. */
  .pay-row:not(.is-open) .pay-row__extra {
    display: none;
  }

  .table--responsive td.pay-row__toggle {
    justify-content: center;
    padding-top: 8px;
  }

  .table--responsive td.pay-row__toggle::before {
    content: none;
  }
}

/* No computador a tabela de pagamentos aparece completa: sem o botão de detalhes. */
@media (min-width: 768px) {
  .pay-row__toggle,
  .pay-row__status-inline {
    display: none;
  }
}

/* ---------- Estados (carregando / vazio / erro) ---------- */
.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--c-muted);
}

.state--loading {
  flex-direction: row;
}

.state--error {
  color: #8f1d1a;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid #cfcfcf;
  border-top-color: var(--c-black);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  border-left: 4px solid;
}

.alert--info {
  background: var(--c-gray-soft);
  border-color: var(--c-black);
}

.alert--warn {
  background: #fff7d6;
  border-color: var(--c-yellow-hover);
}

.alert--error {
  background: var(--c-red-soft);
  border-color: var(--c-red);
}

/* ---------- Navegação das áreas ---------- */
.area-nav {
  margin-bottom: 24px;
  overflow-x: auto;
}

.area-nav ul {
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--c-black);
  border-radius: 10px;
  width: max-content;
  min-width: 100%;
}

.area-nav a {
  display: block;
  padding: 10px 16px;
  border-radius: 7px;
  color: var(--c-white);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.area-nav a:hover {
  background: #262626;
}

.area-nav a[aria-current="page"] {
  background: var(--c-gray-soft);
  color: var(--c-black);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar h2 {
  font-size: 1.25rem;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px var(--gutter);
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.6);
  animation: fade-in 0.2s var(--ease);
}

.modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: auto 0;
  padding: 28px 24px 24px;
  background: var(--c-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  animation: modal-in 0.22s var(--ease);
}

.modal--wide {
  max-width: 760px;
}

.modal--sm {
  max-width: 400px;
}

.modal__title {
  font-size: 1.25rem;
  margin-bottom: 8px;
  padding-right: 32px;
}

.modal__text {
  font-size: 1rem;
  font-weight: 500;
}

.modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--c-gray-soft);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: var(--c-gray);
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* PIX */
.pix {
  margin-top: 16px;
}

.pix__qr {
  width: 220px;
  height: 220px;
  margin: 0 auto 16px;
  image-rendering: pixelated;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
}

.pix__info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0 8px;
}

.pix__info dt {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--c-muted);
}

.pix__info dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* Código de presença */
.presence-code {
  margin: 16px 0;
  padding: 16px;
  text-align: center;
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  background: var(--c-black);
  color: var(--c-white);
  border-radius: var(--radius);
}

/* ---------- Toast ---------- */
.toast-box {
  position: fixed;
  z-index: 60;
  right: 16px;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 420px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--c-black);
  color: var(--c-white);
  font-weight: 600;
  font-size: 0.9375rem;
  border-left: 5px solid var(--c-white);
  box-shadow: var(--shadow-lift);
  pointer-events: auto;
  animation: modal-in 0.2s var(--ease);
  transition: opacity 0.25s var(--ease);
}

.toast--success {
  border-left-color: var(--c-green);
}

.toast--error {
  border-left-color: #ff4d4d;
}

.toast--out {
  opacity: 0;
}

/* ---------- Convite de instalação do app (js/pwa.js) ---------- */
.pwa-prompt {
  position: fixed;
  z-index: 55;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-start;
  gap: 14px;
  max-width: 420px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: var(--c-black);
  color: var(--c-white);
  box-shadow: var(--shadow-lift);
  animation: modal-in 0.2s var(--ease);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
}

.pwa-prompt--out {
  opacity: 0;
  transform: translateY(8px);
}

.pwa-prompt__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

.pwa-prompt__body {
  flex: 1;
  min-width: 0;
}

.pwa-prompt__title {
  font-weight: 800;
  color: var(--c-white);
}

.pwa-prompt__text {
  margin-top: 4px;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.85);
}

.pwa-prompt__text p + p,
.pwa-prompt__text p + ol,
.pwa-prompt__text ol + p {
  margin-top: 6px;
}

.pwa-prompt__tip {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.75);
}

.pwa-prompt__list {
  margin: 4px 0 0;
  padding-left: 18px;
}

.pwa-prompt__share {
  display: inline-flex;
  vertical-align: -2px;
}

.pwa-prompt__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pwa-prompt .btn--ghost {
  color: var(--c-white);
}

.pwa-prompt .btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

.pwa-prompt :focus-visible {
  outline-color: var(--c-white);
}

/* Desktop: canto inferior esquerdo, longe dos toasts (à direita). */
@media (min-width: 768px) {
  .pwa-prompt {
    right: auto;
    margin: 0;
  }
}

/* ---------- Data digitável no celular (js/ui.js) ---------- */
.date-typed {
  position: relative;
  display: flex;
  gap: 8px;
}

.date-typed > .input {
  flex: 1;
  min-width: 0;
}

.date-typed__picker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 46px;
  border: 1px solid var(--c-line);
  border-radius: var(--radius-sm);
  background: var(--c-white);
  color: var(--c-black);
  cursor: pointer;
}

.date-typed__picker:hover {
  background: var(--c-gray-soft);
}
