/* Marca, barra lateral, menu e cabeçalho da página. */

/* Marca */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--brand);
  color: var(--on-brand);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-mark.has-logo {
  overflow: hidden;
  padding: 3px;
  border: 1px solid var(--line);
  background: #ffffff;
}
.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brand-caption {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Estrutura: barra lateral fixa à esquerda e a área de trabalho à direita.
   A largura da barra muda pela alça na borda dela (sidebar-resize.js). */
#application {
  display: grid;
  grid-template-columns: var(--sidebar-width, 264px) minmax(0, 1fr);
  min-height: 100vh;
}
/* Alça para aumentar ou diminuir a barra lateral: arrastar, setas do teclado
   ou dois cliques para voltar à largura padrão. */
.sidebar-resizer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: calc(var(--sidebar-width, 264px) - 4px);
  z-index: 20;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
}
.sidebar-resizer::after {
  content: "";
  position: absolute;
  inset: 0 3px;
  border-radius: 2px;
  background: transparent;
  transition: background-color 120ms ease;
}
.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after,
.is-resizing-sidebar .sidebar-resizer::after {
  background: var(--brand);
}
.sidebar-resizer:focus-visible {
  outline: none;
}
.is-resizing-sidebar,
.is-resizing-sidebar * {
  cursor: col-resize !important;
  user-select: none;
}
.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  padding: 22px 18px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar .brand {
  padding: 0 6px;
}
/* Deixa o nome e a legenda encolherem para caber (com reticências). */
.brand > div {
  min-width: 0;
}
/* No celular este grupo é a barra de baixo; aqui ele não existe como caixa,
   para o botão novo e o rodapé continuarem soltos na coluna. */
.mobile-dock {
  display: contents;
}
.label-short {
  display: none;
}
/* Menu de ações no topo da barra. */
.sidebar-menu {
  display: grid;
  gap: 8px;
}
.sidebar-primary {
  width: 100%;
  min-height: 42px;
}
.sidebar-link {
  width: 100%;
  justify-content: flex-start;
  min-height: 40px;
}
.sidebar-link[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand);
}
/* Filtros (situação e pastas): ocupam o meio e rolam se não couberem. */
.sidebar-rail {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
/* Rodapé da barra: conta, senha, sair e tema. */
.sidebar-foot {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.sidebar-foot .account-label {
  max-width: 100%;
  padding: 0 4px;
}
.sidebar-foot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sidebar-foot-actions .button {
  min-height: 34px;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 38px;
  margin-left: auto;
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}
.account-label {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Área de trabalho: uma coluna larga, com a lista de documentos, a
   administração e o rodapé. */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.shell {
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 40px 48px 64px;
}
.rail-label {
  margin-bottom: 10px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
/* Pastas por setor, abaixo dos filtros de situação. */
.rail-section {
  margin-top: 28px;
}
.rail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  padding-right: 6px;
}
.rail-heading .rail-label {
  margin-bottom: 0;
}
/* O resumo é o título "Pastas". A seta só aparece no celular. */
.folders-summary {
  list-style: none;
}
.folders-summary::-webkit-details-marker {
  display: none;
}
.folders-summary-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.folders-summary-label::before {
  content: none;
}
@media (min-width: 721px) {
  .folders-summary {
    pointer-events: none;
  }
  .folders-summary .rail-action {
    pointer-events: auto;
  }
}
.rail-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
}
.rail-action:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.rail-action svg {
  width: 14px;
  height: 14px;
}
/* Convite para criar a primeira pasta, quando ainda não há nenhuma. */
.folder-empty {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}
.folder-empty strong {
  display: block;
  margin-top: 4px;
  color: var(--brand);
  font-weight: 600;
}
.folder-empty:hover {
  border-color: var(--brand);
  color: var(--ink);
}
.folder-button::before,
.nav-button.folder-button::before {
  width: 15px;
  height: 13px;
  border-radius: 0;
  background: currentColor;
  opacity: 0.55;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 14'%3E%3Cpath d='M1.5 2.5A1.5 1.5 0 0 1 3 1h3.3l1.6 1.8H13a1.5 1.5 0 0 1 1.5 1.5v7.2A1.5 1.5 0 0 1 13 13H3a1.5 1.5 0 0 1-1.5-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 14'%3E%3Cpath d='M1.5 2.5A1.5 1.5 0 0 1 3 1h3.3l1.6 1.8H13a1.5 1.5 0 0 1 1.5 1.5v7.2A1.5 1.5 0 0 1 13 13H3a1.5 1.5 0 0 1-1.5-1.5z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.folder-button[aria-pressed="true"]::before {
  opacity: 1;
  color: var(--brand);
}
/* Subpastas: recuo por nível, com o nome cortado se não couber. */
.folder-button.is-subfolder {
  padding-left: calc(12px + var(--depth, 0) * 16px);
}
.folder-button .folder-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Pasta com subpastas: a seta substitui o ícone e expande/recolhe. */
.folder-button.has-toggle::before {
  display: none;
}
.folder-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 18px;
  color: var(--faint);
  cursor: pointer;
}
/* A seta é o primeiro filho, mas quem cresce para empurrar a contagem é o
   rótulo (a regra geral dos botões daria o "flex:1" para a seta). */
.folder-button.has-toggle > span:first-child {
  flex: none;
}
.folder-button .folder-label {
  flex: 1;
}
.folder-toggle::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 120ms ease;
}
.folder-toggle.is-open::before {
  transform: rotate(90deg);
}
.folder-toggle:hover {
  color: var(--ink);
}
.nav-list {
  display: grid;
  gap: 2px;
}
.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
}
.nav-button::before {
  content: "";
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--line-strong);
}
.nav-button[data-filter="soon"]::before {
  background: var(--soon);
}
.nav-button[data-filter="overdue"]::before {
  background: var(--overdue);
}
.nav-button > span:first-child {
  flex: 1;
}
.nav-button:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-button[aria-pressed="true"] {
  background: var(--brand-soft);
  color: var(--ink);
  font-weight: 600;
}
.nav-count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Cabeçalho da página */
.page-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-heading h1 {
  font-size: 28px;
}
.today-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.today-label::first-letter {
  text-transform: uppercase;
}

