/* ================================
   Modal Detalle de Publicación
   Solo frontend — estilo creativo
   ================================ */

.det-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.det-modal.open { opacity: 1; visibility: visible; }

.det-modal-backdrop {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(7,17,32,0.55) 0%, rgba(7,17,32,0.82) 100%);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

.det-modal-wrap {
  position: relative;
  width: min(92vw, 1024px);
  max-height: min(90vh, 800px);
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(7,17,32,0.35);
  transform: scale(0.92) translateY(16px);
  transition: transform 0.30s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.det-modal.open .det-modal-wrap { transform: scale(1) translateY(0); }

.det-modal-inner {
  display: flex;
  height: 100%;
  max-height: min(90vh, 800px);
}

/* --- Image Panel --- */
.det-image-panel {
  flex: 1.1;
  background: #0a0e17;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  min-height: 400px;
}
.det-image-panel::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,200,150,0.06) 0%, transparent 70%);
  pointer-events: none; z-index: 1;
}
.det-image-stage {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.det-image-stage img {
  max-width: 100%; max-height: 100%;
  object-fit: contain; display: block;
}
.det-image-stage video {
  max-width: 100%; max-height: 100%;
  display: block;
  border-radius: 4px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
  user-select: none;
  -webkit-user-drag: none;
}
.det-image-stage .post-image-carousel {
  aspect-ratio: auto;
  max-height: 100%;
  margin-bottom: 0;
  background: transparent;
}
.det-image-stage .carousel-track {
  position: relative;
  height: auto;
}
.det-image-stage .carousel-slide {
  position: static;
  inset: auto;
  width: 100%;
  height: auto;
  max-height: calc(90vh - 120px);
  object-fit: contain;
  background: #0a0e17;
  opacity: 1;
  display: none;
}
.det-image-stage .carousel-slide.is-active { display: block; }
.det-image-empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  color: rgba(255,255,255,0.35); text-align: center;
  font-size: 14px; font-weight: 500;
}
.det-image-empty svg { width: 52px; height: 52px; opacity: 0.5; }

/* --- Info Panel --- */
.det-info-panel {
  flex: 0.9;
  display: flex; flex-direction: column;
  background: var(--paper);
  max-width: 420px;
  min-width: 320px;
}

/* --- Header --- */
.det-info-header {
  display: flex; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}
.det-info-author { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.det-avatar-link { flex-shrink: 0; line-height: 0; }
.det-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px; font-weight: 600; color: #fff;
  flex-shrink: 0; user-select: none;
  transition: box-shadow 0.2s;
}
.det-avatar-link:hover .det-avatar { box-shadow: 0 0 0 3px var(--signal-soft); }
.det-author-meta { display: flex; flex-direction: column; min-width: 0; }
.det-username {
  font-size: 14px; font-weight: 600; color: var(--ink);
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.det-username:hover { color: var(--signal); }
.det-post-tags {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--ink-dim);
  margin-top: 1px;
}
.det-tag {
  font-weight: 600; font-size: 10.5px;
  background: var(--signal-soft); color: var(--ink);
  padding: 2px 8px; border-radius: 4px;
  white-space: nowrap;
}
.det-time { white-space: nowrap; }
.det-options-wrap { position: relative; }
.det-options-btn {
  background: none; border: none; padding: 6px; cursor: pointer;
  color: var(--ink-dim); line-height: 0; border-radius: 6px; flex-shrink: 0;
  transition: all 0.15s;
}
.det-options-btn:hover { color: var(--ink); background: var(--surface); }
.det-options-btn svg { width: 18px; height: 18px; }
.det-dropdown{
  position: absolute; top: 100%; right: 0; z-index: 100;
  min-width: 180px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(7,17,32,0.18);
  padding: 4px;
  display: none;
  overflow: hidden;
}
.det-dropdown.open{ display: block; }

/* --- Scrollable middle --- */
.det-info-scroll {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column;
}
.det-info-scroll::-webkit-scrollbar { width: 4px; }
.det-info-scroll::-webkit-scrollbar-track { background: transparent; }
.det-info-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.det-info-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }

.det-info-content {
  padding: 16px 18px 8px;
  font-size: 15px; line-height: 1.6; color: var(--ink);
  word-wrap: break-word;
}
.det-info-content::first-letter {
  font-size: inherit; font-weight: inherit;
  color: inherit;
}

