/* ============================================================
   GLOBAL LAYOUT
============================================================ */
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  margin: 0;
  padding-top: 72px;
  font-family: "Inter", sans-serif;
}

.feed-wrapper {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px;
}

/* Flash messages */
.flash-message {
  background: #e8f5e9;
  border-left: 4px solid #43a047;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 14px;
}

/* Hide lightbox doc correctly */
#lightbox-doc.hidden {
  display: none;
}

/* ============================================================
   POST CARD (CRITICAL FIXED)
============================================================ */
.post-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 22px;
  border: 1px solid #e2e2e2;
  box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.04);

  /* IMPORTANT FIXES */
  position: relative;
  overflow: hidden;
  display: flow-root; /* prevents overlap / margin collapse */
}

/* ============================================================
   POST HEADER
============================================================ */
.post-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.post-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.post-meta {
  display: flex;
  flex-direction: column;
}

.post-author {
  font-weight: 600;
  font-size: 15px;
}

.post-time {
  color: #666;
  font-size: 12px;
}

.post-category {
  background: #eaf3ff;
  color: #1a73e8;
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 100px;
  margin-top: 2px;
  width: fit-content;
}

/* ============================================================
   TITLE & CONTENT
============================================================ */
.post-title {
  font-size: 20px;
  font-weight: 600;
  margin: 15px 0 8px 0;
}

.post-content {
  font-size: 14px;
  color: #333;
  margin-bottom: 16px;
}

/* ============================================================
   MEDIA — SINGLE FILE
============================================================ */
.media-single {
  margin-top: 12px;
  margin-bottom: 12px;
}

.media-single-img,
.media-single-video {
  width: 100%;
  border-radius: 10px;
  background: #000;
}

/* Normalize document-only post height */
.media-single .doc-attachment {
  width: 100%;
  box-sizing: border-box;
}

/* ============================================================
   REDDIT-STYLE GALLERY
============================================================ */
.media-gallery {
  width: 100%;
  height: 420px;
  min-height: 420px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: #000;
  margin-top: 12px;
}

/* Horizontal slide track */
.gallery-track {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.35s ease;
}

/* Each slide */
.gallery-item {
  min-width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Document inside gallery */
.doc-slide {
  width: 70%;
  max-width: 380px;
  padding: 22px;
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   GALLERY CONTROLS
============================================================ */
.gallery-prev,
.gallery-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 26px;
  transition: 0.2s;
}

.gallery-prev {
  left: 10px;
}
.gallery-next {
  right: 10px;
}

.gallery-prev:hover,
.gallery-next:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Dots */
.gallery-dots {
  position: absolute;
  bottom: 12px;
  width: 100%;
  text-align: center;
}

.gallery-dots span {
  height: 10px;
  width: 10px;
  margin: 0 3px;
  background: #bbb;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
}

.gallery-dots .active {
  background: white;
}

/* ============================================================
   DOCUMENT ATTACHMENT (HOME + DETAIL UNIFIED)
============================================================ */
.doc-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #f3f3f3;
  border-radius: 10px;
  text-decoration: none;
  color: #333;
  border: 1px solid #ddd;
  margin-top: 12px;
}

.doc-attachment:hover {
  background: #e9e9e9;
}

.doc-attachment-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.doc-file-icon {
  font-size: 26px;
  color: #666;
}

.doc-file-info {
  display: flex;
  flex-direction: column;
}

.doc-file-name {
  font-size: 14px;
  font-weight: 600;
  color: #222;
}

.doc-file-meta {
  font-size: 12px;
  color: #666;
}

/* ============================================================
   ACTION BAR & VOTING
============================================================ */

/* Action buttons (Comments + Share) */
.action-btn {
  font-size: 14px;
  color: #333;
  cursor: pointer; /* 👈 IMPORTANT */
  user-select: none;
  transition: color 0.15s ease;
}

.action-btn:hover {
  color: #000;
  text-decoration: underline;
}

/* Share button extra hint */
.share-btn {
  cursor: pointer; /* double safety */
}

.post-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
}

.vote-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vote-btn {
  background: #eee;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

.vote-btn:hover {
  background: #ccc;
}

/* Vote UI state */
.vote-btn.active {
  color: #fff;
}

.vote-btn.upvote.active {
  background: #2ecc71; /* green */
}

.vote-btn.downvote.active {
  background: #e74c3c; /* red */
}

/* ============================================================
   DOCUMENT PREVIEW (INLINE)
============================================================ */
.doc-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: #f3f3f3;
  border-radius: 10px;
  border: 1px solid #ddd;
  cursor: pointer;
}

.doc-preview-card:hover {
  background: #e8e8e8;
}

/* ============================================================
   LIGHTBOX
============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.lightbox.hidden {
  display: none;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
}

/* Image / Video */
#lightbox-img,
#lightbox-video {
  display: none;
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
}

#lightbox-img.active,
#lightbox-video.active {
  display: block;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 28px;
  color: #fff;
  font-size: 40px;
  cursor: pointer;
  z-index: 100001;
  user-select: none;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.25);
  border: none;
  color: #fff;
  font-size: 40px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  cursor: pointer;
  transition: 0.2s;
  z-index: 100001;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-prev {
  left: 18px;
}

#lightbox-next {
  right: 18px;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.45);
}
/* ============================================================
   LIGHTBOX DOCUMENT
============================================================ */
.doc-lightbox-box {
  display: flex;
  justify-content: center;
  align-items: center;
}

.doc-preview {
  background: #ffffff;
  padding: 30px 40px;
  border-radius: 14px;
  max-width: 380px;
  box-shadow: 0px 4px 14px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 480px) {
  .media-gallery {
    height: 320px;
    min-height: 320px;
  }
}
