/* ============================================================================
   shared-posts.css
   Post cards (no inline comments; they open in #postViewModal) — visually matched to shared-products-dimona.css
   (#f4f3ef surface, deep rounding, Figtree, #151219 text, #712bf5 accent).

   NOTE: shared-posts.js writes inline styles on the card (border-radius,
   box-shadow, font sizes, avatar size) and Bootstrap utilities such as
   .p-2 / .text-muted / .rounded-circle use !important, so !important is
   required in several rules below to override them.
   ========================================================================== */

/* ─── Grid (same breakpoints as the Dimona product grid) ──────────────────── */

#allPostsContainer {
  gap: 20px !important;
}

@media (max-width: 1100px) {
  #allPostsContainer { grid-template-columns: repeat(3, 1fr) !important; }
}
@media (max-width: 768px) {
  #allPostsContainer { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 480px) {
  #allPostsContainer { grid-template-columns: repeat(1, 1fr) !important; }
}

/* ─── Card ────────────────────────────────────────────────────────────────── */

.post-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px;
  overflow: hidden;
  background: #f4f3ef !important;
  border: none !important;
  border-radius: 32px !important;
  box-shadow: none !important;
  font-family: 'Figtree', sans-serif;
  font-weight: 400;
  color: #151219;
}

/* The whole card opens the post modal (comments live there) */
.post-card { cursor: pointer; }

/* ─── Image ───────────────────────────────────────────────────────────────── */

.post-card > div:has(> img.lazy-load) {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4 !important;   /* horizontal: a proporção do produto (4/5) deitada */
  overflow: hidden;
  background: #e2e2e2 !important;
  border-radius: 26px;
  cursor: pointer;
}

.post-card .lazy-load {
  display: block;
  max-width: 100%;
  transform: scale(1);
  transition: transform 0.4s ease;
  will-change: transform;
}

.post-card > div:has(> img.lazy-load):hover .lazy-load {
  transform: scale(1.05);
}

/* ─── Body (author, text, date) ───────────────────────────────────────────── */

.post-card > .p-2 {
  padding: 12px 4px 4px !important;
}

/* Author row */
.post-card > .p-2 > .d-flex {
  gap: 10px !important;
  margin-bottom: 8px !important;
}

.post-card img.user-profile-link {
  flex-shrink: 0;
  width: 38.4px !important;
  height: 38.4px !important;
  object-fit: cover;
  background: #1c1c1f;
  border-radius: 10px !important;
  cursor: pointer;
}

.post-card small.user-profile-link {
  min-width: 0;
  font-size: 17px !important;
  font-weight: 500 !important;
  color: #000 !important;
  cursor: pointer;
}

.post-card .user-profile-link:hover {
  opacity: 0.75;
}

/* Post text */
.post-card > .p-2 > p {
  margin-top: 4px;
  font-size: 15px !important;
  line-height: 1.4;
  color: #151219;
}

/* Date */
.post-card > .p-2 > small {
  display: block;
  margin-top: 8px;
  font-size: 12px !important;
  color: #9a9aa1 !important;
}

/* ─── Like / delete: na linha do autor, ao lado do nome (como nas artes) ───── */

.post-card > .p-2 > .d-flex > small.user-profile-link {
  flex: 1 1 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-card .post-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
}

/* ─── Buttons (same look as the Dimona .pm-btn family) ────────────────────── */

.post-card .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px !important;
  font-family: inherit;
  font-size: 0.85rem !important;
  font-weight: 600;
  line-height: 1;
  color: #151219;
  background: #fff;
  border: 1.5px solid #e2e2e2;
  border-radius: 12px;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, transform 0.15s ease;
}

.post-card .btn:hover {
  color: #712bf5;
  background: #fff;
  border-color: #712bf5;
}

.post-card .btn:active {
  transform: scale(0.96);
}

.post-card .btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(113, 43, 245, 0.25);
}

.post-card .post-actions .btn {
  flex-shrink: 0;
  min-height: 30px;
  padding: 5px 9px !important;
  font-size: 0.78rem !important;
  white-space: nowrap;
}

/* Liked state (btn-primary / liked / active, depending on shared-likes.js) */
.post-card .like-button.btn-primary,
.post-card .like-button.liked,
.post-card .like-button.active {
  color: #fff;
  background: #712bf5;
  border-color: #712bf5;
}

.post-card .like-button.btn-primary:hover,
.post-card .like-button.liked:hover,
.post-card .like-button.active:hover {
  color: #fff;
  background: #5f22d6;
  border-color: #5f22d6;
}