/* --- Shared original embed inside modal --- */
.det-shared-original{
  margin: 8px 18px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--surface);
}
.det-shared-head{
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.det-shared-avatar{
  width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 600; color: #fff;
  flex-shrink: 0; user-select: none;
  background: var(--ink-mid);
}
.det-shared-name{
  font-size: 13px; font-weight: 600; color: var(--ink);
  text-decoration: none;
}
.det-shared-name:hover{ color: var(--signal); }
.det-shared-time{
  font-size: 11.5px; color: var(--ink-dim);
  margin-left: auto; white-space: nowrap;
}
.det-shared-content{
  font-size: 14px; color: var(--ink);
  line-height: 1.45; margin: 0 0 6px;
}
.det-shared-image{
  width: 100%; border-radius: 6px; display: block;
}
.det-shared-video{
  width: 100%; border-radius: 6px; display: block; background: #000;
}

/* Shared embed media: standard contained size (no overflow, wide or tall) */
.det-shared-media-stage { width: 100%; }
.det-shared-media-stage > video,
.det-shared-media-stage > img {
  width: 100%;
  max-height: 380px;
  max-width: 100%;
  object-fit: contain;
  border-radius: 8px;
  background: #0a0e17;
  display: block;
}
.det-shared-media-stage .post-image-carousel {
  max-height: 380px;
  background: #0a0e17;
}
.det-shared-media-stage .post-image-carousel .carousel-slide {
  object-fit: contain;
}

/* --- Comments --- */
.det-comments-section {
  padding: 4px 18px 12px;
  display: flex; flex-direction: column;
  flex: 1;
  min-height: 0;
}
.det-comments-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.det-comments-header svg { width: 14px; height: 14px; }
.det-comments-list {
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 0;
  min-height: 60px;
}
.det-comments-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; text-align: center;
  padding: 24px 8px; color: var(--ink-dim); font-size: 13px;
}
.det-empty-icon { font-size: 24px; opacity: 0.5; }
.det-comments-empty p { margin: 0; }
.det-comments-loader{
  text-align: center; padding: 12px 0; font-size: 12px;
  color: var(--ink-dim); display: none;
}

/* --- Comment item --- */
.det-comment {
  display: flex; gap: 10px;
  animation: detFadeIn 0.25s ease;
}
.det-comment-active .det-comment-body{ background: var(--signal-soft); }
.det-comment-avatar-link { flex-shrink: 0; line-height: 0; }
.det-comment-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 600; color: #fff;
  flex-shrink: 0; user-select: none;
}
.det-comment-body {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 12px;
}
.det-comment-head {
  display: flex; align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
/* --- Comment options --- */
.det-comment-options-wrap { position: relative; margin-left: auto; flex-shrink: 0; }
.det-comment-options-btn {
  background: none; border: none; padding: 2px 4px; cursor: pointer;
  color: var(--ink-dim); line-height: 0; border-radius: 4px; flex-shrink: 0;
  transition: all 0.15s; display: none;
}
.det-comment:hover .det-comment-options-btn { display: block; }
.det-comment-options-btn:hover { color: var(--ink); background: var(--surface); }
.det-comment-options-btn svg { width: 14px; height: 14px; }
.det-comment-dropdown {
  position: absolute; top: 100%; right: 0; z-index: 100;
  min-width: 170px;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(7,17,32,0.18);
  padding: 4px;
  display: none;
  overflow: hidden;
}
.det-comment-dropdown.open { display: block; }
.det-comment-name {
  font-size: 13px; font-weight: 600; color: var(--ink);
  text-decoration: none;
  font-family: 'Inter', sans-serif;
}
.det-comment-name:hover { color: var(--signal); }
.det-comment-text {
  font-size: 14px; color: var(--ink); line-height: 1.45;
  word-wrap: break-word;
  font-family: 'Inter', sans-serif;
}
.det-comment-time {
  font-size: 11px; color: var(--ink-dim);
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

/* --- Actions bar --- */
.det-actions-bar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.det-action {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; padding: 4px; cursor: pointer;
  color: var(--ink-dim); font-size: 13px; font-weight: 500;
  font-family: 'Inter', sans-serif;
  line-height: 0; border-radius: 6px;
  transition: all 0.15s;
}
.det-action svg { width: 20px; height: 20px; }
.det-action:hover { color: var(--ink); }
.det-action.active { color: var(--signal); }
.det-like-btn.active svg {
  fill: var(--signal);
  animation: detHeartPop 0.3s ease;
}
.det-timestamp {
  margin-left: auto;
  font-size: 11px; color: var(--ink-dim); white-space: nowrap;
}

/* --- Comment input --- */
.det-comment-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  flex-shrink: 0;
  background: var(--paper);
}
.det-input-avatar-wrap { flex-shrink: 0; line-height: 0; }
.det-input-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 600; color: #fff;
  flex-shrink: 0; user-select: none;
}
.det-comment-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  color: var(--ink);
  background: var(--surface);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.det-comment-input:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-soft);
}
.det-comment-input::placeholder { color: var(--ink-dim); }
.det-comment-send {
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none;
  cursor: pointer;
  color: var(--signal);
  padding: 4px;
  transition: color 0.15s;
}
.det-comment-send:hover:not(:disabled) { color: var(--signal-hover); }
.det-comment-send:disabled { opacity: 0.35; cursor: default; }
.det-comment-send svg { width: 20px; height: 20px; }

