/* ==========================================================
   assets/shell-nav.css
   Shell de navegação compartilhado — ClinicusMed
   Injetado em todos os arquivos de conteúdo (guias, simulados).
   Todas as classes usam o prefixo "cmed-nav-" pra nunca colidir
   com o CSS interno de cada arquivo de conteúdo.
   ========================================================== */

.cmed-nav-header, .cmed-nav-header * { box-sizing: border-box; }

/* ---------- OVERRIDE CRÍTICO ----------
   Alguns arquivos de conteúdo definem body{display:flex} ou display:grid
   pra ter o layout próprio deles (sidebar+conteúdo lado a lado). Sem isso
   aqui, o body flex/grid do arquivo "puxa" nosso cabeçalho/breadcrumb/
   sidebar pra layout errado também. Forçamos o body a empilhar em coluna
   sempre, e cada arquivo mantém seu próprio layout interno dentro da
   .cmed-nav-main (onde ele já usava display:flex/grid nos PRÓPRIOS
   elementos internos, isso continua funcionando normalmente). */
html body{
  display: block !important;
  min-height: 0 !important;
}
/* Nota: arquivos que tinham body{display:flex/grid} pra layout proprio
   tiveram essa regra retargetada pra .cmed-nav-main (ver inject_shell.py) */