/* Delete — same red as .dimona-menu-item-danger */
.post-card .post-actions .delete-post-button {
  width: 30px;
  padding: 0 !important;
  color: #fff;
  background: #e0475a;
  border-color: #e0475a;
}

.post-card .post-actions .delete-post-button:hover {
  color: #fff;
  background: #e0475a;
  border-color: #e0475a;
  filter: brightness(1.08);
}

/* ─── Post modal (comments live here, not on the card) ───────────────────── */

#postViewModal .modal-content {
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 28px;
  background: #fff;
  font-family: 'Figtree', sans-serif;
  color: #151219;
}

#postViewModal .btn-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  width: 32px;
  height: 32px;
  margin: 0;
  background-color: #fff;
  border-radius: 50%;
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

#postViewModal .po-wrap {
  display: flex;
  height: min(640px, 86vh);
}

#postViewModal .po-wrap.po-noimg {
  height: auto;
  max-height: 86vh;
}

#postViewModal .po-left {
  display: flex;
  flex: 1 1 56%;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 20px;
  background: #f4f3ef;
}

#postViewModal .po-left img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 18px;
}

#postViewModal .po-right {
  display: flex;
  flex: 0 0 380px;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 28px 24px 20px;
}

#postViewModal .po-noimg .po-right {
  flex: 1 1 auto;
}

#postViewModal .po-info {
  flex-shrink: 0;
  padding-right: 36px;           /* keep clear of the close button */
}

#postViewModal .po-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

#postViewModal .po-author img {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  object-fit: cover;
  background: #1c1c1f;
  border-radius: 10px;
  cursor: pointer;
}

#postViewModal .po-author span {
  min-width: 0;
  font-size: 17px;
  font-weight: 500;
  color: #000;
  cursor: pointer;
}

#postViewModal .po-author .user-profile-link:hover { opacity: 0.75; }

#postViewModal .po-text {
  max-height: 160px;
  margin: 12px 0 0;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.45;
  color: #151219;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#postViewModal .po-date {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: #9a9aa1;
}

#postViewModal .po-comments {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1.5px solid #ecebe7;
}

#postViewModal .po-noimg .cm-list { max-height: 320px !important; }

/* Comments panel (list + input) rendered by SharedCommentsManager.mountCommentsPanel */
#postViewModal .po-comments .cm-panel-title {
  flex-shrink: 0;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #151219;
}

#postViewModal .po-comments .cm-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;       /* shared-comments.js sets 300px inline */
  padding-right: 4px;
  overflow-y: auto !important;
  font-size: 0.9rem;
}

#postViewModal .po-comments .cm-list::-webkit-scrollbar { width: 4px; }
#postViewModal .po-comments .cm-list::-webkit-scrollbar-track { background: transparent; }
#postViewModal .po-comments .cm-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

/* "No comments yet." / error */
#postViewModal .po-comments .cm-list > p {
  margin: 0;
  font-size: 14px;
  color: #9a9aa1 !important;
}

#postViewModal .po-comments .cm-list img.user-profile-link {
  width: 34px !important;
  height: 34px !important;
  object-fit: cover;
  background: #1c1c1f;
  border-radius: 10px !important;
}

#postViewModal .po-comments .cm-list strong {
  font-size: 14px;
  font-weight: 500;
}

#postViewModal .po-comments .cm-list .text-break {
  font-size: 14px;
  line-height: 1.4;
}

#postViewModal .po-comments .cm-list .text-muted {
  font-size: 12px;
  color: #9a9aa1 !important;
}

#postViewModal .po-comments .cm-list .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  font-weight: 600;
  color: #151219;
  background: #fff;
  border: 1.5px solid #e2e2e2;
  border-radius: 10px;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#postViewModal .po-comments .cm-list .btn:hover {
  color: #712bf5;
  background: #fff;
  border-color: #712bf5;
}

/* Liked comment (the like manager toggles btn-primary / btn-outline-primary) */
#postViewModal .po-comments .cm-list .comment-like-button.btn-primary {
  color: #fff;
  background: #712bf5;
  border-color: #712bf5;
}

#postViewModal .po-comments .cm-list .btn-link {
  border: none;
  background: transparent;
}

#postViewModal .po-comments .cm-list .alert {
  margin: 8px 0 0;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 12px;
}

/* Input row */
#postViewModal .po-comments .cm-input {
  flex-shrink: 0;
  margin-top: 12px;
}

#postViewModal .po-comments .cm-input .input-group {
  flex-wrap: nowrap;
  gap: 6px;
}

#postViewModal .po-comments .cm-input .input-group > * {
  margin-left: 0 !important;
  border-radius: 12px !important;
}

