/* ============================================
   PANEL STYLES — Estilos del sistema de panel lateral
   Depende de las variables definidas en styles.css
   ============================================ */

/* ============================================
   SIDEBAR — Barra lateral estilo Notion
   Fija a la izquierda, todo el alto de pantalla
   ============================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background-color: var(--gray-lt);
  border-right: 1px solid #E0E0E0;
  display: flex;
  flex-direction: column;
  padding: 16px 8px;
  z-index: 60;
  gap: 0;
}

.sidebar-logo {
  position: absolute;
  bottom: 24px;
  left: 8px;
  height: 32px;
  width: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.12s;
  user-select: none;
}

.sidebar-item:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.sidebar-item.active {
  background-color: rgba(0, 0, 0, 0.06);
}

.sidebar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--gray);
  flex-shrink: 0;
}

.sidebar-item.active .sidebar-icon {
  color: var(--navy);
}

.sidebar-label {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: #374151;
}

.sidebar-item.active .sidebar-label {
  color: var(--navy);
}

.sidebar-separator {
  height: 8px;
}

/* ============================================
   SIDEBAR PAGES — Páginas completas de herramientas
   Se muestran al lado de la sidebar, ocupan todo el espacio
   ============================================ */

.sidebar-page {
  display: flex;
  flex-direction: column;
  padding: 48px 32px;
  width: 100%;
  position: fixed;
  left: 260px;
  top: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  /* Ocultar scrollbar nativo — se usa el indicador custom a la derecha */
  scrollbar-width: none;
}

.sidebar-page::-webkit-scrollbar {
  display: none;
}

/* Título de página — estilo Notion */
.page-title {
  font-family: var(--font);
  font-size: 32px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 32px;
}

/* ============================================
   NOTEPAD — Editor de notas
   ============================================ */

.notepad-editor {
  font-family: var(--font);
  font-size: 16px;
  color: var(--navy);
  line-height: 1.8;
  outline: none;
  min-height: calc(50vh - 40px);
  margin-left: 15%;
}

.notepad-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--gray);
  opacity: 0.5;
}

/* ============================================
   TODO LIST — Lista de tareas en el notepad
   ============================================ */

.todo-section {
  margin-left: 15%;
  margin-top: 8px;
}

/* Línea separadora corta */
.todo-section::before {
  content: '';
  display: block;
  width: 280px;
  height: 1.5px;
  background: #E8ECEF;
  margin-bottom: 20px;
}

.todo-section-label {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 14px;
}

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.todo-item.removing {
  opacity: 0;
}

/* El círculo — botón invisible salvo el borde */
.todo-circle {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--gray);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease;
  padding: 0;
  margin-top: 3px; /* alinea con la primera línea del textarea */
}

.todo-circle:hover {
  border-color: var(--blue);
}

/* Check visible dentro del círculo al presionar */
.todo-circle.checked {
  border-color: var(--success);
  background: var(--success);
}

.todo-circle.checked::after {
  content: '';
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

/* Input de texto de la tarea — textarea que se expande verticalmente */
.todo-input {
  flex: 1;
  font-family: var(--font);
  font-size: 15px;
  color: var(--navy);
  line-height: 1.6;
  border: none;
  outline: none;
  background: transparent;
  padding: 2px 0;
  resize: none;
  overflow: hidden;
  word-wrap: break-word;
  white-space: pre-wrap;
  min-height: 1.6em;
}

/* ============================================
   CIE-11 — Panel de búsqueda de diagnósticos
   ============================================ */

.cie-panel-content {
  margin-left: 15%;
}

.cie-search-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid #E0E0E0;
  max-width: 320px;
}

.cie-search-icon {
  display: flex;
  align-items: center;
  color: var(--gray);
  flex-shrink: 0;
}

.cie-search-input {
  flex: 1;
  padding: 0;
  font-family: var(--font);
  font-size: 16px;
  color: var(--navy);
  background: transparent;
  border: none;
  outline: none;
}

.cie-search-input::placeholder {
  color: var(--gray);
  opacity: 0.6;
}

