/**
 * YouTube Gallery Widget Styles
 * Matches Astra theme and Elfsight design
 */

.ytg-container {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  background-color: #FFFFFF;
  padding: 1.25em 1em;
  border-radius: 4px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.ytg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5em;
  flex-wrap: wrap;
  gap: 1em;
}

.ytg-channel-info {
  display: flex;
  align-items: center;
  gap: 0.75em;
  text-decoration: none;
}

.ytg-channel-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #E0E0E0;
}

.ytg-channel-name {
  font-size: 22px !important;
  font-weight: 400;
  margin: 0;
  color: #030303;
  text-decoration: none;
  transition: text-decoration 0.2s ease;
}

.ytg-channel-info:hover .ytg-channel-name {
  text-decoration: underline;
}

/* Subscribe Button */
.ytg-subscribe-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  background-color: #FF0000 !important;
  color: #FFFFFF !important;
  padding: 0.6em 1.2em;
  border-radius: 4px;
  text-decoration: none !important;
  font-weight: 500;
  font-size: 0.95rem;
}

.ytg-subscribe-btn:hover,
.ytg-subscribe-btn:focus,
.ytg-subscribe-btn:active,
.ytg-subscribe-btn:visited {
  background-color: #FF0000 !important;
  color: #FFFFFF !important;
  text-decoration: none !important;
}

.ytg-yt-icon {
  width: 20px;
  height: 20px;
}

/* Video Grid */
.ytg-video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1em;
  margin-bottom: 1.5em;
  position: relative;
}

/* Navigation Arrow Indicators */
.ytg-nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 10;
  transition: all 0.2s ease;
  pointer-events: auto;
}