/* --- Close button --- */
.det-modal-close-btn {
  position: absolute; top: 8px; right: 12px; z-index: 10;
  border: none; background: none;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  font-size: 22px; line-height: 1;
  padding: 4px;
  transition: color 0.15s;
  opacity: 0;
}
.det-modal.open .det-modal-close-btn { opacity: 1; }
.det-modal-close-btn:hover { color: #fff; }

/* --- Animations --- */
@keyframes detFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes detHeartPop {
  0% { transform: scale(1); }
  30% { transform: scale(1.3); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* --- Text-only mode (no image) --- */
.det-modal.text-only .det-image-panel { display: none; }
.det-modal.text-only .det-info-panel {
  flex: 1; max-width: none; min-width: 0;
  width: min(92vw, 640px);
}
.det-modal.text-only .det-modal-wrap {
  width: min(92vw, 640px);
}
.det-modal.text-only .det-info-content {
  font-size: 16px; line-height: 1.65;
}
.det-modal.text-only .det-modal-close-btn { color: var(--ink-dim); }
.det-modal.text-only .det-modal.open .det-modal-close-btn { color: var(--ink-dim); }
.det-modal.text-only .det-modal-close-btn:hover { color: var(--ink); }

/* --- Mobile --- */
@media (max-width: 768px) {
  .det-modal-wrap {
    width: 100vw; max-height: 100vh;
    border-radius: 0;
    min-height: 100dvh;
  }
  .det-modal-inner {
    flex-direction: column;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
  }
  .det-image-panel {
    flex: none;
    height: 30vh; min-height: 160px;
  }
  .det-image-stage { padding: 6px; }
  /* Mobile only: keep tall images fully contained inside the fixed 30vh panel
     (override the desktop max-height so they aren't clipped to a slice). */
  .det-image-stage .post-image-carousel { height: 100%; }
  .det-image-stage .carousel-track { height: 100%; }
  .det-image-stage .carousel-slide { max-height: 100%; }
  .det-info-panel {
    flex: 1; max-width: none; min-width: 0;
    min-height: 0;
  }
  .det-info-scroll {
    flex: 1 1 0%;
    overflow-y: auto;
    min-height: 0;
  }
  .det-info-scroll::-webkit-scrollbar { width: 4px; }
  .det-info-scroll::-webkit-scrollbar-track { background: transparent; }
  .det-info-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
  .det-info-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }
  .det-modal-close-btn { top: 6px; right: 8px; }
  .det-timestamp { display: none; }
  .det-info-header { padding: 10px 14px; }
  .det-info-content { padding: 12px 14px 6px; font-size: 14px; }
  .det-shared-original { margin: 4px 14px 2px; padding: 10px 12px; }
  .det-comments-section { flex: none; overflow-y: visible; padding: 2px 14px 8px; }
  .det-actions-bar { padding: 8px 14px; gap: 10px; }
  .det-comment-input-row { padding: 8px 12px; }
  .det-comment { gap: 8px; }
  .det-comment-body { padding: 6px 10px; }
  .det-comment-text { font-size: 13px; }
  .det-avatar { width: 30px; height: 30px; font-size: 10px; }
  .det-comment-avatar { width: 24px; height: 24px; font-size: 9px; }
  .det-input-avatar { width: 24px; height: 24px; font-size: 9px; }
  .det-comment-input { font-size: 13px; padding: 6px 12px; }
  .det-action svg { width: 18px; height: 18px; }
  .det-like-btn.active svg { animation: none; }
}

.mention-link{
  color: var(--signal);
  font-weight: 600;
  text-decoration: none;
}
.mention-link:hover{
  text-decoration: underline;
}
