/* galeria.css — estilos da página de fotos dos convidados
   Depende dos tokens CSS de style.css (:root variables)             */

/* ── Reset de página ───────────────────────────────────────────────── */

.galeria-page {
  background: var(--linen-50);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ────────────────────────────────────────────────────────── */

.galeria-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px min(4%, 24px);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--sand-100);
}

.galeria-back {
  font-size: 0.9rem;
  color: var(--text-700);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.galeria-back:hover {
  background: var(--linen-100);
}

.galeria-brand {
  font-size: 1.35rem;
  color: #ab690c;
  text-align: center;
}

.galeria-header-spacer {
  /* balances the back button so brand stays centered */
  width: 72px;
}

/* ── Hero strip ─────────────────────────────────────────────────────── */

.galeria-hero {
  background: var(--sand-100);
  text-align: center;
  padding: 44px 20px 36px;
  border-bottom-left-radius: var(--radius-xxl);
  border-bottom-right-radius: var(--radius-xxl);
}

.galeria-title {
  font-size: clamp(2.6rem, 7vw, 5rem);
  color: #ab690c;
  margin: 0 0 10px;
  line-height: 1;
}

.galeria-subtitle {
  color: var(--text-700);
  font-size: 1.05rem;
  margin: 0;
}

/* ── Tab bar ────────────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  max-width: 480px;
  margin: 28px auto 0;
  background: var(--sand-100);
  border-radius: 999px;
  padding: 4px;
}

.tab-btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 12px 20px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: var(--text-700);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tab-btn.active {
  background: var(--linen-50);
  color: var(--text-900);
  box-shadow: var(--shadow);
}

.tab-btn:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 2px;
}

/* ── Tab panels ─────────────────────────────────────────────────────── */

.tab-panel {
  max-width: 680px;
  margin: 28px auto 64px;
  padding: 0 16px;
}

/* A galeria ganha mais espaço que o formulário para o masonry respirar */
#panel-gallery {
  max-width: 1100px;
}

/* ── Upload card ────────────────────────────────────────────────────── */

.upload-card {
  background: var(--linen-100);
  border-radius: var(--radius-xl);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ── Drop zone ──────────────────────────────────────────────────────── */

.drop-zone {
  border: 2px dashed var(--sand-300);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: var(--linen-50);
  user-select: none;
}

.drop-zone.hidden {
  display: none;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--aqua);
  background: color-mix(in oklab, var(--aqua), transparent 88%);
}

.drop-zone:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 3px;
}

.drop-zone-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 10px;
}

.drop-zone-text {
  font-weight: 600;
  color: var(--text-900);
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.drop-zone-hint {
  font-size: 0.9rem;
  color: var(--text-700);
  margin: 0 0 18px;
}

.drop-zone-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.drop-zone-actions .btn {
  font-size: 0.98rem;
}

.drop-zone-formats {
  font-size: 0.78rem;
  color: var(--text-500);
  margin: 0;
}

/* ── Preview ────────────────────────────────────────────────────────── */

.preview-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.preview-wrap.hidden {
  display: none;
}

.preview-img {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  display: block;
  border-radius: var(--radius-lg);
}

.preview-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 6px 12px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
}

/* ── Campos de metadados ────────────────────────────────────────────── */

.upload-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-optional {
  font-weight: 400;
  color: var(--text-500);
  font-size: 0.85em;
}

/* ── Barra de progresso ─────────────────────────────────────────────── */

.progress-wrap {
  background: var(--sand-100);
  border-radius: 999px;
  height: 10px;
  overflow: visible;
  position: relative;
}

.progress-wrap.hidden {
  display: none;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--aqua);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.progress-label {
  position: absolute;
  right: 0;
  top: -20px;
  font-size: 0.75rem;
  color: var(--text-500);
}

/* ── Status e botão ─────────────────────────────────────────────────── */

.upload-status {
  font-size: 0.9rem;
  color: var(--text-700);
  margin: 0;
  min-height: 1.3em;
  text-align: center;
}

.upload-status.error   { color: #c0392b; }
.upload-status.success { color: #27ae60; font-weight: 600; }

.upload-btn {
  align-self: stretch;
}

.upload-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Toolbar da galeria ─────────────────────────────────────────────── */

.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.gallery-count {
  font-size: 0.9rem;
  color: var(--text-500);
}

.realtime-dot {
  width: 8px;
  height: 8px;
  background: #27ae60;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse-dot 2.4s ease-in-out infinite;
}

.realtime-dot.flash {
  animation: flash-dot 0.6s ease-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1;    transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.85); }
}

@keyframes flash-dot {
  0%   { opacity: 1; transform: scale(1.6); background: var(--aqua); }
  100% { opacity: 1; transform: scale(1);   background: #27ae60; }
}

/* ── Grade de fotos — masonry orgânico (colunas) ────────────────────── */
/* Usa CSS columns: cada foto mantém seu formato natural (retrato,
   paisagem, quadrada) e as colunas se encaixam de forma orgânica.
   As mais recentes entram no topo da primeira coluna.                  */

.photo-grid {
  column-count: 2;
  column-gap: 12px;
}

@media (min-width: 560px) {
  .photo-grid { column-count: 3; }
}

@media (min-width: 900px) {
  .photo-grid { column-count: 4; }
}

/* ── Itens da grade ─────────────────────────────────────────────────── */

.photo-item {
  break-inside: avoid; /* não quebra o card entre colunas */
  margin: 0 0 12px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: var(--sand-100);
  position: relative;
  outline-offset: 3px;
}

.photo-item:focus-visible {
  outline: 3px solid var(--aqua);
}

.photo-item img {
  width: 100%;
  height: auto; /* preserva a proporção real da foto — sem cortar */
  display: block;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.4s ease, filter 0.4s ease;
}

.photo-item img.loaded {
  opacity: 1;
}

.photo-item:hover img,
.photo-item:focus-within img {
  transform: scale(1.05);
  filter: brightness(0.9);
}

.photo-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 55%, rgba(0, 0, 0, 0.52));
  opacity: 0;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-end;
  padding: 8px;
  pointer-events: none;
}

