/*
 * AEGIS Subject Log Viewer Styles
 * Dark theme, utilitarian, internal tool aesthetic
 */

:root {
  /* Base colors - cooler, more utilitarian than corporate */
  --bg-primary: #12151e;
  --bg-secondary: #181c27;
  --bg-tertiary: #1e2330;
  --bg-hover: #252a38;
  --bg-active: #2a3042;

  /* Text colors */
  --text-primary: #e8eaed;
  --text-secondary: #9aa0ad;
  --text-muted: #6b7280;
  --text-dim: #4b5563;

  /* Entry type border colors - muted, subtle */
  --border-log: #4a90a4;
  --border-system: #a89444;
  --border-researcher: #5a9a6a;

  /* UI accents */
  --border-default: #2d3344;
  --border-light: #3d4455;

  /* Typography */
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Sizing */
  --header-height: 64px;
  --sidebar-width: 340px;
  --content-max-width: 72ch;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tool-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.version {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-left: 8px;
  cursor: pointer;
}

.version:hover {
  color: var(--text-secondary);
}

.internal-notice {
  font-size: 0.6875rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.header-right {
  text-align: right;
}

.subject-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
}

.subject-id {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.backup-date {
  font-size: 0.6875rem;
  color: var(--text-dim);
}

/* Main layout */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.entry-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Custom scrollbar */
.entry-list::-webkit-scrollbar {
  width: 8px;
}

.entry-list::-webkit-scrollbar-track {
  background: transparent;
}

.entry-list::-webkit-scrollbar-thumb {
  background: var(--border-default);
  border-radius: 4px;
}

.entry-list::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* Entry list items */
.entry-item {
  display: block;
  padding: 12px 16px 12px 14px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.1s ease;
}

.entry-item:hover {
  background: var(--bg-hover);
}

.entry-item.active {
  background: var(--bg-active);
}

/* Entry type borders */
.entry-item[data-type="log_entry"] {
  border-left-color: var(--border-log);
}

.entry-item[data-type="system_annotation"] {
  border-left-color: var(--border-system);
}

.entry-item[data-type="researcher_note"] {
  border-left-color: var(--border-researcher);
}

.entry-item-line1 {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-item-line2 {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

/* Content area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
}

/* Navigation buttons */
.content-nav {
  display: flex;
  justify-content: space-between;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.top-nav {
  margin-bottom: 24px;
}

.bottom-nav {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-default);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--text-primary);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.nav-arrow {
  font-size: 1rem;
}

/* Entry container */
.entry-container {
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* Entry header/metadata */
.entry-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-default);
}

.entry-type-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.entry-type-label[data-type="log_entry"] {
  color: var(--border-log);
}

.entry-type-label[data-type="system_annotation"] {
  color: var(--border-system);
}

.entry-type-label[data-type="researcher_note"] {
  color: var(--border-researcher);
}

.entry-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.meta-item {
  display: flex;
  gap: 6px;
}

.meta-label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.meta-value {
  color: var(--text-muted);
}

/* Entry body */
.entry-body {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.75;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.entry-body.empty {
  color: var(--text-dim);
  font-style: italic;
}

/* Footer */
.footer {
  padding: 12px 24px;
  border-top: 1px solid var(--border-default);
  background: var(--bg-secondary);
}

.fiction-notice {
  font-size: 0.6875rem;
  color: var(--text-dim);
  text-decoration: none;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.fiction-notice:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 280px;
  }

  .content {
    padding: 24px 32px;
  }
}

@media (max-width: 768px) {
  .main {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border-default);
  }

  .content {
    padding: 20px;
  }

  .header {
    padding: 0 16px;
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .header-right {
    order: -1;
    width: 100%;
    text-align: left;
  }

  .subject-info {
    flex-direction: row;
    gap: 12px;
    align-items: center;
  }

  .nav-label {
    display: none;
  }

  .nav-btn {
    padding: 8px 12px;
  }
}

/* Focus states for accessibility */
.entry-item:focus,
.nav-btn:focus {
  outline: 2px solid var(--border-log);
  outline-offset: -2px;
}

/* Selection styling */
::selection {
  background: rgba(74, 144, 164, 0.3);
  color: var(--text-primary);
}

/* Flag indicator */
.flag-indicator {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--text-dim);
  border-radius: 50%;
  margin-left: 8px;
  vertical-align: middle;
  opacity: 0.7;
}

.entry-item.active .flag-indicator {
  opacity: 1;
}

/* Changelog Modal */
.changelog-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.changelog-modal.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.changelog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.changelog-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.changelog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default);
}

.changelog-header h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.changelog-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.changelog-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.changelog-body {
  overflow-y: auto;
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
}

.changelog-entry {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-default);
}

.changelog-entry:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.changelog-version-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.changelog-version {
  font-weight: 500;
  color: var(--text-primary);
}

.changelog-date {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.changelog-author {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.changelog-changes {
  margin: 0;
  padding-left: 16px;
  color: var(--text-secondary);
}

.changelog-changes li {
  margin-bottom: 4px;
}

.changelog-changes li:last-child {
  margin-bottom: 0;
}
