body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
  margin-bottom: 5rem;
  font-family: var(--font-body);
}

/* 
  === OVERRIDES DO GLOBAL-STYLE.CSS ===
  O global-style tem regras genéricas de .section e .section > * que
  quebram o layout do memorial. Aqui sobrescrevemos APENAS neste contexto.
*/

/* 1. Remove o padding/gap generoso do .section que cria espaço branco gigante */
.memorial-page-wrapper .section,
body > main .section {
  padding: 0;
  gap: 0;
}

/* 2. Os filhos do .section no global ganham flex: 1 1 20rem (mínimo de 20rem).
      No memorial, queremos que ocupem 100% sem esse mínimo forçado. */
body > main .section > * {
  flex: 1 1 auto;
  max-width: 100%;
}

/* 3. O .card no global tem overflow: hidden que corta o botão de edição circular.
      No contexto dos story-cards, precisamos deixar o overflow visível. */
#story-cards-container .card {
  overflow: visible;
}

/* 4. Hero Banner: O height: 200px do global fica proporcional, mas o margin-bottom: 4rem
      combinado com o espaço do avatar cria muito espaço. Ajustamos aqui. */
.hero-banner {
  height: clamp(140px, 30vw, 260px); /* Mobile menor, desk maior */
  margin-bottom: 3rem; /* Espaço pro avatar que fica em bottom: -3rem */
  border-radius: var(--radius-lg); /* Restaurado: o banner é "flutuante" por design */
}

/* O avatar-overlap do global usa background-image com placeholder.
   No memorial, o conteúdo vem do <img> filho, então limpamos isso. */
.avatar-overlap {
  background-image: none;
  width: auto;
  height: auto;
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

/* 5. O checkin-card dentro do masonry fica com width quebrado pois o
      `column-count` do CSS masonry precisa que o item seja display: block/inline-block.
      O width: 100% aqui garante que ele ocupe a coluna inteira. */
#checkin-card {
  width: 100% !important;
  display: block !important;
  box-sizing: border-box;
}

.memorial-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.img-container {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid oklch(0% 0 0 / 5%);
  box-shadow: var(--shadow-sm);
}

.img-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Contêiner com fundo branco para quando não há foto */
.img-container.default-avatar-container {
  background: var(--bg-surface);
  display: flex;
  justify-content: center;
  align-items: center;
}

#memorial-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* O ícone azul dentro do fundo branco */
#memorial-image.default-avatar {
  width: 60%;
  height: 60%;
  object-fit: contain;
  filter: invert(51%) sepia(80%) saturate(2858%) hue-rotate(180deg) brightness(96%) contrast(91%);
  opacity: 0.9;
}

/* Layout Principal do Header */
.memorial-header-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  gap: 3rem;
  padding: 1rem 0;
}

@media (max-width: 800px) {
  .memorial-header-wrapper {
    flex-direction: column;
    align-items: center;
    gap: 2rem;
  }
}

.profile-main-section {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 2rem;
}

@media (max-width: 600px) {
  .profile-main-section {
    flex-direction: column;
    text-align: center;
  }
}

.main-info {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

#memorial-name {
  margin: 0;
  font-size: 2.2rem;
  color: var(--text-main);
}

.dates-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 500;
  color: #666;
}

/* Área de Família (A ser injetada dentro de um Story Card) */

.family-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: white;
  border: 1px solid #eaeaea;
  padding: 0.5rem 1rem;
  border-radius: 2rem; /* Pill shape */
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.fb-icon {
  font-size: 1.2rem;
}

.fb-info {
  display: flex;
  flex-direction: column;
}

.fb-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

.fb-role {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-section {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
  max-width: 1200px;
  margin: 2rem auto 0;
}

.card-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0; /* Evita quebra de layout com conteúdos longos */
}

/* Garante que os cards ocupem 100% da largura da sua coluna */
.card-column > * {
  width: 100%;
}

@media (max-width: 1000px) {
  /* No tablet, podemos manter as colunas ou ajustar se necessário */
}

@media (max-width: 650px) {
  .card-section {
    flex-direction: column;
  }
}

