/* Nostr Box Widget Sidebar Styles */
#sidebar {
  position: fixed;
  top: 180px;
  right: 25px;
  width: 258px;
  max-height: 77.4vh;
  background: linear-gradient(145deg, #1c1c1c, #3a3a3a);
  border-radius: 16px;
  box-shadow: 0 0 18px rgba(136, 136, 136, 0.8); /* Improved RGBA syntax */
  padding: 17px;
  display: flex;
  flex-direction: column;
  align-items: center;
  backdrop-filter: blur(10px);
  transform-origin: top right;
  transform: scale(0.86);
  z-index: 2000;
  transition: all 0.3s;
  overflow: hidden; /* Prevent content overflow */
}

#sidebar::before {
  content: "";
  position: absolute;
  top: -8px; 
  right: -8px; 
  bottom: -8px; 
  left: -8px;
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(170, 170, 170, 0.8); /* Improved RGBA syntax */
  z-index: -1;
}

#sidebar-toggle {
  padding: 12px;
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #ccc;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  z-index: 1001;
  transition: color 0.3s;
}

#sidebar-toggle:hover {
  color: #fff;
}

#sidebar.minimized {
  width: 56px !important;
  height: 56px !important;
  border-radius: 50% !important;
  padding: 0 !important;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #111;
  box-shadow: 0 0 10px #222;
  transform: none;
  cursor: pointer;
}

#sidebar.minimized #sidebar-toggle,
#sidebar.minimized > *:not(#header-link) {
  display: none !important;
}

#sidebar.minimized #header-link {
  font-size: 0.65rem;
  pointer-events: none;
  margin: 0;
  text-align: center;
}

#header-link {
  font-weight: 800;
  font-size: 1.38rem;
  color: #fff;
  text-decoration: none;
  user-select: none;
  font-family: 'Segoe UI Black', sans-serif;
  margin-bottom: 14px;
  width: 100%;
  text-align: center;
  transition: color 0.3s; /* Smooth color transition */
}

/* Per-letter NEWS! coloring */
#header-link .news-letter {
  display: inline-block;
  letter-spacing: 0;
  /* User request: make NEWS! one consistent sky-blue */
  color: #5aa9ff;
  text-shadow: none;
}

#header-link:hover {
  color: #bbb;
}

#nostr-feed {
  width: 100%;
  display: none;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.post {
  background: #2e2e2e;
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 0 12px rgba(85, 85, 85, 0.8); /* Improved RGBA syntax */
  color: #f2f2f2;
  font-size: 0.96rem;
  line-height: 1.55;
  max-height: 275px;
  overflow-y: auto;
  word-wrap: break-word;
  white-space: pre-line; /* Preserve line breaks */
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-weight: 500;
}

.post a {
  color: #80d4ff;
  text-decoration: underline;
  word-break: break-word;
  transition: color 0.2s; /* Smooth color transition */
}

.post a:hover {
  color: #b3e6ff; /* Lighter blue on hover */
  text-decoration: none;
}

.post small {
  display: block;
  margin-top: 7px;
  font-size: 0.65rem;
  color: #999;
  text-align: right;
}

/* Add tag filtering indicator */
.widget-tag {
  display: inline-flex;
  background: #FF6666;
  color: #000;
  font-size: 0.7em;
  padding: 2px 6px;
  border-radius: 3px;
  margin: 5px 0 0 5px; /* Better spacing */
  font-weight: bold;
   align-self: flex-end; /* Positions to the right */
}

img, video {
  max-width: 100%;
  border-radius: 10px;
  margin-top: 10px;
  display: block;
  box-shadow: 0 0 8px rgba(102, 102, 102, 0.67); /* Improved RGBA syntax */
  transition: transform 0.3s; /* Smooth hover effect */
}

img:hover, video:hover {
  transform: scale(1.02); /* Slight zoom on hover */
}

video {
  max-height: 224px;
}

#nostr-fallback {
  display: none;
  text-align: center;
}

#qr-code {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

#qr-code canvas {
  border-radius: 12px;
  /* Remove the "glow" around the QR code (requested). */
  box-shadow: none !important;
  outline: none !important;
  border: none !important;
  width: 120px !important;
  height: 120px !important;
  transition: transform 0.3s; /* Smooth hover effect */
}

#qr-code canvas:hover {
  transform: none;
}

#nip05-id {
  margin-top: 10px;
  font-size: 0.75rem;
  color: #ccc;
}

#nostr-network-link {
  margin-top: 18px;
  font-size: 0.589rem;
  text-align: center;
  width: 100%;
  transform-origin: center;
  transform: scale(0.86);
}

#nostr-network-link a {
  display: inline-block;
  padding: 6px 14px;
  border: 2px solid #bbb;
  border-radius: 12px;
  color: #ddd;
  text-decoration: none;
  font-weight: 600;
  font-family: 'Segoe UI', sans-serif;
  transition: all 0.25s; /* Transition all properties */
}

#nostr-network-link a:hover {
  background-color: #ddd;
  color: #222;
  border-color: #eee;
  transform: scale(1.05); /* Slight zoom on hover */
}

#nostr-loading {
  display: none;
}

@media (max-width: 600px) {
  #sidebar {
    bottom: 20px;
    top: auto;
    /* Minimized widget should sit bottom-right for thumb reach */
    right: 14px;
    left: auto;
    width: auto;
  }

  #sidebar.expanded {
    /* Open as a right-side panel (not full-screen) */
    width: 82vw;
    max-width: 460px;
    height: 58vh;
    max-height: 60vh;
    bottom: auto;
    top: 92px;
    right: 14px;
    left: auto;
    border-radius: 16px;
    padding: 16px;
    background: linear-gradient(145deg, #1c1c1c, #3a3a3a);
    box-shadow: 0 0 18px rgba(136, 136, 136, 0.8); /* Improved RGBA syntax */
    transform: none;
    overflow-y: auto;
  }

  #sidebar.expanded #header-link {
    font-size: 1.6rem;
    margin-bottom: 14px;
  }

  #sidebar.expanded #nostr-feed,
  #sidebar.expanded #nostr-network-link {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
  }

  /* Let the feed fill the available height inside the expanded panel */
  #sidebar.expanded #nostr-feed {
    flex: 1 1 auto;
    min-height: 0;
  }

  #sidebar.expanded #nostr-fallback #nip05-id {
    display: none;
  }

  #sidebar.expanded #nostr-fallback {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  /* Mobile-specific adjustments */
  .post {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    padding: 10px; /* Tighter padding */
    font-size: 0.8rem; /* Slightly larger text */
  }
  
  .widget-tag {
    font-size: 0.6em; /* Smaller tag on mobile */
  }
}