.photo-item:hover .photo-item-overlay,
.photo-item:focus-within .photo-item-overlay {
  opacity: 1;
}

.photo-item-name {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}

/* Foto nova animada (chegou via realtime) */
.photo-new {
  animation: pop-in 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.82); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Curtidas ───────────────────────────────────────────────────────── */

.photo-like {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  color: var(--text-700);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
  transition: transform 0.15s ease, background 0.2s ease;
}

.photo-like:hover { transform: scale(1.06); }

.photo-like:focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 2px;
}

.photo-like-heart {
  font-size: 0.95rem;
  line-height: 1;
  color: #d6455a;
  opacity: 0.5;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.photo-like.is-liked {
  color: #d6455a;
}

.photo-like.is-liked .photo-like-heart {
  opacity: 1;
}

.photo-like.bump .photo-like-heart {
  animation: heart-bump 0.42s ease;
}

@keyframes heart-bump {
  0%, 100% { transform: scale(1); }
  35%      { transform: scale(1.45); }
}

/* ── Skeletons ──────────────────────────────────────────────────────── */

.photo-skeleton {
  break-inside: avoid;
  margin: 0 0 12px;
  height: 200px;
  border-radius: var(--radius-lg);
  background: linear-gradient(
    90deg,
    var(--sand-100) 0%,
    var(--sand-200) 50%,
    var(--sand-100) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* alturas variadas para um esqueleto orgânico (combina com o masonry) */
.photo-skeleton:nth-child(3n + 1) { height: 260px; }
.photo-skeleton:nth-child(3n + 2) { height: 180px; }
.photo-skeleton:nth-child(4n + 3) { height: 220px; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Load more ──────────────────────────────────────────────────────── */

.load-more-wrap {
  text-align: center;
  margin-top: 28px;
}

.load-more-btn.hidden,
.gallery-empty.hidden {
  display: none;
}

.gallery-empty {
  color: var(--text-500);
  font-size: 1rem;
  margin: 0;
}

/* ── Lightbox ───────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.lightbox.hidden {
  display: none;
}

.lightbox-inner {
  position: relative;
  max-width: min(92vw, 900px);
  width: 100%;
}

.lightbox-photo {
  width: 100%;
  max-height: 75vh;
  object-fit: contain;
  display: block;
  border-radius: var(--radius-lg);
}

.lightbox-caption {
  color: #fff;
  padding: 12px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lightbox-caption strong { font-size: 0.95rem; }
.lightbox-caption span   { font-size: 0.9rem; opacity: 0.8; }
.lightbox-caption time   { font-size: 0.8rem; opacity: 0.5; }

.lightbox-caption-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.lightbox-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
}

.lightbox-like:hover {
  background: rgba(255, 255, 255, 0.26);
  transform: scale(1.05);
}

.lightbox-like .photo-like-heart {
  color: #ff8fa3;
  opacity: 0.7;
  font-size: 1.05rem;
}

.lightbox-like.is-liked {
  background: rgba(214, 69, 90, 0.92);
}

.lightbox-like.is-liked .photo-like-heart {
  color: #fff;
  opacity: 1;
}

.lightbox-like.bump .photo-like-heart {
  animation: heart-bump 0.42s ease;
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.14);
  border: none;
  cursor: pointer;
  color: #fff;
  border-radius: 999px;
  transition: background 0.2s ease;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-close {
  top: -52px;
  right: 0;
  width: 44px;
  height: 44px;
}

.lightbox-prev,
.lightbox-next {
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
}

.lightbox-prev { left: -60px; }
.lightbox-next { right: -60px; }

@media (max-width: 720px) {
  .lightbox-prev { left:  8px; }
  .lightbox-next { right: 8px; }
  .lightbox-close {
    position: fixed;
    top:   12px;
    right: 12px;
  }
}

/* ── Admin ──────────────────────────────────────────────────────────── */

.admin-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(47, 42, 37, 0.96);
  color: #fff;
  padding: 10px 16px;
  z-index: 8000;
  backdrop-filter: blur(6px);
}

.admin-bar.hidden { display: none; }

.admin-login,
.admin-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
}

.admin-login.hidden,
.admin-status.hidden { display: none; }

.admin-login-label { opacity: 0.85; }

.admin-login input {
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text-900);
  min-width: 130px;
}

.admin-login input:focus {
  outline: none;
  border-color: var(--aqua);
  box-shadow: 0 0 0 3px rgba(180, 211, 199, 0.4);
}

.admin-login .btn,
.admin-status .btn {
  padding: 7px 16px;
  font-size: 0.85rem;
}

.admin-status .btn-outline {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

.admin-status .btn-outline:hover {
  background: rgba(255, 255, 255, 0.12);
}

.admin-error {
  color: #ffb4b4;
  font-weight: 600;
  flex-basis: 100%;
  text-align: center;
}

.admin-error:empty { display: none; }

.photo-delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(180, 0, 0, 0.88);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  display: none;
  z-index: 2;
  transition: background 0.15s ease;
}

.photo-delete-btn:hover { background: rgba(180, 0, 0, 1); }
.admin-mode .photo-delete-btn { display: block; }
