/* viewer.css - Online Reader App Styles */

body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.viewer-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  padding: 16px;
  gap: 16px;
  position: relative;
  z-index: 2;
}

/* Sidebar */
.viewer-sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  height: 100%;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border-glass);
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
}

.sidebar-logo-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.sidebar-channels-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-channels-list::-webkit-scrollbar {
  width: 6px;
}

.sidebar-channels-list::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 3px;
}

.sidebar-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.01);
}

.channel-item:hover {
  background: rgba(255, 255, 255, 0.04);
  transform: translateX(-2px);
}

.channel-item.active {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
}

.channel-item-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.channel-item-name {
  font-size: 14px;
  font-weight: 600;
  flex: 1;
}

/* Main Area */
.viewer-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.viewer-header {
  height: 72px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.menu-toggle-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
}

.active-channel-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-channel-icon {
  font-size: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.active-channel-meta h2 {
  font-size: 16px;
  font-weight: 700;
}

.active-channel-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

/* Tabs Bar */
.viewer-tabs-bar {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 12px;
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

.viewer-tabs-bar::-webkit-scrollbar {
  display: none;
}

.viewer-tab {
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.viewer-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.viewer-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* Pinned Bar */
.viewer-pinned-bar {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
  overflow: hidden;
  cursor: pointer;
}

.pinned-label {
  font-weight: 700;
  color: #f59e0b;
  font-size: 12px;
  white-space: nowrap;
}

.pinned-messages {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Feed */
.viewer-feed {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.viewer-feed::-webkit-scrollbar {
  width: 8px;
}

.viewer-feed::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 4px;
}

.feed-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 40px;
}

.placeholder-icon {
  font-size: 64px;
  margin-bottom: 20px;
  opacity: 0.5;
}

.feed-placeholder h3 {
  font-size: 20px;
  margin-bottom: 10px;
  color: var(--text);
}

/* Messages Cards */
.msg-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0.3;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.15s;
  will-change: transform, opacity;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.msg-card.scroll-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.msg-card.scroll-visible:hover {
  transform: translateY(-2px) scale(1);
  border-color: rgba(59, 130, 246, 0.3);
}

.msg-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.msg-author-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.msg-author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.msg-author {
  font-weight: 700;
  font-size: 14px;
}

.msg-time {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-text {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Markdown classes */
.msg-text strong {
  font-weight: 700;
}

.msg-text em {
  font-style: italic;
}

.msg-text code {
  background: rgba(214, 51, 132, 0.1);
  color: #D63384;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}

.msg-divider {
  border: none;
  border-top: 1px solid var(--border-glass);
  margin: 8px 0;
}

.msg-title-header {
  display: block;
  font-weight: 800;
  margin-bottom: 6px;
  color: var(--text);
}

.msg-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.msg-link:hover {
  text-decoration: underline;
}

.msg-media {
  margin-top: 8px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-glass);
}

.msg-media img {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.msg-media video {
  width: 100%;
  display: block;
}

.msg-media audio {
  width: 100%;
  display: block;
  outline: none;
  background: var(--bg-secondary);
}

.msg-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-glass);
  padding-top: 12px;
  margin-top: 8px;
}

.msg-views {
  font-size: 11px;
  color: var(--text-muted);
}

.msg-reactions {
  display: flex;
  gap: 6px;
}

.msg-reaction-pill {
  padding: 4px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.msg-reaction-pill:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Read More */
.read-more-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  padding: 4px 0;
  display: block;
}

/* Bottom Ticker Ad */
.viewer-footer-ad {
  height: 40px;
  display: flex;
  align-items: center;
  overflow: hidden;
  margin-top: 12px;
  padding: 0 20px;
  flex-shrink: 0;
}

.ticker-text-wrapper {
  white-space: nowrap;
  display: inline-block;
  animation: marquee 25s linear infinite;
  font-size: 12px;
  color: var(--text-muted);
}

@keyframes marquee {
  0% { transform: translate3d(100%, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

/* Loading / Empty States */
.loading-spinner {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  .viewer-layout {
    flex-direction: column;
    padding: 8px;
    gap: 8px;
  }

  .viewer-sidebar {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: calc(100% - 16px);
    height: calc(100% - 16px);
    z-index: 100;
  }

  .viewer-sidebar.show {
    display: flex;
  }

  .menu-toggle-btn {
    display: block;
  }
}

/* Scrollbar to match extension styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  display: block;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 6px;
  border: 2px solid var(--bg-secondary);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Auto Update highlight animation for new messages */
@keyframes new-message-highlight {
  0% {
    background-color: rgba(59, 130, 246, 0.18);
    transform: translateY(-20px);
    opacity: 0;
  }
  10% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    background-color: var(--bg-glass);
  }
}

.msg-card.new-message-animation {
  animation: new-message-highlight 4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