@media (max-width: 1000px) {
  .card-section {
    column-count: 2;
  }
}

@media (max-width: 650px) {
  .card-section {
    column-count: 1;
  }
}

/* Estilização do Card de Check-in */
.checkin-card {
  background: white;
  border: 1px solid #eaeaea;
  border-radius: 1.2rem;
  padding: 1.2rem;
  width: 320px;
  max-width: 100%;
  box-shadow: 0 4px 15px rgba(0,0,0,0.03);
  text-align: center;
  transition: all 0.3s ease;
}

.checkin-card.active {
  background: #f8ffff;
  border-color: var(--color-primary);
}

.checkin-card p {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1rem;
  line-height: 1.4;
}

/* O btn-checkin é o botão dentro do card estático de check-in.
   Ele usa as classes do global (.btn .btn-primary), mas precisamos garantir
   que ele seja um pouco maior e mais generoso que o padrão .btn-mini */
#btn-checkin {
  padding: 0.65rem 2rem;
  font-size: 0.9rem;
  border-radius: var(--radius-full);
}

.checkin-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.5s ease;
}

.checkin-success span {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-primary);
}

.checkin-success .sub {
  font-size: 0.8rem;
  color: #888;
}

.tribute-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#tribute-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 90vw;
    width: 30rem;


}

#edit-memorial-form {
    display: flex;
    flex-direction: column;
    max-width: 30rem;
    margin: 0 auto;
    gap: 1rem;
}

#edit-memorial-form label {
    font-weight: bold;
    margin-left: 1rem;

}

/* The :has() pseudo-class selects the label only if its immediate next sibling (+) 
   is a required element. This allows us to append a red asterisk via ::after 
   without changing the HTML structure or manually adding classes. */
#tribute-form label:has(+ :required)::after {
    content: " *";
    color: var(--color-primary);
}

#tribute-form input {
    border-radius: var(--radius);
    border: 1px solid oklch(0% 0 0 / 5%);
    background-color: var(--bg-app);
    padding: 1rem 1.5rem;
}
#tribute-form input[type=file] {
    background-color: var(--bg-app);
    padding: 0.5rem;
}

#tribute-form input[type=file]::file-selector-button {
    border-radius: var(--radius);
    border: none;
    background: var(--gradient-blue);
    color: var(--text-on-accent);
    padding: 0.5rem 1rem;
    margin-right: 1rem;
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: bold;
    text-shadow: var(--shadow-sm);
}
#tribute-form textarea {
    border-radius: var(--radius);
    border: 1px solid oklch(0% 0 0 / 5%);
    background-color: var(--bg-app);
    min-height: 5rem;
    padding: 1rem 1.5rem;
}
#tribute-form button {
    border-radius: var(--radius);
    border: 1px solid oklch(0% 0 0 / 5%);
    padding: 1rem 1.5rem;
    width: 100%;
    font-weight: bold;
    color: var(--text-on-accent);
    text-shadow: var(--shadow-sm);
    cursor: pointer;
}

/* button area */

.actionsContainer {
  margin-top: 2rem;
  display: flex;
  flex-direction: row;
  gap: 1rem;
}
.btn {
  border: 1px solid oklch(0% 0 0 / 5%);
  border-radius: var(--radius);
  cursor: pointer;
}
.btn.edit {
  border: solid 1px var(--color-primary);
}
.btn.delete {
  background-color: oklch(65% 0.2 25);
  border: none;
}


.icon {
  width: 1.2rem;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.1));
}
.edit {
  background-color: var(--bg-app);
  filter: invert(50%) sepia(98%) saturate(1834%) hue-rotate(195deg) brightness(101%) contrast(105%);
}
/* .actionsContainer .btn.open {
    background-color:;
} */
.i-open {
  width: 1.3rem;
  filter: brightness(0) invert(1) drop-shadow(var(--shadow-sm));
}
.actionsContainer .btn {
  padding: .7rem 0;
  min-width: 3rem;
  border-radius: 50%;
}