/* Rodapé com o crédito e o contato do desenvolvedor. */
.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  width: 100%;
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px 48px 32px;
  border-top: 1px solid var(--line);
}
.developer-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  font-size: 12px;
}
.developer-contact a {
  color: var(--muted);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.developer-contact a:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Com o botão novo e a conta agrupados no HTML, a ordem visual no computador
   continua: marca, novo, filtros, rodapé. */
@media (min-width: 1081px) {
  .sidebar-rail {
    order: 2;
  }
  .admin-rail {
    order: 3;
  }
  .sidebar-foot {
    order: 4;
  }
}

/* Telas menores: a barra lateral passa para o topo, em linha, e a lista
   ocupa a largura toda. */
@media (max-width: 1080px) {
  #application {
    display: block;
  }
  .sidebar-resizer {
    display: none;
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
    padding: 12px max(16px, calc((100vw - 1500px) / 2));
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand {
    margin-right: auto;
  }
  .sidebar-menu {
    grid-auto-flow: column;
    gap: 8px;
  }
  .sidebar-primary,
  .sidebar-link {
    width: auto;
  }
  /* Os filtros descem para uma faixa própria, abaixo do topo. A conta fica
     na primeira linha (o rodapé vem antes dos filtros no HTML). */
  .sidebar-foot {
    order: 1;
  }
  .admin-rail {
    order: 2;
    flex-basis: 100%;
  }
  .sidebar-rail {
    order: 3;
    flex-basis: 100%;
    overflow: visible;
  }
  .rail-label {
    display: none;
  }
  .rail-section {
    margin-top: 10px;
  }
  .rail-heading {
    margin-bottom: 6px;
  }
  .rail-heading .rail-label {
    display: block;
    padding-left: 2px;
  }
  .nav-list {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }
  .nav-button {
    width: auto;
    min-width: max-content;
    border: 1px solid var(--line);
    background: var(--surface);
  }
  .nav-button > span:first-child {
    flex: none;
  }
  .sidebar-foot {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }
  .sidebar-foot .account-label {
    max-width: 200px;
  }
  .shell {
    padding: 28px 24px 56px;
  }
  .app-footer {
    padding: 20px 24px 32px;
  }
}

/* Celular: topo grudado com a marca e os filtros; novo documento, conta e
   tema ficam numa barra fixa, para a lista começar logo abaixo do topo. */
@media (max-width: 720px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
    height: auto;
    padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
    overflow: visible;
    background: var(--surface);
  }
  .sidebar .brand {
    padding: 0;
  }
  .brand-caption {
    display: none;
  }
  .mobile-dock {
    display: flex;
    align-items: center;
    gap: 4px;
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    overflow-x: auto;
    border-top: 1px solid var(--line);
    background: var(--surface);
    scrollbar-width: none;
    transition: transform 180ms ease;
  }
  .mobile-dock::-webkit-scrollbar {
    display: none;
  }
  body:has(input:focus, textarea:focus, select:focus) .mobile-dock {
    transform: translateY(110%);
  }
  .mobile-dock .label-long {
    display: none;
  }
  .mobile-dock .label-short {
    display: inline;
  }
  .sidebar-menu {
    flex: 1 1 auto;
    flex-shrink: 0;
    order: 0;
    width: auto;
    min-width: max-content;
  }
  .sidebar-primary,
  .sidebar-link {
    width: auto;
    min-height: 44px;
  }
  .sidebar-primary {
    width: 100%;
  }
  .sidebar-foot {
    display: flex;
    flex: none;
    flex-wrap: nowrap;
    align-items: center;
    order: 0;
    gap: 2px;
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .sidebar-foot .account-label {
    display: none;
  }
  .sidebar-foot-actions {
    flex-wrap: nowrap;
    gap: 2px;
  }
  .sidebar-foot .sidebar-link,
  .sidebar-foot-actions .button,
  .theme-toggle {
    min-width: 44px;
    min-height: 44px;
    padding-inline: 8px;
  }
  .theme-toggle {
    width: 44px;
    margin-left: 0;
  }
  .sidebar-rail,
  .admin-rail,
  .nav-list,
  .admin-nav,
  .rail-section {
    min-width: 0;
    max-width: 100%;
  }
  .rail-section {
    margin-top: 2px;
  }
  .folders-summary {
    min-height: 44px;
    margin-bottom: 0;
    padding: 0 10px 0 12px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-small);
    background: var(--surface-2);
    cursor: pointer;
  }
  .folders-disclosure[open] > .folders-summary {
    border-color: var(--brand);
    background: var(--brand-soft);
  }
  .folders-summary .rail-label {
    padding: 0;
    color: var(--ink);
    font-size: 15px;
    font-weight: 650;
  }
  .folders-summary-label::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 6px solid var(--brand);
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    transition: transform 120ms ease;
  }
  .folders-disclosure[open] > .folders-summary .folders-summary-label::before {
    transform: rotate(90deg);
  }
  .folders-disclosure:not([open]) > :not(summary) {
    display: none;
  }
  .rail-action {
    min-height: 44px;
  }
  .sidebar-rail > .nav-list,
  .admin-nav {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .sidebar-rail > .nav-list::-webkit-scrollbar,
  .admin-nav::-webkit-scrollbar {
    display: none;
  }
  .nav-button {
    flex-shrink: 0;
    min-height: 40px;
  }
  .nav-button[aria-pressed="true"] {
    border-color: var(--brand);
  }
  /* Pastas abertas: lista vertical, com rolagem própria se forem muitas. */
  .folder-list {
    display: grid;
    gap: 2px;
    max-height: min(240px, 40vh);
    margin-top: 4px;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .folder-list .nav-button {
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
  }
  .folder-list .nav-button[aria-pressed="true"] {
    background: var(--brand-soft);
  }
  .admin-nav-back {
    min-height: 40px;
  }
  .workspace {
    padding-bottom: calc(68px + env(safe-area-inset-bottom));
  }
  .shell {
    padding: 16px 16px 28px;
  }
  .app-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 16px 20px;
  }
  .developer-contact {
    display: grid;
    gap: 6px;
  }
  .page-heading {
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 14px;
  }
  .page-heading h1 {
    font-size: 24px;
  }
  .today-label {
    white-space: normal;
  }
}

