/**
 * Manic Pixels Web OS — VfsFileDialog CSS
 * Estilos para o picker nativo de arquivos/pastas (VfsFileDialog).
 *
 * Sessão 2 — WP-3:
 *   Item 12 — File picker nativo (open)
 *   Item 13 — Modo save-as (campo de nome no rodapé)
 *   Item 14 — Hook beforeConfirm async (sem estilo específico)
 *   Item 48 — Validar nome sem barras (erro inline .mp-fd-error)
 */

/* ── Corpo da janela ─────────────────────────────────────────────────────── */

.mp-fd-body {
  padding:    0 !important;
  overflow:   hidden !important;
}

.mp-fd-container {
  display:        flex;
  flex-direction: column;
  height:         100%;
  overflow:       hidden;
  font-family:    var(--mp-font-ui, system-ui, sans-serif);
  font-size:      12px;
  color:          rgba(255, 255, 255, 0.80);
}

/* ── Toolbar (voltar + breadcrumb) ───────────────────────────────────────── */

.mp-fd-toolbar {
  display:     flex;
  align-items: center;
  gap:         6px;
  padding:     7px 8px 7px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
  min-height:  38px;
}

/* Botão de voltar */
.mp-fd-nav-btn {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:  28px; height: 28px;
  flex-shrink:  0;
  padding:      0;
  background:   rgba(255, 255, 255, 0.05);
  border:       1px solid rgba(255, 255, 255, 0.09);
  border-radius: 5px;
  color:        rgba(255, 255, 255, 0.55);
  cursor:       pointer;
  transition:   background 0.12s, color 0.12s, opacity 0.12s;
}

.mp-fd-nav-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.10);
  color:      rgba(255, 255, 255, 0.90);
}

.mp-fd-nav-btn:disabled {
  opacity: 0.28;
  cursor:  default;
}

.mp-fd-nav-btn svg { display: block; }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */

.mp-fd-breadcrumb {
  display:     flex;
  align-items: center;
  flex:        1;
  min-width:   0;
  gap:         0;
  overflow:    hidden;
}

.mp-fd-bc-item {
  padding:       2px 5px;
  background:    transparent;
  border:        none;
  border-radius: 4px;
  font-family:   var(--mp-font-ui, system-ui, sans-serif);
  font-size:     12px;
  color:         rgba(255, 255, 255, 0.50);
  cursor:        pointer;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
  max-width:     180px;
  transition:    background 0.10s, color 0.10s;
  flex-shrink:   1;
}

.mp-fd-bc-item:hover:not(.active) {
  background: rgba(255, 255, 255, 0.07);
  color:      rgba(255, 255, 255, 0.80);
}

.mp-fd-bc-item.active {
  color:  rgba(255, 255, 255, 0.85);
  cursor: default;
}

.mp-fd-bc-sep {
  flex-shrink:   0;
  color:         rgba(255, 255, 255, 0.22);
  font-size:     13px;
  padding:       0 1px;
  line-height:   1;
  user-select:   none;
}

/* ── Layout principal (sidebar + resizer + painel) ───────────────────────── */

.mp-fd-main {
  display:    flex;
  flex:       1;
  overflow:   hidden;
  min-height: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.mp-fd-sidebar {
  width:          190px;
  min-width:      130px;
  max-width:      280px;
  flex-shrink:    0;
  overflow-y:     auto;
  overflow-x:     hidden;
  padding:        8px 0;
  border-right:   1px solid rgba(255, 255, 255, 0.07);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.10) transparent;
}

.mp-fd-sidebar::-webkit-scrollbar       { width: 3px; }
.mp-fd-sidebar::-webkit-scrollbar-track { background: transparent; }
.mp-fd-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); border-radius: 2px; }

/* Cabeçalho de seção da sidebar */
.mp-fd-sidebar-header {
  padding:        3px 10px 3px 12px;
  font-size:      9.5px;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color:          rgba(255, 255, 255, 0.28);
  user-select:    none;
}

/* Item de acesso rápido */
.mp-fd-sidebar-item {
  display:       flex;
  align-items:   center;
  gap:           7px;
  width:         100%;
  padding:       4px 10px 4px 12px;
  background:    transparent;
  border:        none;
  text-align:    left;
  cursor:        pointer;
  border-radius: 0;
  transition:    background 0.10s, color 0.10s;
  color:         rgba(255, 255, 255, 0.62);
}

.mp-fd-sidebar-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color:      rgba(255, 255, 255, 0.90);
}