.ytg-nav-arrow:hover {
  background-color: rgba(255, 255, 255, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ytg-nav-arrow-left {
  left: 10px;
}

.ytg-nav-arrow-right {
  right: 10px;
}

.ytg-nav-arrow svg {
  width: 24px;
  height: 24px;
  fill: #606060;
}

@media (min-width: 768px) {
  .ytg-video-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .ytg-video-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Video Card */
.ytg-video-card {
  background-color: #FFFFFF;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ytg-thumbnail-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* Thumbnail */
.ytg-thumbnail-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background-color: #000000;
  overflow: hidden;
}

.ytg-thumbnail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ytg-play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 48px;
  transition: opacity 0.2s ease;
}

.ytg-video-card:hover .ytg-play-button {
  opacity: 0.9;
}

.ytg-play-icon {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Video Info */
.ytg-video-info {
  padding: 0.75em;
  min-height: 140px;
  display: flex;
  flex-direction: column;
}

.ytg-video-title {
  font-size: 14px !important;
  font-weight: 600;
  color: #030303;
  margin: 0 0 0.3em 0;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.6em;
}

.ytg-video-date {
  font-size: 0.75rem;
  color: #606060;
  margin: 0 0 0.4em 0;
  font-weight: 400;
}

.ytg-video-description {
  font-size: 0.8rem;
  color: #606060;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.8em;
}

/* Pagination */
.ytg-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4em;
  flex-wrap: wrap;
  margin-top: 1.5em;
}

.ytg-page-btn {
  min-width: 2.2em;
  height: 2.2em;
  padding: 0.4em 0.6em;
  border: none;
  background-color: #E8E8E8;
  color: #606060;
  border-radius: 2px;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ytg-page-btn:hover {
  background-color: #D0D0D0;
}

.ytg-page-btn.ytg-active {
  background-color: #FF0000;
  color: #FFFFFF;
  font-weight: 500;
}

.ytg-page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Loading and Error States */
.ytg-loading,
.ytg-error {
  text-align: center;
  padding: 3em 1em;
  color: #666666;
  font-size: 1rem;
}

.ytg-error {
  color: #CC0000;
}

/* Responsive Adjustments */
@media (max-width: 767px) {
  .ytg-container {
    padding: 1.5em 1em;
  }

  .ytg-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .ytg-channel-name {
    font-size: 1.25rem;
  }

  .ytg-channel-avatar {
    width: 50px;
    height: 50px;
  }

  .ytg-video-grid {
    grid-template-columns: 1fr;
    gap: 1em;
  }

  .ytg-subscribe-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 544px) {
  .ytg-container {
    padding: 1em 0.75em;
  }

  .ytg-video-title {
    font-size: 14px !important;
  }

  .ytg-video-description {
    font-size: 0.85rem;
  }

  .ytg-page-btn {
    min-width: 2em;
    height: 2em;
    padding: 0.4em 0.6em;
    font-size: 0.85rem;
  }
}

/* Print Styles */
@media print {
  .ytg-subscribe-btn,
  .ytg-pagination {
    display: none;
  }
}

/* Video Modal / Lightbox */
.ytg-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ytgFadeIn 0.2s ease;
}

@keyframes ytgFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

.ytg-modal-content {
  position: relative;
  width: 95%;
  max-width: 1200px;
  background-color: #FFFFFF;
  border-radius: 8px;
  overflow: hidden;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

.ytg-modal-close {
  position: absolute;
  top: -45px;
  right: 0;
  width: 40px;
  height: 40px;
  background-color: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  color: #000000;
  cursor: pointer;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.ytg-modal-close:hover {
  background-color: #FFFFFF;
  transform: scale(1.1);
}

.ytg-modal-close:focus {
  outline: 2px solid #FFFFFF;
  outline-offset: 2px;
}

.ytg-modal-player {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  background-color: #000000;
}

.ytg-modal-player iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.ytg-modal-info {
  padding: 1em 1.5em;
  background-color: #FFFFFF;
}

/* Modal Channel Info */
.ytg-modal-channel {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-bottom: 1em;
  padding-bottom: 1em;
  border-bottom: 1px solid #E0E0E0;
}

.ytg-modal-channel-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
}

.ytg-modal-channel-details {
  flex: 1;
}

.ytg-modal-channel-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #030303;
}

.ytg-modal-stats {
  margin: 0.25em 0 0 0;
  font-size: 14px;
  color: #606060;
}

.ytg-modal-subscribe {
  display: inline-flex;
  align-items: center;
  background-color: #FF0000 !important;
  color: #FFFFFF !important;
  padding: 0.5em 1em;
  border-radius: 4px;
  text-decoration: none !important;
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
}

.ytg-modal-subscribe:hover {
  background-color: #CC0000 !important;
}

/* Modal Title */
.ytg-modal-title {
  margin: 0 0 0.75em 0;
  font-size: 18px;
  font-weight: 600;
  color: #030303;
  line-height: 1.4;
}

/* Modal Description */
.ytg-modal-description {
  margin-bottom: 1em;
}

.ytg-modal-description-text {
  margin: 0 0 0.5em 0;
  font-size: 14px;
  color: #030303;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ytg-modal-description-text.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 4.8em;
}

.ytg-modal-show-more {
  background: none;
  border: none;
  color: #065FD4;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.ytg-modal-show-more:hover {
  text-decoration: underline;
}

/* Modal Social Sharing */
.ytg-modal-social {
  display: flex;
  gap: 0.75em;
  padding-top: 1em;
  border-top: 1px solid #E0E0E0;
}

.ytg-modal-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 1em;
  border-radius: 4px;
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

.ytg-modal-share-btn:hover {
  opacity: 0.9;
}

.ytg-modal-share-btn.facebook {
  background-color: #1877F2;
  color: #FFFFFF !important;
}

.ytg-modal-share-btn.twitter {
  background-color: #1DA1F2;
  color: #FFFFFF !important;
}

.ytg-modal-share-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Modal Responsive Styles */
@media (max-width: 768px) {
  .ytg-modal-content {
    width: 100%;
    max-width: 100%;
    border-radius: 0;
  }

  .ytg-modal-close {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    font-size: 24px;
    background-color: rgba(255, 255, 255, 0.95);
  }

  .ytg-modal-info {
    padding: 0.75em 1em;
  }

  .ytg-modal-title {
    font-size: 16px;
  }

  .ytg-modal-social {
    flex-direction: column;
  }

  .ytg-modal-share-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .ytg-modal-title {
    font-size: 14px;
  }

  .ytg-modal-info {
    padding: 0.5em 0.75em;
  }

  .ytg-modal-channel-name {
    font-size: 14px;
  }

  .ytg-modal-stats {
    font-size: 12px;
  }

  .ytg-modal-channel {
    flex-wrap: wrap;
  }

  .ytg-modal-subscribe {
    width: 100%;
    justify-content: center;
  }
}
