/* ===== VARIÁVEIS DE TEMA INSTAGRAM ===== */
:root {
  --modal-bg: #18191A;
  --modal-panel-bg: #fff;
  --modal-border-radius: 24px;
  --modal-shadow: 0 8px 40px rgba(0,0,0,0.4);
  --modal-header-border: #efefef;
  --modal-footer-border: #efefef;
  --modal-user-name: #262626;
  --modal-desc-color: #262626;
  --modal-close-color: #fff;
  --modal-close-hover-bg: rgba(0,0,0,0.15);
  --modal-close-size: 32px;
  --modal-panel-width: 400px;
  --modal-panel-width-mobile: 100vw;
  --modal-panel-bg-dark: #18191A;
  --modal-action-hover: #fafafa;
  --modal-action-active: #efefef;
  --modal-accent: #0095F6;
  --modal-comment-bg: #fafafa;
}

body.modal-open {
  overflow: hidden !important;
}

#modalBg {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(2px);
  overflow-y: auto;
  overscroll-behavior: contain;
  transition: opacity 0.3s;
}
body:not(.modal-open) #modalBg {
  display: none !important;
}

#modalInstagram {
  display: flex;
  flex-direction: row;
  background: var(--modal-panel-bg);
  border-radius: var(--modal-border-radius);
  box-shadow: var(--modal-shadow);
  width: 800px;
  height: 600px;
  max-width: 98vw;
  max-height: 98vh;
  overflow: hidden;
  position: relative;
  border: 1px solid #dbdbdb;
}
@media (max-width: 900px) {
  #modalInstagram {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    min-width: 0;
    min-height: 0;
    max-width: 100vw;
    max-height: 100vh;
  }
}

.modal-media-col {
  flex: 1 1 60%;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 350px;
  max-width: 600px;
  height: 100%;
  position: relative;
}
@media (max-width: 900px) {
  .modal-media-col {
    width: 100vw;
    height: 50vh;
    min-width: 0;
    max-width: 100vw;
    max-height: 50vh;
  }
}
#modalMediaImg, #modalMediaVideo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  margin: 0 auto;
  background: #000;
  border-radius: 0;
}

.modal-panel {
  flex: 1 1 40%;
  background: var(--modal-panel-bg);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: var(--modal-panel-width);
  max-width: var(--modal-panel-width);
  position: relative;
  overflow: hidden;
  border-left: 1px solid #efefef;
}
@media (max-width: 900px) {
  .modal-panel {
    width: var(--modal-panel-width-mobile);
    min-width: 0;
    max-width: 100vw;
    height: 50vh;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid #efefef;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--modal-header-border);
  background: var(--modal-panel-bg);
  min-height: 56px;
}
.modal-user-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 12px;
  object-fit: cover;
  border: 1px solid #dbdbdb;
}
.modal-user-name {
  font-weight: bold;
  color: var(--modal-user-name);
  flex: 1;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#modalFollowBtn {
  background: #0095F6;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
#modalFollowBtn:hover {
  background: #1877f2;
}
#modalFollowBtn.hidden {
  display: none;
}

#closeModal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--modal-close-color);
  z-index: 2;
  padding: 0;
  border-radius: 50%;
  width: var(--modal-close-size);
  height: var(--modal-close-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: background 0.2s;
}
#closeModal:hover {
  background: var(--modal-close-hover-bg);
}
@media (max-width: 900px) {
  #closeModal {
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
  }
}

#modalDesc {
  padding: 12px 16px;
  color: var(--modal-desc-color);
  font-size: 15px;
  white-space: pre-line;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid #eee;
  background: var(--modal-panel-bg);
  max-height: 48px;
  line-height: 1.3;
}
@media (max-width: 900px) {
  #modalDesc {
    max-height: 36px;
    font-size: 0.95rem;
    padding: 10px 10px 6px 10px;
  }
}

#modalCommentsWrapper {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  max-height: calc(100% - 160px);
  padding: 8px 16px 0 16px;
  background: var(--modal-panel-bg);
}
@media (max-width: 900px) {
  #modalCommentsWrapper {
    max-height: 30vh;
    padding: 6px 8px 0 8px;
  }
}