.mp-fd-sidebar-item.active {
  background: rgba(var(--mp-accent-rgb, 61, 174, 233), 0.14);
  color:      var(--mp-accent, #3daee9);
}

.mp-fd-sidebar-icon {
  display:     flex;
  align-items: center;
  flex-shrink: 0;
  width:  16px; height: 16px;
  font-size:   14px;
  line-height: 1;
}

.mp-fd-sidebar-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.mp-fd-sidebar-label {
  font-size:     11.5px;
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}

/* ── Árvore de pastas ────────────────────────────────────────────────────── */

.mp-fd-tree-node {
  display: flex;
  flex-direction: column;
}

.mp-fd-tree-row {
  display:       flex;
  align-items:   center;
  gap:           4px;
  padding-top:   3px;
  padding-bottom: 3px;
  padding-right: 8px;
  cursor:        pointer;
  color:         rgba(255, 255, 255, 0.55);
  transition:    background 0.10s, color 0.10s;
  white-space:   nowrap;
  overflow:      hidden;
}

.mp-fd-tree-row:hover {
  background: rgba(255, 255, 255, 0.06);
  color:      rgba(255, 255, 255, 0.90);
}

.mp-fd-tree-row.active {
  background: rgba(var(--mp-accent-rgb, 61, 174, 233), 0.14);
  color:      var(--mp-accent, #3daee9);
}

/* Seta de expansão */
.mp-fd-tree-arrow {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:  14px; height: 14px;
  flex-shrink: 0;
  color:       rgba(255, 255, 255, 0.35);
  transition:  transform 0.14s, color 0.10s;
  cursor:      pointer;
  border-radius: 3px;
}

.mp-fd-tree-arrow:hover { color: rgba(255, 255, 255, 0.80); }

.mp-fd-tree-arrow--empty { opacity: 0; pointer-events: none; }

.mp-fd-tree-arrow--expanded svg {
  transform: rotate(90deg);
}

.mp-fd-tree-arrow svg { display: block; transition: transform 0.14s; }

/* Ícone da pasta na árvore */
.mp-fd-tree-icon {
  display:     flex;
  align-items: center;
  flex-shrink: 0;
  width:  14px; height: 14px;
  font-size: 12px;
  line-height: 1;
}

.mp-fd-tree-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.mp-fd-tree-label {
  font-size:     11px;
  overflow:      hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Container de filhos */
.mp-fd-tree-children { display: flex; flex-direction: column; }

/* Spinner de lazy-load (Item 46) */
.mp-fd-tree-spinner {
  padding:     4px 24px;
  display:     flex;
  align-items: center;
}

.mp-fd-tree-spinner::after {
  content:      '';
  display:      block;
  width:        12px; height: 12px;
  border:       1.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--mp-accent, #3daee9);
  border-radius: 50%;
  animation:    mp-fd-spin 0.6s linear infinite;
}

@keyframes mp-fd-spin {
  to { transform: rotate(360deg); }
}

/* ── Resizer ─────────────────────────────────────────────────────────────── */

.mp-fd-resizer {
  width:      4px;
  flex-shrink: 0;
  background:  transparent;
  cursor:      col-resize;
  transition:  background 0.15s;
}

.mp-fd-resizer:hover { background: rgba(var(--mp-accent-rgb, 61, 174, 233), 0.35); }

/* ── Painel de arquivos ───────────────────────────────────────────────────── */

.mp-fd-pane {
  flex:        1;
  overflow-y:  auto;
  overflow-x:  hidden;
  padding:     6px;
  outline:     none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.10) transparent;
}

.mp-fd-pane::-webkit-scrollbar       { width: 4px; }
.mp-fd-pane::-webkit-scrollbar-track { background: transparent; }
.mp-fd-pane::-webkit-scrollbar-thumb { background: rgba(255,255,255,.10); border-radius: 2px; }

/* ── Estado vazio ─────────────────────────────────────────────────────────── */

.mp-fd-empty {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  gap:             10px;
  padding:         40px 16px;
  color:           rgba(255, 255, 255, 0.18);
  font-size:       12px;
  text-align:      center;
  user-select:     none;
}

.mp-fd-empty svg { opacity: 0.30; }

/* ── Lista de itens ───────────────────────────────────────────────────────── */

.mp-fd-items {
  display:        flex;
  flex-direction: column;
  gap:            1px;
}

.mp-fd-item {
  display:       flex;
  align-items:   center;
  gap:           8px;
  padding:       5px 7px;
  border-radius: 5px;
  cursor:        default;
  border:        1px solid transparent;
  transition:    background 0.09s, border-color 0.09s;
  user-select:   none;
}

.mp-fd-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.mp-fd-item.selected {
  background:   rgba(var(--mp-accent-rgb, 61, 174, 233), 0.14);
  border-color: rgba(var(--mp-accent-rgb, 61, 174, 233), 0.28);
  color:        rgba(255, 255, 255, 0.95);
}

/* Item de sistema (somente leitura) */
.mp-fd-item--system {
  opacity: 0.55;
  cursor:  not-allowed;
}

.mp-fd-item--system:hover {
  background:   transparent;
  border-color: transparent;
}

/* Ícone do item */
.mp-fd-item-icon {
  width:  28px; height: 28px;
  flex-shrink: 0;
  display:     flex;
  align-items: center;
  justify-content: center;
}

.mp-fd-item-emoji {
  font-size: 20px;
  line-height: 1;
}

/* Informações (nome + meta) */
.mp-fd-item-info {
  flex:    1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap:     1px;
}

.mp-fd-item-name {
  font-size:     12px;
  color:         rgba(255, 255, 255, 0.82);
  overflow:      hidden;
  text-overflow: ellipsis;
  white-space:   nowrap;
}

.mp-fd-item.selected .mp-fd-item-name { color: rgba(255, 255, 255, 0.97); }

/* Item 48 analogue: indicador de sistema */
.mp-fd-item-system-label {
  font-size: 10px;
  color:     rgba(255, 100, 100, 0.60);
  font-weight: 400;
  margin-left: 2px;
}

.mp-fd-item-meta {
  font-size:  10.5px;
  color:      rgba(255, 255, 255, 0.30);
  overflow:   hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Rodapé ──────────────────────────────────────────────────────────────── */

.mp-fd-footer {
  display:        flex;
  flex-direction: column;
  gap:            8px;
  flex-shrink:    0;
  padding:        9px 10px 10px;
  border-top:     1px solid rgba(255, 255, 255, 0.07);
}

/* Botões do rodapé */
.mp-fd-footer-btns {
  display:         flex;
  align-items:     center;
  justify-content: flex-end;
  gap:             8px;
}

/* ── Modo save-as — campo de nome (Item 13) ──────────────────────────────── */

.mp-fd-saveas-row {
  display:     flex;
  align-items: flex-start;
  gap:         8px;
}

.mp-fd-label {
  flex-shrink: 0;
  font-size:   11.5px;
  color:       rgba(255, 255, 255, 0.45);
  padding-top: 5px;
  white-space: nowrap;
}

.mp-fd-saveas-wrap {
  flex:    1;
  display: flex;
  flex-direction: column;
  gap:     4px;
}

/* Campo de nome de arquivo */
.mp-fd-filename {
  width:         100%;
  padding:       5px 9px;
  background:    rgba(255, 255, 255, 0.06);
  border:        1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  color:         rgba(255, 255, 255, 0.90);
  font-family:   var(--mp-font-ui, system-ui, sans-serif);
  font-size:     12px;
  outline:       none;
  transition:    border-color 0.12s, background 0.12s;
  box-sizing:    border-box;
}

.mp-fd-filename::placeholder { color: rgba(255, 255, 255, 0.22); }

.mp-fd-filename:focus {
  border-color: var(--mp-accent, #3daee9);
  background:   rgba(255, 255, 255, 0.08);
}

/* Erro de validação (Item 48) */
.mp-fd-filename--error {
  border-color: rgba(220, 80, 80, 0.70) !important;
  background:   rgba(220, 80, 80, 0.06) !important;
}

.mp-fd-error {
  font-size:    10.5px;
  color:        rgba(220, 100, 100, 0.90);
  padding:      2px 2px;
  animation:    mp-fd-shake 0.28s ease;
}

@keyframes mp-fd-shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

/* ── Botões de ação ───────────────────────────────────────────────────────── */

.mp-fd-btn {
  padding:       5px 16px;
  border-radius: 6px;
  font-family:   var(--mp-font-ui, system-ui, sans-serif);
  font-size:     12px;
  font-weight:   500;
  cursor:        pointer;
  border:        1px solid transparent;
  transition:    background 0.12s, color 0.12s, opacity 0.12s, filter 0.12s;
  white-space:   nowrap;
  min-width:     72px;
  text-align:    center;
}

.mp-fd-btn-secondary {
  background:   rgba(255, 255, 255, 0.06);
  color:        rgba(255, 255, 255, 0.55);
  border-color: rgba(255, 255, 255, 0.10);
}

.mp-fd-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.10);
  color:      rgba(255, 255, 255, 0.82);
}

.mp-fd-btn-primary {
  background:   var(--mp-accent, #3daee9);
  color:        #fff;
  border-color: rgba(0, 0, 0, 0.15);
}

.mp-fd-btn-primary:hover:not(:disabled) {
  filter: brightness(1.10);
}

.mp-fd-btn-primary:disabled {
  opacity: 0.32;
  cursor:  default;
}