/* ========================================= */
/* INLINE EDITING STYLES (UI POPUPS)         */
/* ========================================= */
.editable-container {
  position: relative;
  display: inline-block;
  transition: background-color 0.2s ease;
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
  /* Margin negativo removido: causava offset visual estranho nos cards */
  /* O overflow precisa ser visível pra mostrar o botão de edição circular
     que fica posicionado fora dos limites do container (top: -8px, right: -20px) */
  overflow: visible !important;
}

/* Remove hover background on the image wrapper so it stays clean */
.image-edit-wrapper.editable-container:hover {
  background-color: transparent;
}

.editable-container:hover {
  background-color: rgba(12, 192, 223, 0.05); /* very light blue hover */
}
.inline-edit-btn {
  position: absolute;
  top: -8px;
  right: -20px;
  background: white;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  z-index: 10;
  pointer-events: none; /* Prevents stray clicks while invisible */
}

/* Edit Mode Visibility Rules */
body.edit-mode-active .inline-edit-btn {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: hover) {
  .editable-container:hover .inline-edit-btn {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1.1);
  }
}

.inline-edit-btn img.blue-icon {
  filter: invert(51%) sepia(80%) saturate(2858%) hue-rotate(180deg) brightness(96%) contrast(91%);
}

.fab-edit-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  border: none;
  box-shadow: 0 4px 15px rgba(12, 192, 223, 0.4);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.image-edit-wrapper .inline-edit-btn {
  top: auto;
  bottom: 5px;
  right: 5px;
  width: 26px;
  height: 26px;
  transform: translate(0, 0); 
}

/* Mobile adjustments */
@media (max-width: 800px) {
  .memorial-page {
    padding: 0 1.5rem; /* Respiro lateral para não colar nas bordas */
  }

  .card-section {
    width: 100%;
    box-sizing: border-box;
    padding: 0 0.5rem;
  }
  .fab-edit-toggle {
    bottom: 7rem; /* Ajuste pra nav mobile */
    right: 1.5rem;
  }
}

.fab-edit-toggle.active {
  background: #2ecc71;
  box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}
.inline-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  animation: fadeIn 0.2s ease;
  margin: 0.5rem 0;
}
.inline-edit-form.row {
  flex-direction: row;
  align-items: center;
}
.inline-edit-input {
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  border: 1px solid var(--color-primary);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  background: white;
  outline: none;
  box-shadow: 0 0 0 2px rgba(12, 192, 223, 0.1);
}
textarea.inline-edit-input {
  min-height: 100px;
  resize: vertical;
}
.inline-edit-actions {
  display: flex;
  gap: 0.5rem;
}
.inline-btn {
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-weight: bold;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.inline-btn.save { color: #2ecc71; background: rgba(46, 204, 113, 0.1); }
.inline-btn.save:hover { background: rgba(46, 204, 113, 0.2); }
.inline-btn.cancel { color: #e74c3c; background: rgba(231, 76, 60, 0.1); }
.inline-btn.cancel:hover { background: rgba(231, 76, 60, 0.2); }

/* ========================================= */
/* CHECK-IN MODAL STYLES                     */
/* ========================================= */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.3s ease;
}

.modal-overlay[style*="display: none"] {
  display: none !important;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  animation: slideUp 0.3s ease;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
  line-height: 1;
}
.close-btn:hover {
  color: #333;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Novo item na Área de Check-ins */
.checkin-badge {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: white;
  border: 1px solid #eaeaea;
  padding: 0.8rem 1.2rem;
  border-radius: 1.2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  /* O .checkin-badge ficava com width limitado herdado do global.
     Aqui forçamos full-width dentro do scroll area do card de homenagens. */
  width: 100%;
  box-sizing: border-box;
}
.cb-icon {
  font-size: 1.2rem;
  margin-top: 0.1rem;
}
.cb-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cb-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}
.cb-date {
  font-size: 0.75rem;
  color: #888;
  letter-spacing: 0.2px;
}
.cb-message {
  font-size: 0.85rem;
  color: #555;
  margin: 0.3rem 0 0 0;
  line-height: 1.4;
  font-style: italic;
  position: relative;
}
.cb-message::before {
  content: '"';
}
.cb-message::after {
  content: '"';
}
