/* Research Reports Reader Styles */

/* Workspace Layout */
.research-workspace {
  display: grid;
  grid-template-columns: 320px 18px minmax(0, 1fr);
  gap: 0;
  height: calc(100vh - 50px);
  min-height: calc(100vh - 50px);
}

/* Sidebar */
.research-sidebar {
  position: relative;
  background: var(--bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 50px);
}

/* Tag Filters */
.research-tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 72px;
  overflow: auto;
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}

.research-tag-filter {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  transition: background 150ms ease, border-color 150ms ease;
}

.research-tag-filter:hover {
  background: var(--bg-subtle);
}

.research-tag-filter.active {
  background: var(--brand-soft);
  border-color: var(--brand);
}

/* Collapsed sidebar state (desktop only) */
.research-workspace.collapsed {
  grid-template-columns: 0 18px minmax(0, 1fr);
}

.research-workspace.collapsed .research-sidebar {
  width: 0;
  overflow: hidden;
  min-width: 0;
}

/* Sidebar Divider */
.research-sidebar-divider {
  position: relative;
  width: 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.research-sidebar-divider-line {
  position: absolute;
  inset: 0 auto 0 50%;
  width: 1px;
  background: var(--border);
  transform: translateX(-50%);
}

.research-sidebar-divider-toggle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.6rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: 16px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.research-sidebar-divider:hover .research-sidebar-divider-line {
  background: var(--brand);
}

.research-sidebar-divider:hover .research-sidebar-divider-toggle {
  border-color: var(--brand);
  color: var(--brand);
}

.research-search {
  padding: 12px 16px 8px;
}

.research-search input {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 2px;
  padding: 0.55rem 0.8rem;
  color: var(--text);
  font-size: 0.8125rem;
  transition: border-color 150ms ease;
  font-family: inherit;
}

.research-search input:focus {
  outline: none;
  border-color: var(--brand);
}

#reportCount {
  padding: 0 16px 8px;
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

.research-report-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 84px;
}

/* Folder Groups */
.research-folder-group {
  border-bottom: 1px solid var(--border);
}

.research-folder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 6px;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  font-family: var(--mono);
  font-weight: 600;
}

.research-folder-count {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* File Items */
.research-report-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 16px 8px 12px;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--text);
  transition: all 150ms ease;
}

.research-report-item:hover {
  background: var(--bg-subtle);
}

.research-report-item.active {
  background: var(--brand-soft);
  border-left-color: var(--brand);
}

.research-report-name {
  display: block;
  line-height: 1.4;
  word-break: break-word;
}

.research-report-open {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
  padding: 0;
  text-align: left;
}

.research-favorite-toggle {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  transition: color 150ms ease, background 150ms ease;
}

.research-favorite-toggle:hover {
  color: var(--brand);
  background: var(--bg-subtle);
}

.research-favorite-toggle.active {
  color: var(--brand);
}

.research-favorite-toggle:focus-visible,
.research-report-open:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.research-report-meta {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 2px;
  font-family: var(--mono);
}

/* Reader Panel */
.research-detail-panel {
  position: relative;
  min-height: 0;
  height: 100%;
}

.research-detail {
  height: 100%;
  min-height: 0;
  padding: 24px 32px 96px;
  overflow-y: auto;
  background: var(--bg);
}

.panel-scroll-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-scroll-controls[hidden] {
  display: none;
}

.panel-scroll-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition:
    transform 150ms ease,
    opacity 150ms ease,
    background 150ms ease,
    border-color 150ms ease;
}

.panel-scroll-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--brand);
  background: #fff;
}

.panel-scroll-button:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.research-reader-header {
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.research-reader-header h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
}

.research-reader-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.research-reader-links[hidden] {
  display: none;
}

.research-reader-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  color: var(--brand);
  background: var(--bg-subtle);
  text-decoration: none;
  font-size: 0.8125rem;
  transition: border-color 150ms ease, background 150ms ease;
}

.research-reader-link:hover {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.research-reader-meta {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: var(--mono);
}

/* Reader Content Typography */
.research-reader-content {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--text);
}

.research-reader-content h1 {
  font-size: 1.5rem;
  margin: 24px 0 12px;
  font-weight: 600;
  line-height: 1.3;
}

.research-reader-content h2 {
  font-size: 1.25rem;
  margin: 20px 0 10px;
  font-weight: 600;
  line-height: 1.3;
}

