/**
 * Final styles for the Opigno Gallery Modal.
 * Fixed styles for proper comment display and author name visibility.
 */

/* Modal base styles */
.opigno-gallery-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  overflow: hidden;
}

.opigno-gallery-modal.active {
  display: block;
}

.gallery-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 1001;
}

.gallery-modal-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1002;
}

.gallery-modal-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  z-index: 1004;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.3s;
}

.gallery-modal-close:hover {
  background: rgba(0, 0, 0, 0.8);
}

/* Content layout */
.gallery-modal-content {
  position: relative;
  width: 95%;
  height: 90%;
  max-width: 1400px;
  display: flex;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Left side - Image container */
.gallery-modal-image-container {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #000;
}

.gallery-modal-image {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.gallery-modal-image img.gallery-full-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.video-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.video-wrapper video {
  max-width: 100%;
  max-height: 100%;
}

.image-counter {
  position: absolute;
  bottom: 20px;
  right: 20px;
  padding: 5px 10px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 20px;
  font-size: 14px;
}

/* Navigation buttons */
.gallery-modal-prev,
.gallery-modal-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 24px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.3s;
  z-index: 1003;
}

.gallery-modal-prev {
  left: 20px;
}

.gallery-modal-next {
  right: 20px;
}

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

/* Right side - Sidebar */
.gallery-modal-sidebar {
  width: 360px;
  height: 100%;
  background: white;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #ddd;
  overflow: hidden; /* Prevent overall sidebar overflow */
}

.gallery-modal-details {
  padding: 20px;
  border-bottom: 1px solid #eee;
  overflow-y: auto; /* Allow scrolling for long descriptions */
  max-height: 35%;
}

/* Author information */
.gallery-modal-author {
  margin-bottom: 15px;
}

.author-details {
  display: flex;
  flex-direction: column;
}

.author-image {
  margin-right: 15px;
  float: left;
}

.author-image img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

/* Ensure author name is visible */
.author-name {
  font-weight: bold;
  margin-bottom: 3px;
  display: block;
  clear: right;
}

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

.gallery-modal-description {
  margin-top: 15px;
  margin-bottom: 15px;
  word-break: break-word;
  clear: both;
}

/* Comments section */
.gallery-modal-comments-section {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow: hidden;
  min-height: 0; /* Critical for flexbox to allow child element to scroll */
}

.gallery-modal-comments-section h3 {
  padding: 15px 20px;
  margin: 0;
  font-size: 16px;
  font-weight: bold;
  border-bottom: 1px solid #eee;
}

.gallery-modal-comments {
  flex-grow: 1;
  overflow-y: auto;
  padding: 0;
  min-height: 100px; /* Ensure there's space for comments */
}

.gallery-modal-comments-content {
  padding: 15px;
}

/* Individual comment styling */
.gallery-modal-comment {
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.gallery-modal-comment:last-child {
  border-bottom: none;
}

.comment-author {
  display: flex;
  align-items: flex-start;
  margin-bottom: 5px;
}

.comment-author img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-right: 10px;
}

.comment-author-name {
  font-weight: bold;
  font-size: 14px;
  display: inline-block;
  margin-left: 5px;
}

.comment-content {
  padding-left: 42px;
  margin-bottom: 5px;
}

.comment-text {
  font-size: 14px;
  word-break: break-word;
}

.comment-time {
  padding-left: 42px;
  color: #666;
  font-size: 12px;
}

.gallery-modal-load-more {
  text-align: center;
  padding: 10px;
  color: #3578e5;
  cursor: pointer;
  font-weight: bold;
}

.gallery-modal-load-more:hover {
  text-decoration: underline;
}

.no-comments {
  padding: 20px;
  text-align: center;
  color: #666;
}

/* Comment form */
.gallery-modal-comment-form-container {
  padding: 15px;
  border-top: 1px solid #eee;
  background-color: #f8f8f8;
}

.gallery-modal-comment-form {
  display: flex;
  flex-direction: column;
}

.gallery-modal-comment-form textarea {
  resize: none;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 15px;
  height: 50px;
  margin-bottom: 10px;
  font-size: 14px;
}

.gallery-modal-comment-form button {
  align-self: flex-end;
  border-radius: 20px;
  padding: 5px 15px;
  font-size: 14px;
  cursor: pointer;
}

/* Loading indicators */
.loading-image,
.loading-comments,
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100px;
  color: #fff;
}

.loading-comments,
.loading-spinner {
  color: #666;
}

/* Error messages */
.error {
  color: #e74c3c;
  text-align: center;
  padding: 20px;
}

/* Body class when modal is open */
body.gallery-modal-open {
  overflow: hidden;
}

/* Responsive styles */
@media (max-width: 992px) {
  .gallery-modal-content {
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: none;
    border-radius: 0;
  }

  .gallery-modal-image-container {
    height: 60%;
    overflow: hidden;
  }

  .gallery-modal-sidebar {
    width: 100%;
    height: 40%;
    overflow-y: auto;
  }

  .gallery-modal-comments {
    max-height: 200px;
  }
}

@media (max-width: 576px) {
  .gallery-modal-image-container {
    height: 50%;
  }

  .gallery-modal-sidebar {
    height: 50%;
  }

  .gallery-modal-prev,
  .gallery-modal-next {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .gallery-modal-prev {
    left: 10px;
  }

  .gallery-modal-next {
    right: 10px;
  }
}