/* ---------- CABEÇALHO FIXO ---------- */
.cmed-nav-header{
  position: sticky; top: 0; z-index: 999;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #0b0f14;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
}
.cmed-nav-header a{ text-decoration: none; }
.cmed-nav-header-actions{ display: flex; align-items: center; gap: 8px; }
.cmed-nav-brand{
  display: flex; align-items: center; gap: 8px;
  color: #f3e9dd; font-weight: 700; font-size: 14px;
  white-space: nowrap;
}
.cmed-nav-brand img{ height: 26px; width: 26px; border-radius: 6px; }
.cmed-nav-back{
  display: flex; align-items: center; gap: 6px;
  color: #9fd7c9; font-size: 13.5px; font-weight: 600;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid rgba(159,215,201,0.35);
  transition: all .15s ease; white-space: nowrap;
}
.cmed-nav-back:hover{ background: rgba(159,215,201,0.1); border-color: #9fd7c9; }
.cmed-nav-catalogo{
  display: flex; align-items: center; gap: 5px;
  color: rgba(243,233,221,0.55); font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: 999px;
  border: 1px solid rgba(243,233,221,0.15);
  transition: all .15s ease; white-space: nowrap;
}
.cmed-nav-catalogo:hover{ background: rgba(243,233,221,0.08); color: rgba(243,233,221,0.85); border-color: rgba(243,233,221,0.3); }
@media (max-width: 560px){
  .cmed-nav-catalogo span.label{ display:none; }
}

/* ---------- BREADCRUMB ---------- */
.cmed-nav-breadcrumb{
  padding: 10px 18px;
  background: #12171d;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
  font-size: 12.5px;
  color: #8f9aa3;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
}
.cmed-nav-breadcrumb a{ color: #8f9aa3; text-decoration: none; }
.cmed-nav-breadcrumb a:hover{ color: #e8c27a; text-decoration: underline; }
.cmed-nav-breadcrumb .sep{ opacity: .5; }
.cmed-nav-breadcrumb .current{ color: #e8c27a; font-weight: 600; }

/* ---------- LAYOUT: SIDEBAR + CONTEÚDO ---------- */
.cmed-nav-layout{
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 92px); /* desconta header + breadcrumb */
}
.cmed-nav-sidebar{
  flex: 0 0 260px;
  max-width: 260px;
  position: sticky;
  top: 92px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  background: #0e1318;
  border-right: 1px solid rgba(255,255,255,0.06);
  padding: 18px 14px 40px;
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
}
.cmed-nav-sidebar h4{
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: #6b7680; margin: 18px 0 8px; font-weight: 700;
}
.cmed-nav-sidebar h4:first-child{ margin-top: 0; }
.cmed-nav-sidebar-title{
  font-size: 14.5px; font-weight: 700; color: #f3e9dd;
  margin: 0 0 4px; line-height: 1.3;
}
.cmed-nav-item{
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  font-size: 13px; color: #c7ceD4;
  text-decoration: none; line-height: 1.3;
  margin-bottom: 2px;
}
.cmed-nav-item:hover{ background: rgba(255,255,255,0.05); color: #fff; }
.cmed-nav-item.is-current{
  background: rgba(232,194,122,0.12);
  color: #e8c27a; font-weight: 700;
  border-left: 3px solid #e8c27a; padding-left: 7px;
}
.cmed-nav-item .ico{ flex-shrink: 0; opacity: .8; font-size: 13px; }
.cmed-novo-badge{
  display: inline-block; flex-shrink: 0;
  margin-left: auto; padding: 1px 7px;
  font-size: 10px; font-weight: 800; letter-spacing: .02em;
  border-radius: 999px; white-space: nowrap;
  background: rgba(255,209,102,.18); color: #ffd166;
  border: 1px solid rgba(255,209,102,.4);
}

.cmed-nav-main{ flex: 1 1 auto; min-width: 0; }

/* colapsa a sidebar em telas pequenas — vira uma barra horizontal no topo */
.cmed-nav-sidebar-toggle{ display: none; }
@media (max-width: 860px){
  .cmed-nav-layout{ flex-direction: column; }
  .cmed-nav-sidebar{
    position: static; max-height: none; width: 100%; max-width: none;
    flex: none; border-right: none; border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 10px 14px;
  }
  .cmed-nav-sidebar-list{ display: none; }
  .cmed-nav-sidebar.is-open .cmed-nav-sidebar-list{ display: block; }
  .cmed-nav-sidebar-toggle{
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; background: none; border: none; cursor: pointer;
    color: #f3e9dd; font-weight: 700; font-size: 14px; padding: 4px 0;
    font-family: inherit;
  }
}

/* ---------- ANTERIOR / PRÓXIMO ---------- */
.cmed-nav-prevnext{
  display: flex; align-items: stretch; justify-content: space-between; gap: 12px;
  padding: 22px 18px 34px;
  background: #0e1318;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
  flex-wrap: wrap;
}
.cmed-nav-pn-btn{
  flex: 1 1 220px; max-width: 340px;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 16px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  color: #f3e9dd; text-decoration: none;
  transition: all .15s ease;
}
.cmed-nav-pn-btn:hover{ border-color: #e8c27a; background: rgba(232,194,122,0.06); }
.cmed-nav-pn-btn.next{ text-align: right; margin-left: auto; }
.cmed-nav-pn-label{ font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #8f9aa3; }
.cmed-nav-pn-title{ font-size: 13.5px; font-weight: 700; }
.cmed-nav-pn-btn.disabled{ opacity: .35; pointer-events: none; }

/* ---------- BARRA DE PROGRESSO (localStorage, sem backend) ---------- */
.cmed-nav-progress-wrap{
  padding: 4px 18px 12px;
  background: #12171d;
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
}
.cmed-nav-progress-label{
  font-size: 11.5px; color: #8f9aa3; margin-bottom: 5px;
  display: flex; justify-content: space-between;
}
.cmed-nav-progress-track{
  height: 6px; border-radius: 99px; background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.cmed-nav-progress-fill{
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg,#c96f2e,#e8c27a);
  transition: width .4s ease;
}

/* ---------- MODO LEITURA (Modo Foco) ---------- */

/* Botão de alternância + selo de tempo de leitura, agrupados numa barrinha fixa */
.cmed-reading-toolbar{
  position: fixed; top: 64px; right: 14px; z-index: 1005;
  display: flex; align-items: center; gap: 8px;
  font-family: 'DM Sans', 'Segoe UI', Arial, sans-serif;
}
.cmed-reading-btn{
  background: #1a2129; color: #f3e9dd; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px; padding: 9px 15px; font-size: 12.5px; font-weight: 700;
  font-family: inherit;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,.35);
  display: flex; align-items: center; gap: 6px;
  transition: background .3s ease, border-color .3s ease, transform .2s ease;
}
.cmed-reading-btn:hover{ border-color: #e8c27a; background: rgba(232,194,122,0.14); }
.cmed-reading-btn:active{ transform: scale(.96); }
html.cmed-reading-mode .cmed-reading-btn .cmed-reading-label-enter{ display: none; }
html:not(.cmed-reading-mode) .cmed-reading-btn .cmed-reading-label-exit{ display: none; }

/* Selo de tempo de leitura + seletor de tema — só aparecem dentro do modo leitura */
.cmed-reading-extras{
  display: none;
  align-items: center; gap: 8px;
}
html.cmed-reading-mode .cmed-reading-extras{ display: flex; }
.cmed-reading-time{
  background: #1a2129; color: #cbd5df; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px; padding: 8px 13px; font-size: 11.5px; font-weight: 600;
  white-space: nowrap;
}
.cmed-reading-themes{
  display: flex; gap: 3px; background: #1a2129; border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px; padding: 4px;
}
.cmed-reading-theme-btn{
  border: none; background: transparent; cursor: pointer; font-size: 15px;
  width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  opacity: .55; transition: opacity .2s ease, background .2s ease;
}
.cmed-reading-theme-btn:hover{ opacity: .85; }
.cmed-reading-theme-btn.is-active{ opacity: 1; background: rgba(255,255,255,0.14); }

/* Barra de progresso de leitura, fixa no topo */
.cmed-reading-progress{
  position: fixed; top: 0; left: 0; height: 3px; width: 0%; z-index: 1006;
  background: linear-gradient(90deg,#c96f2e,#e8c27a);
  transition: width .12s linear;
  display: none;
}
html.cmed-reading-mode .cmed-reading-progress{ display: block; }

/* Botão flutuante "voltar ao topo" */
.cmed-reading-top{
  position: fixed; right: 20px; bottom: 20px; z-index: 1005;
  width: 42px; height: 42px; border-radius: 50%;
  background: #1a2129; color: #f3e9dd; border: 1px solid rgba(255,255,255,0.14);
  cursor: pointer; font-size: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.35);
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .3s ease, transform .3s ease;
  display: none; align-items: center; justify-content: center;
}
html.cmed-reading-mode .cmed-reading-top{ display: flex; }
html.cmed-reading-mode .cmed-reading-top.is-visible{ opacity: 1; pointer-events: auto; transform: translateY(0); }

/* Quando o modo leitura esta ATIVO, o cabecalho fixo some (ver regra abaixo) —
   entao o toolbar pode subir pro topo, sem risco de colidir com o botao "Voltar" */
html.cmed-reading-mode .cmed-reading-toolbar{ top: 14px; }

/* Oculta navegação/UI que não é conteúdo de estudo */
html.cmed-reading-mode .cmed-nav-header,
html.cmed-reading-mode .cmed-nav-breadcrumb,
html.cmed-reading-mode .cmed-nav-progress-wrap,
html.cmed-reading-mode .cmed-nav-sidebar,
html.cmed-reading-mode .cmed-nav-prevnext,
html.cmed-reading-mode footer{
  display: none !important;
}

/* Área de leitura: largura confortável, centralizada, com transição suave */
html.cmed-reading-mode .wrap{
  max-width: 880px !important;
  margin: 0 auto !important;
  transition: max-width .3s ease;
}

/* Tipografia mais confortável dentro do conteúdo de estudo */
html.cmed-reading-mode .card p,
html.cmed-reading-mode .card li,
html.cmed-reading-mode .card td,
html.cmed-reading-mode .card th{
  font-size: 19px !important;
  line-height: 1.8 !important;
}
html.cmed-reading-mode .card{
  padding: 26px 28px !important;
  margin-bottom: 22px !important;
  transition: background .3s ease, color .3s ease, border-color .3s ease;
}
html.cmed-reading-mode .card p{ margin-bottom: 1em !important; }
html.cmed-reading-mode body{ transition: background .3s ease, color .3s ease; }

/* ---- Temas do Modo Leitura ---- */
html.cmed-reading-mode[data-reading-theme="claro"]{
  --bg:#ffffff !important; --card:#ffffff !important; --card2:#f5f5f5 !important;
  --text:#1c1c1c !important; --text-dim:#5a5a5a !important; --border:#e2e2e2 !important;
}
html.cmed-reading-mode[data-reading-theme="claro"] body{ background:#ffffff !important; }
html.cmed-reading-mode[data-reading-theme="claro"] .card{ background:#ffffff !important; border-color:#e2e2e2 !important; box-shadow: 0 1px 3px rgba(0,0,0,.06); }

html.cmed-reading-mode[data-reading-theme="escuro"]{
  --bg:#101418 !important; --card:#161b20 !important; --card2:#1c2229 !important;
  --text:#e9edf1 !important; --text-dim:#9aa5af !important; --border:#2a3138 !important;
}
html.cmed-reading-mode[data-reading-theme="escuro"] body{ background:#101418 !important; }
html.cmed-reading-mode[data-reading-theme="escuro"] .card{ background:#161b20 !important; border-color:#2a3138 !important; }

html.cmed-reading-mode[data-reading-theme="papel"]{
  --bg:#f4ecd8 !important; --card:#f8f1e1 !important; --card2:#f0e6cd !important;
  --text:#3a3226 !important; --text-dim:#6b5f4d !important; --border:#e0d3b0 !important;
}
html.cmed-reading-mode[data-reading-theme="papel"] body{ background:#f4ecd8 !important; }
html.cmed-reading-mode[data-reading-theme="papel"] .card{ background:#f8f1e1 !important; border-color:#e0d3b0 !important; }

@media (max-width: 640px){
  .cmed-reading-btn{ padding: 7px 12px; font-size: 11.5px; }
  .cmed-reading-toolbar{ top: 58px; right: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 20px); }
  html.cmed-reading-mode .cmed-reading-toolbar{ top: 10px; }
  .cmed-reading-time{ display: none; } /* no celular, prioriza espaço — some o selo de tempo */
  html.cmed-reading-mode .wrap{ max-width: 100% !important; padding-left: 14px; padding-right: 14px; }
  html.cmed-reading-mode .card{ padding: 18px 16px !important; }
  html.cmed-reading-mode .card p, html.cmed-reading-mode .card li{ font-size: 17px !important; }
  .cmed-reading-top{ right: 14px; bottom: 14px; width: 38px; height: 38px; }
}