.cie-search-container:focus-within {
  border-bottom-color: var(--blue);
}

.cie-search-container:focus-within .cie-search-icon {
  color: var(--blue);
}

.cie-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cie-result-item {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.12s;
}

.cie-result-item:hover {
  background-color: var(--gray-lt);
}

/* Subcódigos (con punto, ej: 6A00.1) — indentados visualmente */
.cie-result-item.cie-subcode {
  padding-left: 28px;
}

.cie-result-code {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
}

.cie-result-title {
  font-family: var(--font);
  font-size: 14px;
  color: var(--navy);
}

.cie-loading, .cie-empty, .cie-error {
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 0;
}

.cie-loading {
  color: var(--gray);
}

.cie-empty {
  color: var(--gray);
}

.cie-error {
  color: var(--error);
}

/* Detalle de diagnóstico */

.cie-detail {
  max-width: 600px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.cie-back {
  font-family: var(--font);
  font-size: 14px;
  color: var(--blue);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 20px;
}

.cie-back:hover {
  opacity: 0.7;
}

.cie-detail-header {
  margin-bottom: 20px;
}

.cie-detail-code {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--blue);
}

.cie-detail-title {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 600;
  color: var(--navy);
  margin-top: 4px;
}

.cie-detail-section {
  margin-bottom: 20px;
}

.cie-detail-text {
  font-family: var(--font);
  font-size: 15px;
  color: var(--navy);
  line-height: 1.7;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.cie-detail-subtitle {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.cie-detail-list {
  list-style: none;
  padding: 0;
}

.cie-detail-list li {
  font-family: var(--font);
  font-size: 14px;
  color: var(--navy);
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.cie-detail-list li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--gray);
  font-weight: 700;
}

/* ============================================
   METADATA — Panel de búsqueda de investigación
   ============================================ */

.meta-panel-content {
  margin-left: 15%;
}

/* Barra de búsqueda — mismo estilo que CIE-11 */
.meta-search-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 1.5px solid #E0E0E0;
  max-width: 320px;
}

.meta-search-icon {
  display: flex;
  align-items: center;
  color: var(--gray);
  flex-shrink: 0;
}

.meta-search-input {
  flex: 1;
  padding: 0;
  font-family: var(--font);
  font-size: 16px;
  color: var(--navy);
  background: transparent;
  border: none;
  outline: none;
}

.meta-search-input::placeholder {
  color: var(--gray);
  opacity: 0.6;
}

.meta-search-container:focus-within {
  border-bottom-color: var(--blue);
}

.meta-search-container:focus-within .meta-search-icon {
  color: var(--blue);
}

/* Resultados */
.meta-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 520px;
}

/* Cada resultado es un link clicable completo */
.meta-result-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.12s;
}

.meta-result-item:hover {
  background-color: var(--gray-lt);
}

.meta-result-title {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  line-height: 1.4;
}

.meta-result-meta {
  font-family: var(--font);
  font-size: 13px;
  color: var(--gray);
}

.meta-result-link {
  color: var(--blue);
  font-size: 12px;
}

/* ============================================
   PANEL SISTEMA — Documentación para el terapeuta
   ============================================ */

.sistema-page {
  max-width: 780px;
  /* margin-left cancela el padding base de sidebar-page (32px) y aplica 15% exacto desde el borde del panel */
  margin-left: calc(15% - 32px);
}

.sistema-page .page-title {
  font-size: 24px;
  font-weight: 400;
}

.sistema-seccion {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 400;
  color: var(--navy);
  margin: 0 0 10px 0;
  border-left: 3px solid var(--blue);
  padding-left: 10px;
}

.sistema-parrafo strong {
  font-size: 15px;
  color: var(--navy);
  opacity: 1;
}

.sistema-parrafo {
  font-family: var(--font);
  font-size: 14px;
  color: #374151;
  line-height: 1.7;
  margin: 0 0 12px 0;
}

.sistema-parrafo a {
  color: var(--blue);
  text-decoration: none;
}