.research-reader-content h3 {
  font-size: 1.1rem;
  margin: 16px 0 8px;
  font-weight: 600;
}

.research-reader-content h4,
.research-reader-content h5,
.research-reader-content h6 {
  font-size: 1rem;
  margin: 12px 0 6px;
  font-weight: 600;
}

.research-reader-content p {
  margin: 0 0 12px;
}

.research-reader-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.875rem;
}

.research-reader-content th,
.research-reader-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.research-reader-content th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.research-reader-content blockquote {
  margin: 0 0 12px;
  padding: 8px 16px;
  border-left: 3px solid var(--brand);
  color: var(--muted);
  background: var(--bg-subtle);
  border-radius: 2px;
}

.research-reader-content pre {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 16px;
  overflow-x: auto;
  font-size: 0.8125rem;
  margin: 12px 0;
  font-family: var(--mono);
}

.research-reader-content code {
  font-family: var(--mono);
  font-size: 0.8125rem;
  background: var(--bg-subtle);
  padding: 2px 4px;
  border-radius: 2px;
}

.research-reader-content pre code {
  background: none;
  padding: 0;
}

.research-reader-content img {
  max-width: 100%;
  border-radius: 2px;
  margin: 12px 0;
}

.research-reader-content iframe {
  max-width: 100%;
}

.research-reader-content a {
  color: var(--brand);
  text-decoration: underline;
}

.research-reader-content a:hover {
  opacity: 0.8;
}

.research-reader-content ul,
.research-reader-content ol {
  padding-left: 24px;
  margin: 0 0 12px;
}

.research-reader-content li {
  margin: 4px 0;
}

.research-reader-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.research-reader-content strong {
  font-weight: 600;
}

/* Empty State */
.research-empty-state {
  display: grid;
  place-items: center;
  min-height: 52vh;
  text-align: center;
}

.research-empty-state-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 360px;
}

.research-empty-state h2 {
  font-size: 1rem;
  color: var(--muted);
  margin: 0;
}

.research-empty-state p {
  font-size: 0.8125rem;
  color: var(--muted);
  font-family: var(--mono);
  margin: 0;
}

/* Mobile Sidebar Toggle (hidden on desktop) */
.research-sidebar-toggle {
  display: none;
}

/* Mobile Backdrop */
.research-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 45;
}

/* Responsive: Tablet */
@media (max-width: 980px) {
  .research-workspace {
    grid-template-columns: 280px 18px minmax(0, 1fr);
  }
}

/* Responsive: Mobile (6.7" Android ~412px) */
@media (max-width: 480px) {
  .research-workspace {
    grid-template-columns: 1fr;
    height: calc(100vh - 50px);
    min-height: calc(100vh - 50px);
  }

  .research-sidebar-divider {
    display: none;
  }

  .research-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 360px;
    height: 100%;
    z-index: 50;
    transform: translateX(-100%);
     transition: transform 200ms ease;
     padding-top: 56px;
     min-height: 0;
     box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
   }

  .research-sidebar.open {
    transform: translateX(0);
  }

  .research-sidebar-toggle {
    display: flex;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 30;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    font-size: 1.3rem;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 150ms ease;
  }

  .research-sidebar-toggle:active {
    opacity: 0.8;
  }

  .research-detail {
    padding: 16px 12px;
    padding-bottom: 88px;
  }

  .panel-scroll-controls {
    right: 12px;
    bottom: 12px;
  }

  .panel-scroll-button {
    width: 40px;
    height: 40px;
  }

  .research-reader-header h2 {
    font-size: 1.1rem;
  }

  .research-report-item {
    min-height: 44px;
    padding: 10px 16px 10px 12px;
  }

  .research-report-open {
    font-size: 0.8rem;
  }

  .research-favorite-toggle {
    width: 28px;
    height: 28px;
    font-size: 1.05rem;
  }

  .research-search input {
    font-size: 16px;
    min-height: 44px;
  }

  .research-reader-content {
    font-size: 0.875rem;
    line-height: 1.7;
  }

  .research-reader-content h1 { font-size: 1.25rem; }
  .research-reader-content h2 { font-size: 1.1rem; }
  .research-reader-content h3 { font-size: 1rem; }

  .research-reader-content table {
    font-size: 0.75rem;
  }

  .research-reader-content th,
  .research-reader-content td {
    padding: 6px 8px;
  }

  .research-reader-content pre {
    font-size: 0.75rem;
    padding: 12px;
  }

  .research-empty-state {
    min-height: 40vh;
  }
}
