﻿:root {
  --color-bg: #f4f4f9;
  --color-panel-bg: #ffffff;
  --color-tree-bg: #e9eef5;
  --color-text: #333333;
  --color-hover: #d1e0f3;
  --color-active: #bacee6;
  --color-border: #d1d1d1;
  --color-header: #007bff;
  --color-header-text: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

.container {
  display: flex;
  flex-grow: 1;
  overflow: hidden;
}

/* Left Panel: Tree View */
.tree-panel {
  background: var(--color-tree-bg);
  padding: 1rem;
  border-right: 1px solid var(--color-border);
  width: 280px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.tree-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--color-header);
}

#directoryTree ul { list-style: none; padding-left: 15px; }
#directoryTree .folder-node {
  padding: 5px;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
#directoryTree .folder-node:hover { background: var(--color-hover); }
#directoryTree .folder-node.active { background: var(--color-active); font-weight: bold; }
#directoryTree .folder-name::before { content: '📁 '; }

/* Right Panel: Content View */
.content-panel {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-header {
  padding: 0.75rem 1rem;
  background: var(--color-panel-bg);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  z-index: 10;
}

.controls-bar { display: flex; align-items: center; gap: 15px; margin-bottom: 10px; }
.controls-bar label { font-weight: bold; }
.controls-bar select {
    padding: 5px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

#breadcrumbs {
  font-size: 1rem;
  color: #555;
}
#breadcrumbs a {
  color: var(--color-header);
  text-decoration: none;
}
#breadcrumbs a:hover { text-decoration: underline; }
#breadcrumbs span { margin: 0 5px; color: #777; }

.file-list {
  padding: 1rem;
  overflow-y: auto;
  flex-grow: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  align-content: flex-start;
}

.file-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
}
.file-item:hover {
  background-color: var(--color-hover);
  border-color: var(--color-active);
}
.file-item .icon { font-size: 48px; }
.file-item .name {
  margin-top: 8px;
  word-break: break-word;
  font-size: 13px;
}
/* Icons */
.file-item[data-type="folder"] .icon::before { content: '📁'; }
.file-item[data-type="mp3"] .icon::before, .file-item[data-type="audio"] .icon::before { content: '🎵'; }
.file-item[data-type="mp4"] .icon::before, .file-item[data-type="video"] .icon::before { content: '🎬'; }
.file-item[data-type="txt"] .icon::before, .file-item[data-type="text"] .icon::before { content: '📄'; }
.file-item[data-type="pdf"] .icon::before { content: '📕'; }

/* Media Viewer (Modal) */
.media-viewer {
  display: none; /* Hidden by default */
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background-color: rgba(0,0,0,0.7);
  flex-direction: column;
  padding: 2rem;
  z-index: 100;
}

#mediaPlayer {
    flex-grow: 1;
    color: #000;
    /* Use Flexbox to center the content (the video/audio player) */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Hide any potential overflow */
}

#mediaPlayer pre {
    background-color: white;
    white-space: pre-wrap;
    padding: 1rem;
    width: 100%;
    height: 100%;
    overflow-y: auto;
}

#mediaPlayer video, #mediaPlayer audio {
    display: block;
    /* Ensure the player never exceeds the container's bounds */
    max-width: 100%;
    max-height: 100%;
    /* Let the browser determine the height to maintain aspect ratio */
    height: auto;
    width: auto;
}

#closeViewerBtn {
    position: absolute; top: 1rem; right: 1rem;
    font-size: 1.5rem; color: white; background: none; border: none; cursor: pointer;
}
#readAloudBtn {
    position: absolute; top: 1rem; right: 4rem;
    font-size: 1.5rem; color: white; background: none; border: none; cursor: pointer;
    display: none; /* Hidden until a text file is open */
}

@media (max-width: 768px) {
    .container { flex-direction: column; }
    .tree-panel { width: 100%; height: 200px; border-right: none; border-bottom: 1px solid var(--color-border); }
    .file-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}