.sistema-parrafo a:hover {
  text-decoration: underline;
}

.sistema-lista {
  margin: 0 0 14px 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sistema-lista li {
  font-family: var(--font);
  font-size: 14px;
  color: #374151;
  line-height: 1.7;
}

.sistema-separador {
  height: 1px;
  background-color: rgba(0, 0, 0, 0.07);
  margin: 24px 0;
}

/* Indicador de scroll custom — borde derecho de pantalla, aplica a todos los paneles */
.sidebar-scroll-track {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: transparent;
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.sidebar-scroll-thumb {
  position: absolute;
  right: 0;
  width: 4px;
  background: #C0C7D0;
  border-radius: 2px;
}

/* Estados */
.meta-loading, .meta-empty, .meta-error {
  font-family: var(--font);
  font-size: 14px;
  padding: 12px 0;
}

.meta-loading { color: var(--gray); }
.meta-empty   { color: var(--gray); }
.meta-error   { color: var(--error); }

/* ============================================
   CALENDARIO — Panel de notas personales
   ============================================ */

/* Título del calendario alineado con el resto del contenido */
.cal-page .page-title {
  margin-left: 15%;
}

/* Navegación de mes */
.cal-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  margin-left: 15%;
  max-width: 640px;
}

.cal-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--gray);
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.12s, background-color 0.12s;
  line-height: 1;
}

.cal-nav-btn:hover:not(:disabled) {
  color: var(--navy);
  background-color: rgba(0, 0, 0, 0.05);
}

.cal-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.cal-month-label {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  min-width: 160px;
  text-align: center;
}

/* Grilla 7 columnas */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-left: 15%;
  max-width: 640px;
  margin-bottom: 28px;
}

/* Encabezados Lu Ma Mi Ju Vi Sá Do */
.cal-header-day {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  text-align: center;
  padding: 6px 0;
  letter-spacing: 0.03em;
}

/* Celda vacía de relleno */
.cal-day-spacer {
  /* espacio vacío para el offset del primer día */
}

/* Celda de día */
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.12s;
  min-height: 44px;
}

.cal-day:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

.cal-day-number {
  font-family: var(--font);
  font-size: 14px;
  color: var(--navy);
  line-height: 1;
}

/* Punto indicador — visible solo cuando has-content */
.cal-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background-color: var(--blue);
  opacity: 0;
  transition: opacity 0.15s;
}

.cal-day.has-content .cal-day-dot {
  opacity: 1;
}

/* Día de hoy */
.cal-day.cal-today .cal-day-number {
  color: var(--blue);
  font-weight: 700;
}

/* Día seleccionado */
.cal-day.cal-selected {
  background-color: var(--navy);
}

.cal-day.cal-selected .cal-day-number {
  color: white;
}

.cal-day.cal-selected .cal-day-dot {
  background-color: white;
}

/* ============================================
   PANEL DEL DÍA — editor + to-do
   ============================================ */

.cal-day-panel {
  margin-left: 15%;
  max-width: 640px;
  padding-top: 8px;
  border-top: 1.5px solid #E8ECEF;
}

.cal-day-title {
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 20px;
}

/* Editor de texto libre — mismo estilo que notepad pero sin margen lateral */
.cal-editor {
  font-family: var(--font);
  font-size: 15px;
  color: var(--navy);
  line-height: 1.8;
  outline: none;
  min-height: 80px;
  margin-bottom: 8px;
}

.cal-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--gray);
  opacity: 0.5;
}

/* Sección to-do del calendario */
.cal-todo-section {
  margin-top: 16px;
}

.cal-todo-section::before {
  content: '';
  display: block;
  width: 100%;
  height: 1.5px;
  background: #E8ECEF;
  margin-bottom: 16px;
}

.cal-todo-label {
  display: block;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 12px;
}

/* "+ Nueva tarea" */
.cal-todo-add {
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray);
  cursor: pointer;
  padding: 4px 0;
  margin-top: 8px;
  transition: color 0.12s;
}

.cal-todo-add:hover {
  color: var(--blue);
}
