/* ==========================================================================
   File Manager Panel
   Overlay panel with file list sidebar and editor/preview area.
   All values sourced from tokens.css — zero hardcoded colors or keyframes.
   ========================================================================== */

/* --- 1. File Manager Panel --- */

.file-manager-panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: var(--z-files);
  display: none;
  flex-direction: column;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
}

/* JS sets display: flex to show */

/* --- 2. FM Header --- */

.fm-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* --- 3. FM Breadcrumb --- */

.fm-breadcrumb {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- 4. FM Body --- */

.fm-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* --- 5. FM Sidebar (file list) --- */

.fm-sidebar {
  width: 280px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

/* --- 6. FM Items --- */

.fm-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: var(--text-base);
  transition: background var(--duration-normal);
  border-bottom: 1px solid var(--border-light);
}

.fm-item:hover {
  background: var(--bg-surface-hover);
}

.fm-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.fm-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fm-size {
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-shrink: 0;
}

.fm-dir .fm-name {
  font-weight: 500;
}

/* --- 7. FM Editor --- */

.fm-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fm-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-base);
  font-weight: 600;
  flex-shrink: 0;
}

.fm-textarea {
  flex: 1;
  width: 100%;
  border: none;
  outline: none;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  background: var(--bg-input);
  color: var(--text);
  resize: none;
  tab-size: 2;
}

/* --- 8. FM Preview --- */

.fm-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fm-preview-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
  -webkit-overflow-scrolling: touch;
}

/* --- 9. New Classes --- */

.fm-error {
  color: var(--danger);
  padding: var(--space-3) var(--space-4);
}

.fm-preview-img {
  max-width: 100%;
  border-radius: var(--radius-md);
}

.fm-preview-code {
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* --- 10. Responsive --- */

@media (max-width: 768px) {
  .fm-sidebar {
    width: 100%;
    border-right: none;
  }

  .fm-body {
    flex-direction: column;
  }

  .fm-editor,
  .fm-preview {
    position: absolute;
    inset: 0;
    top: var(--space-12);
    background: var(--bg);
    z-index: var(--z-base);
  }
}
