/* ==========================================
   FEED GRID — Desktop: 3 colunas
   ========================================== */

.feed-section {
  padding-bottom: 80px;
}

.feed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

/* ==========================================
   CARD — estrutura compartilhada
   ========================================== */

.feed-card {
  position: relative;
  cursor: pointer;
  background: var(--bg-card);
  overflow: hidden;
}

/* ── Wrap da imagem (quadrado no desktop) ── */
.card-img-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bg-card);
}

.feed-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Placeholder quando não há imagem */
.feed-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #111827, #1e2a3a);
  padding: 20px;
  text-align: center;
}

[data-theme="light"] .feed-card-placeholder {
  background: linear-gradient(135deg, #f0f4ff, #e8f0fe);
}

.feed-card-placeholder .placeholder-icon {
  font-size: 36px;
  opacity: 0.75;
}

.feed-card-placeholder .placeholder-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Overlay de hover — desktop only */
.feed-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.78) 0%,
    rgba(0, 0, 0, 0.3) 50%,
    rgba(0, 0, 0, 0) 100%
  );
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.22s ease;
  padding: 12px;
  pointer-events: none;
}

.feed-card:hover .feed-card-overlay { opacity: 1; }
.feed-card:hover .feed-card-img     { transform: scale(1.05); }

.overlay-title {
  font-size: 11px;
  font-weight: 700;
  color: white;
  line-height: 1.3;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.overlay-tag {
  font-size: 10px;
  color: rgba(255,255,255,0.85);
  background: rgba(59,130,246,0.55);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(6px);
  font-weight: 600;
}

/* ── Header/Footer do card (desktop: oculto) ── */
.card-insta-header,
.card-insta-footer {
  display: none;
}

/* ==========================================
   ESTADO VAZIO
   ========================================== */

.feed-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.feed-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.feed-empty p { font-size: 14px; }

/* ==========================================
   MODAL / LIGHTBOX
   ========================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(16px) saturate(150%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease both;
  overflow-y: auto;
}

.modal-backdrop.closing {
  animation: fadeIn 0.15s ease reverse both;
}

.modal-box {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 820px;
  height: min(580px, 88vh);
  display: flex;
  flex-direction: row;
  overflow: hidden;
  box-shadow: 0 32px 96px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-backdrop.closing .modal-box {
  animation: scaleIn 0.15s ease reverse both;
}

/* ── Imagem — coluna esquerda, preenche toda a altura ── */
.modal-img-wrap {
  position: relative;
  width: 44%;
  flex-shrink: 0;
  background: #000;
  overflow: hidden;
}

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

.modal-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: linear-gradient(160deg, #0f1c2e 0%, #1e3a5f 100%);
  padding: 32px;
  text-align: center;
}

[data-theme="light"] .modal-img-placeholder {
  background: linear-gradient(160deg, #dbeafe 0%, #bfdbfe 100%);
}

.modal-img-placeholder .modal-placeholder-icon { font-size: 72px; }
.modal-img-placeholder .modal-placeholder-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Coluna direita — conteúdo scrollável ── */
.modal-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Cabeçalho estilo Instagram */
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #818cf8, #c084fc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--bg-modal), 0 0 0 3.5px #818cf8;
}

.modal-header-info {
  flex: 1;
  min-width: 0;
}

.modal-username {
  font-size: 13px;
  font-weight: 700;
  display: block;
  color: var(--text-primary);
}

.modal-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition), transform 0.15s ease;
  flex-shrink: 0;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--border-light);
  color: var(--text-primary);
  transform: scale(1.08);
}

/* Corpo scrollável */
.modal-body {
  padding: 18px 20px 14px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-emoji {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
  line-height: 1;
}

.modal-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
  line-height: 1.2;
  color: var(--text-primary);
}

.modal-legenda {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.65;
  font-style: italic;
  padding-left: 10px;
  border-left: 2px solid var(--accent);
}

.modal-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.modal-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.85;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.modal-tag {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-weight: 600;
  transition: background var(--transition), transform 0.15s ease;
}

.modal-tag:hover {
  background: rgba(59, 130, 246, 0.22);
  transform: translateY(-1px);
}

/* Rodapé de navegação */
.modal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-modal);
}

.modal-nav-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all var(--transition);
  cursor: pointer;
}

.modal-nav-btn:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.modal-nav-btn:disabled { opacity: 0.25; cursor: not-allowed; }

.modal-counter {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
  min-width: 40px;
  text-align: center;
}

/* ==========================================
   MOBILE — Layout Instagram (< 768px)
   ========================================== */

@media (max-width: 767px) {

  /* Feed: coluna única com gap visível entre cards */
  .feed-grid {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 8px 0 16px;
  }

  .feed-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border);
    border-bottom: none;
  }

  /* Imagem quadrada, 100% de largura */
  .card-img-wrap {
    aspect-ratio: 1 / 1;
    width: 100%;
  }

  /* Desativa zoom e overlay no mobile (touch) */
  .feed-card:hover .feed-card-img   { transform: none; }
  .feed-card:hover .feed-card-overlay { opacity: 0; }

  /* ── Header estilo Instagram ── */
  .card-insta-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card);
  }

  .card-insta-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #818cf8, #c084fc);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    flex-shrink: 0;
  }

  .card-insta-meta {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    min-width: 0;
  }

  .card-insta-user {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .card-insta-tag {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
  }

  .card-insta-emoji {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
  }

  /* ── Footer estilo Instagram ── */
  .card-insta-footer {
    display: block;
    padding: 10px 14px 14px;
    background: var(--bg-card);
  }

  .card-insta-actions {
    display: flex;
    gap: 14px;
    margin-bottom: 8px;
  }

  .card-action-icon {
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.15s ease, opacity 0.15s ease;
    user-select: none;
  }

  .card-action-icon:active {
    transform: scale(1.25);
    opacity: 0.7;
  }

  .card-insta-caption {
    display: block;
    margin-bottom: 6px;
  }

  .card-insta-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    margin-bottom: 3px;
  }

  .card-insta-legenda {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
  }

  .card-insta-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
  }

  .card-footer-tag {
    font-size: 12px;
    color: var(--accent);
    font-weight: 600;
  }

  /* ── Modal mobile: bottom sheet ── */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.75);
  }

  .modal-box {
    display: flex;
    flex-direction: column;
    border-radius: 20px 20px 0 0;
    height: auto;
    max-height: 96vh;
    max-width: 100%;
    width: 100%;
    border-bottom: none;
    overflow: hidden;
  }

  /* Imagem: quadrada, 100% largura, sem altura forçada */
  .modal-img-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 60vh; /* segurança: nunca ocupa mais que 60% da tela */
    flex-shrink: 0;
    overflow: hidden;
  }

  .modal-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
  }

  /* Conteúdo: ocupa o restante e rola */
  .modal-content {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }
}

/* ==========================================
   TABLET — 2 colunas
   ========================================== */

@media (min-width: 768px) and (max-width: 1023px) {
  .feed-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
  }

  .modal-box {
    max-width: 700px;
  }

  .modal-img-wrap {
    aspect-ratio: 1 / 1;
  }
}