#modalComments {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#modalComments .comment {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
}
#modalComments .comment:last-child {
  border-bottom: none;
}
#modalComments .comment-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: #eee;
  border: 1px solid #dbdbdb;
}
#modalComments .comment-content {
  flex: 1;
  min-width: 0;
}
#modalComments .comment-user {
  font-weight: 600;
  color: #262626;
  font-size: 0.97em;
  margin-right: 4px;
}
#modalComments .comment-text {
  color: #222;
  font-size: 0.97em;
  word-break: break-word;
}
#modalComments .comment-like-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1em;
  margin-left: 8px;
  transition: color 0.2s;
}
#modalComments .comment-like-btn:hover {
  color: var(--modal-accent);
}

#modalShowAllComments {
  display: block;
  margin: 10px auto 0 auto;
  background: none;
  border: none;
  color: var(--modal-accent);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95em;
  text-align: center;
}
#modalShowAllComments.hidden {
  display: none;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--modal-footer-border);
  background: var(--modal-panel-bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#modalActionsBar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
#modalActionsBar button {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}
#modalActionsBar button:hover {
  background: var(--modal-action-hover);
  color: var(--modal-accent);
}
#modalLikes {
  color: #888;
  font-size: 0.9rem;
  margin-left: auto;
}

#modalEmojiBar {
  display: flex;
  gap: 6px;
  justify-content: flex-start;
  margin-bottom: 2px;
}
#modalEmojiBar .emoji {
  font-size: 1.3rem;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 6px;
  transition: background 0.2s;
  position: relative;
}
#modalEmojiBar .emoji:hover {
  background: var(--modal-action-hover);
}
#modalEmojiBar .emoji .emoji-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #fff;
  color: #0095F6;
  font-size: 0.7em;
  border-radius: 8px;
  padding: 1px 5px;
  border: 1px solid #eee;
  font-weight: 600;
}

#modalCommentForm {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--modal-panel-bg);
  border: none;
  padding: 0;
  margin-top: 2px;
}
#modalEmojiBtn {
  font-size: 1.3rem;
  color: #888;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 50%;
  transition: background 0.2s;
}
#modalEmojiBtn:hover {
  color: #0095F6;
  background: var(--modal-action-hover);
}
#modalCommentInput {
  flex: 1;
  border: none;
  padding: 8px 0;
  font-size: 0.95rem;
  color: #222;
  background: transparent;
  outline: none;
}
#modalCommentInput::placeholder {
  color: #bbb;
}
#modalPostCommentBtn {
  color: #0095F6;
  font-weight: 600;
  font-size: 0.95rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
#modalPostCommentBtn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

#modalEmojiPopover {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 16px;
  background: #fff;
  border: 1px solid #dbdbdb;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  z-index: 100;
  max-width: 280px;
}
#modalEmojiPopover button.emoji {
  font-size: 1.25rem;
  padding: 4px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}
#modalEmojiPopover button.emoji:hover {
  background: #f0f0f0;
}

#modalPrevItem, #modalNextItem {
  background: rgba(0,0,0,0.5);
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
}
#modalPrevItem:hover, #modalNextItem:hover {
  background: rgba(0,0,0,0.7);
}
#modalPrevItem { left: 10px; }
#modalNextItem { right: 10px; }

#modalThumbs {
  display: flex;
  gap: 4px;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}
#modalThumbs img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid #eee;
  cursor: pointer;
  opacity: 0.7;
  transition: border 0.2s, opacity 0.2s;
}
#modalThumbs img.border-primary-color {
  border: 2px solid #0095F6;
  opacity: 1;
}
#modalThumbs img:hover {
  border: 2px solid #0095F6;
  opacity: 1;
}

#modalMediaIndicators {
  display: flex;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  gap: 4px;
}
#modalMediaIndicators .indicator-dot {
  width: 6px;
  height: 6px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  transition: background 0.2s;
}
#modalMediaIndicators .indicator-dot.active {
  background: #fff;
}