#postViewModal .po-comments .cm-input .form-control {
  font-family: inherit;
  background: #fff;
  border: 1.5px solid #e2e2e2;
  padding: 8px 12px;
  box-shadow: none;
  transition: border-color 0.15s ease;
}

#postViewModal .po-comments .cm-input .form-control:focus {
  outline: none;
  border-color: #712bf5;
  box-shadow: 0 0 0 3px rgba(113, 43, 245, 0.15);
}

#postViewModal .po-comments .cm-input .btn {
  font-family: inherit;
  font-weight: 600;
  color: #151219;
  background: #fff;
  border: 1.5px solid #e2e2e2;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#postViewModal .po-comments .cm-input .btn:hover {
  color: #712bf5;
  background: #fff;
  border-color: #712bf5;
}

#postViewModal .po-comments .cm-input .comment-submit {
  color: #fff;
  background: #712bf5;
  border-color: #712bf5;
}

#postViewModal .po-comments .cm-input .comment-submit:hover {
  color: #fff;
  background: #5f22d6;
  border-color: #5f22d6;
}

@media (max-width: 768px) {
  #postViewModal .po-wrap { flex-direction: column; height: auto; }
  #postViewModal .po-left { flex: none; height: 42vh; padding: 12px; }
  #postViewModal .po-right { flex: none; padding: 20px 16px 16px; }
  #postViewModal .cm-list { max-height: 260px !important; }
}

/* ─── Debug-only dark mode (mirrors shared-products-dimona.css) ───────────── */

html.kv-dbg-dark .post-card,
html.kv-dbg-dark .post-card > div:has(> img.lazy-load),
html.kv-dbg-dark .post-card .btn,
html.kv-dbg-dark #postViewModal .modal-content,
html.kv-dbg-dark #postViewModal .btn-close,
html.kv-dbg-dark #postViewModal .cm-list .btn,
html.kv-dbg-dark #postViewModal .cm-input .form-control,
html.kv-dbg-dark #postViewModal .cm-input .btn:not(.comment-submit) {
  background: #222124 !important;
  border-color: #e1dfe6 !important;
}

html.kv-dbg-dark #postViewModal .modal-content,
html.kv-dbg-dark #postViewModal .po-text,
html.kv-dbg-dark #postViewModal .cm-panel-title {
  color: #e1dfe6;
}

html.kv-dbg-dark #postViewModal .cm-input .comment-submit {
  background: #712bf5 !important;
}

html.kv-dbg-dark .post-card .like-button.btn-primary,
html.kv-dbg-dark .post-card .like-button.liked,
html.kv-dbg-dark .post-card .like-button.active {
  background: #712bf5 !important;
}

html.kv-dbg-dark .post-card .delete-post-button {
  background: #e0475a !important;
}

@media (max-width: 480px) {
  .post-card { padding: 8px; border-radius: 18px !important; }
  .post-card > div:has(> img.lazy-load) { aspect-ratio: 3 / 4 !important; border-radius: 12px; }
  .post-card > .p-2 { padding: 8px 2px 2px !important; }
  .post-card > .p-2 > .d-flex { gap: 6px !important; margin-bottom: 6px !important; }
  .post-card > .p-2 > .d-flex { flex-wrap: wrap; }
  .post-card img.user-profile-link { width: 30px !important; height: 30px !important; }
  .post-card small.user-profile-link { font-size: 14px !important; }
  .post-card > .p-2 > .d-flex > small.user-profile-link { flex: 1 1 24px; }
  .post-card > .p-2 > p { font-size: 14px !important; line-height: 1.4; }
  .post-card .post-actions { flex: 1 0 100%; gap: 4px; }
  .post-card .post-actions .btn { min-height: 32px; padding: 4px 8px !important; }
}

/* ─── Profile pages only: hide author avatar + name ───────────────────────────
   (profile.html / public-profile.html use <body class="profile-page-shell">).
   The row's space is reclaimed: the like / delete buttons (same row) are taken
   out of the flow and floated over the top-right corner of the image instead. */

body.profile-page-shell .post-card {
  position: relative;
}

body.profile-page-shell .post-card img.user-profile-link,
body.profile-page-shell .post-card small.user-profile-link {
  display: none !important;
}

body.profile-page-shell .post-card > .p-2 > .d-flex {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 3;
  margin: 0 !important;
}

/* Text now starts right under the image */
body.profile-page-shell .post-card > .p-2 {
  padding-top: 10px !important;
}

@media (max-width: 480px) {
  body.profile-page-shell .post-card > .p-2 > .d-flex { top: 14px; right: 14px; }
  body.profile-page-shell .post-card .post-actions { flex: 0 0 auto; }
}