/* ═══════════════════════════════════════════
   VISOR DE DOCUMENTOS — styles.css
   ═══════════════════════════════════════════ */

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

/* ── VARIABLES GLOBALES ── */
:root {
  --sidebar-width:    280px;
  --note-width:       260px;
  --toolbar-height:   56px;
  --bg-app:           #F4F2EE;
  --bg-sidebar:       #FFFFFF;
  --bg-viewer:        #ECEAE4;
  --bg-toolbar:       #FFFFFF;
  --bg-note:          #FDFCF8;
  --border:           #E3E1DB;
  --text-primary:     #1A1916;
  --text-secondary:   #6B6860;
  --text-muted:       #9B9A97;
  --accent:           #534AB7;
  --accent-light:     #EEEDFE;
  --accent-text:      #3C3489;
  --note-accent:      #3B6D11;
  --note-accent-bg:   #EAF3DE;
  --note-accent-text: #27500A;
  --shadow:           0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ── BASE ── */
html, body {
  height: 100%;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT PRINCIPAL ── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

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

.sidebar-header {
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 1rem;
}

.sidebar-logo .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-logo .logo-icon i { color: white; font-size: 16px; }
.sidebar-logo span          { font-size: 15px; font-weight: 600; }

/* Búsqueda */
.search-box { position: relative; }

.search-box i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: 7px 10px 7px 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  background: #F7F6F3;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.search-box input:focus       { border-color: var(--accent); background: white; }
.search-box input::placeholder { color: var(--text-muted); }

.section-label {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Lista */
.doc-list { flex: 1; overflow-y: auto; padding-bottom: 1rem; }
.doc-list::-webkit-scrollbar       { width: 4px; }
.doc-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.no-results {
  padding: 1rem;
  color: var(--text-muted);
  font-size: 13px;
}

/* Ítem de documento */
.doc-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 0.625rem 1rem;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  color: inherit;
  user-select: none;
}

.doc-item:hover  { background: #F7F6F3; }

.doc-item.active {
  background: var(--accent-light);
  border-left-color: var(--accent);
}

.doc-icon {
  width: 34px;
  height: 38px;
  border-radius: 5px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
  color: var(--accent);
  border: 1px solid rgba(83, 74, 183, 0.15);
}

.doc-item.active .doc-icon {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.doc-info   { flex: 1; min-width: 0; }

.doc-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: normal;
  word-break: break-word;
  line-height: 1.4;
  margin-bottom: 3px;
}

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

.doc-badges {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
}

/* Etiqueta de categoría */
.doc-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
}

.tag-contract { background: #EEEDFE; color: #3C3489; }
.tag-report   { background: #E1F5EE; color: #085041; }
.tag-policy   { background: #FAECE7; color: #712B13; }
.tag-finance  { background: #E6F1FB; color: #0C447C; }
.tag-other    { background: #F1EFE8; color: #444441; }

/* Insignia de nota */
.note-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--note-accent-bg);
  color: var(--note-accent);
  font-size: 11px;
}

/* ════════════════════════════════════════
   VISOR PRINCIPAL (centro)
   ════════════════════════════════════════ */
.viewer {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-viewer);
  min-width: 0;
}

/* Toolbar */
.viewer-toolbar {
  height: var(--toolbar-height);
  background: var(--bg-toolbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  gap: 1rem;
  flex-shrink: 0;
}

.toolbar-info .doc-name { font-size: 14px; font-weight: 500; }
.toolbar-info .doc-date { font-size: 12px; color: var(--text-muted); }

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 2px;
}

/* Botones de herramienta */
.btn-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  font-size: 16px;
}

.btn-tool:hover {
  background: #F0EEE8;
  border-color: var(--border);
  color: var(--text-primary);
}

.btn-tool.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-tool.primary:hover {
  background: var(--accent-text);
  border-color: var(--accent-text);
}

.zoom-display {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 38px;
  text-align: center;
}

/* Scroll del visor */
.viewer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.viewer-scroll::-webkit-scrollbar       { width: 6px; }
.viewer-scroll::-webkit-scrollbar-thumb { background: #C8C6C0; border-radius: 4px; }

/* Estado vacío */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 0.75rem;
  padding: 3rem;
  text-align: center;
}

.empty-state i    { font-size: 52px; opacity: 0.25; }
.empty-state h3   { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.empty-state p    { font-size: 13px; max-width: 240px; line-height: 1.6; }

/* Contenedor del PDF */
.pdf-wrapper {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pdf-iframe-container {
  background: white;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.pdf-iframe-container iframe {
  display: block;
  width: 100%;
  height: 80vh;
  border: none;
}

/* Barra de estado */
.statusbar {
  height: 32px;
  background: var(--bg-toolbar);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.statusbar span        { display: flex; align-items: center; gap: 4px; }
.statusbar .status-right { margin-left: auto; }

/* ════════════════════════════════════════
   PANEL DE NOTA PERSONAL (derecha)
   ════════════════════════════════════════ */
.note-panel {
  width: var(--note-width);
  min-width: var(--note-width);
  background: var(--bg-note);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Cabecera del panel */
.note-header {
  height: var(--toolbar-height);
  padding: 0 0.75rem 0 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.note-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--note-accent);
}

.note-title i { font-size: 16px; }

/* Área del textarea */
.note-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.875rem 1rem;
  overflow: hidden;
}

.note-body textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.65;
  /*color: var(--text-primary);*/
   color: darkred;
  background: white;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.note-body textarea:focus {
  border-color: var(--note-accent);
  box-shadow: 0 0 0 3px rgba(59, 109, 17, 0.1);
   color: var(--text-primary);
}

.note-body textarea::placeholder { color: var(--text-muted); }

.note-body textarea:disabled {
  background: #F7F6F3;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Pie del panel */
.note-footer {
  padding: 0.625rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
}

.note-hint {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-muted);
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 10px;
  font-family: inherit;
  background: #F7F6F3;
  color: var(--text-secondary);
  line-height: 1.4;
}

.note-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.char-count {
  font-size: 10px;
  color: var(--text-muted);
}

.note-status {
  font-size: 11px;
  font-weight: 500;
  color: var(--note-accent);
  min-width: 60px;
  text-align: right;
}

/* Botón guardar */
.btn-save {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn-save i { font-size: 14px; }

.btn-save:hover {
  background: #F0EEE8;
  color: var(--text-primary);
}

/* Estado "sin guardar" — resalta el botón en verde */
.btn-save.dirty {
  background: var(--note-accent-bg);
  border-color: var(--note-accent);
  color: var(--note-accent-text);
}

.btn-save.dirty:hover {
  background: #C0DD97;
}