@media (max-width: 720px) and (prefers-reduced-motion: reduce) {
  .mobile-dock {
    transition: none;
  }
}

/* Arrastar arquivos ou uma pasta do computador para a tela principal: um
   contorno na tela e o aviso embaixo; a pasta da lateral sob o cursor fica em
   destaque. O aviso não recebe o ponteiro, para a pasta embaixo dele contar. */
.main-drop-overlay {
  position: fixed;
  inset: 8px;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 28px;
  border: 2px dashed var(--brand);
  border-radius: 12px;
  background: color-mix(in srgb, var(--brand-soft) 35%, transparent);
  pointer-events: none;
}
.main-drop-overlay[hidden] {
  display: none;
}
.main-drop-overlay p {
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: var(--shadow-dialog);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
}
.folder-button.is-drop-target {
  background: var(--brand-soft);
  color: var(--brand);
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* Ambiente que não é a produção (homologação, local): linha colorida no topo
   e uma etiqueta, sem ocupar espaço nem bloquear cliques. */
.environment-banner {
  position: fixed;
  top: 0;
  left: 50%;
  z-index: 30;
  transform: translateX(-50%);
  padding: 2px 12px 3px;
  border-radius: 0 0 var(--radius-small) var(--radius-small);
  background: var(--soon);
  color: var(--surface);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}
.environment-banner::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--soon);
}

/* Celular: os três filtros de situação cabem lado a lado, sem rolagem que
   esconda o último. */
@media (max-width: 720px) {
  .status-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    overflow: visible;
  }
  .status-list .nav-button {
    min-width: 0;
    gap: 6px;
    padding: 0 8px;
    font-size: 13px;
  }
  .status-list .nav-button > span:first-child {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
