/* ── NicoDoc App Styles ───────────────────────────────── */

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  overflow: hidden;
  height: 100vh;
}

/* ── Header ────────────────────────────────────────────── */
.nicodoc-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 600;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-left, .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-center {
  flex: 1;
  text-align: center;
}

.logo {
  font-size: 1rem;
  font-weight: 700;
  color: #FFB300;
  letter-spacing: -0.3px;
}

.doc-title {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* ── PDF Viewer ────────────────────────────────────────── */
#pdf-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: auto;
  padding: 12px;
  background: rgba(0,0,0,0.2);
}

#pdf-canvas {
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
  border-radius: 2px;
}

.text-layer {
  position: absolute;
  top: 0; left: 0;
  pointer-events: all;
  opacity: 0.25;
}

.annotation-layer {
  position: absolute;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 2;
}

/* ── Annotation tool buttons ─────────────────────────── */
.pdf-tool-btn {
  padding: 3px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.pdf-tool-btn:hover {
  background: rgba(255,255,255,0.1);
}
.pdf-tool-btn.active {
  color: #FFB300;
  background: rgba(255,179,0,0.15);
}

/* ── Visual annotation overlays ──────────────────────── */
.annotation-highlight {
  position: absolute;
  border-radius: 2px;
  pointer-events: all;
  cursor: pointer;
  transition: background 0.15s;
}
.annotation-highlight:hover {
  filter: brightness(1.3);
}

.annotation-underline {
  position: absolute;
  border-bottom: 2px solid;
  pointer-events: all;
  cursor: pointer;
  transition: border-color 0.15s;
}
.annotation-underline:hover {
  border-bottom-width: 3px;
}

.annotation-note-marker {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #1a1a2e;
  pointer-events: all;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  z-index: 3;
  transition: transform 0.15s;
}
.annotation-note-marker:hover {
  transform: scale(1.2);
}

/* Tooltip on hover */
.annotation-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.72rem;
  color: #e2e8f0;
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
}
.annotation-highlight:hover .annotation-tooltip,
.annotation-underline:hover .annotation-tooltip,
.annotation-note-marker:hover .annotation-tooltip {
  opacity: 1;
}

/* Selection highlight during text selection with a tool */
.text-layer-selecting {
  cursor: crosshair !important;
}
.text-layer-selecting span {
  cursor: crosshair !important;
}

#page-info {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  padding: 0 8px;
  white-space: nowrap;
}

/* ── Annotations Panel ─────────────────────────────────── */
.annotation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
}

.annotation-item {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.82rem;
}
.annotation-item:hover {
  background: rgba(255,255,255,0.08);
}

.annotation-item .annotation-page {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
}

.annotation-item .annotation-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.65rem;
  text-transform: uppercase;
  margin-right: 4px;
}
.annotation-type.note { background: rgba(99,102,241,0.2); color: #818cf8; }
.annotation-type.highlight { background: rgba(255,235,59,0.2); color: #FFEB3B; }
.annotation-type.underline { background: rgba(255,152,0,0.2); color: #FF9800; }
.annotation-type.bookmark { background: rgba(16,185,129,0.2); color: #10b981; }

/* ── Chat Panel ────────────────────────────────────────── */
.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.chat-msg {
  max-width: 86%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.5;
  word-break: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: #FFB300;
  color: #1a1a2e;
  border-bottom-right-radius: 3px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  border-bottom-left-radius: 3px;
}
.chat-msg.system {
  align-self: center;
  font-size: 0.72rem;
  opacity: 0.5;
  font-style: italic;
}
.chat-msg.thinking {
  opacity: 0.5;
  font-style: italic;
}
.chat-msg.action {
  align-self: center;
  font-size: 0.72rem;
  color: #FFB300;
  background: rgba(255,179,0,0.08);
  border: 1px solid rgba(255,179,0,0.15);
  border-radius: 8px;
  padding: 4px 12px;
  font-style: italic;
}

/* Markdown in chat */
.chat-msg.assistant p { margin: 0 0 6px; }
.chat-msg.assistant p:last-child { margin-bottom: 0; }
.chat-msg.assistant code {
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
}
.chat-msg.assistant pre {
  background: rgba(0,0,0,0.35);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  margin: 6px 0;
}
.chat-msg.assistant ul, .chat-msg.assistant ol {
  margin: 4px 0;
  padding-left: 20px;
}
.chat-msg.assistant h1, .chat-msg.assistant h2, .chat-msg.assistant h3 {
  margin: 8px 0 4px;
  font-size: 0.9rem;
}

.chat-input-area {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 7px 10px;
  color: #e2e8f0;
  font-size: 0.82rem;
  resize: none;
  font-family: inherit;
  max-height: 120px;
  outline: none;
}
.chat-input-area textarea:focus {
  border-color: #FFB300;
}

.chat-input-area .btn {
  flex-shrink: 0;
  height: 34px;
}

/* ── Summary Panel ─────────────────────────────────────── */
#summary-content {
  padding: 12px;
  font-size: 0.85rem;
  line-height: 1.6;
}
#summary-content h1, #summary-content h2, #summary-content h3 {
  margin: 10px 0 6px;
}
#summary-content ul, #summary-content ol {
  padding-left: 20px;
  margin: 6px 0;
}
#summary-content p {
  margin: 0 0 8px;
}

/* ── Music Panel ───────────────────────────────────────── */
.music-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.music-player input[type="range"] {
  flex: 1;
  accent-color: #FFB300;
}
.music-player select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #e2e8f0;
  padding: 4px 8px;
  font-size: 0.78rem;
}

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 700;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f8fafc;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ── Document List ─────────────────────────────────────── */
.document-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 16px;
}

.document-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.15s;
}
.document-item:hover {
  background: rgba(255,255,255,0.08);
}
.document-item .doc-icon {
  color: #ef4444;
  flex-shrink: 0;
}
.document-item .doc-info {
  flex: 1;
  min-width: 0;
}
.document-item .doc-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.document-item .doc-meta {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
}
.document-item .doc-actions {
  display: flex;
  gap: 4px;
}

/* ── File Upload Zone ──────────────────────────────────── */
.file-upload {
  border: 2px dashed rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.file-upload:hover, .file-upload.dragover {
  border-color: #FFB300;
  background: rgba(255,179,0,0.05);
}
.file-upload-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.3);
}
.file-upload-text {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
}

/* ── Dropdown ──────────────────────────────────────────── */
.dropdown {
  position: relative;
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 4px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 650;
}
.dropdown-menu.hidden { display: none; }
.dropdown-item {
  display: block;
  padding: 8px 12px;
  border-radius: 4px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown-item:hover {
  background: rgba(255,255,255,0.08);
}
.dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 4px 0;
}

/* ── Select ────────────────────────────────────────────── */
.select {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: #e2e8f0;
  padding: 4px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  outline: none;
}

/* ── Conversation History ──────────────────────────────── */
.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  overflow-y: auto;
}

.chat-conv-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.chat-conv-item:hover {
  background: rgba(255,255,255,0.08);
}
.chat-conv-item.active {
  background: rgba(255,179,0,0.15);
}
.chat-conv-title {
  flex: 1;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-conv-meta {
  font-size: 0.7rem;
  opacity: 0.45;
}

/* ── Text helpers ──────────────────────────────────────── */
.text-secondary { color: rgba(255,255,255,0.5); }
.hidden { display: none !important; }

/* ── Liminal Cursor ────────────────────────────────────── */
#liminal-cursor {
  position: fixed;
  width: 24px;
  height: 24px;
  pointer-events: none;
  z-index: 9999;
  display: none;
}
