/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  background: #f0f0f0;
  color: #222;
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#app.app-hidden {
  display: none !important;
}

/* ===== Overlay / Dialog ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog {
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
  min-width: 360px;
  max-width: 480px;
  width: 100%;
}

.dialog-sm { min-width: 280px; max-width: 360px; }

.dialog-title {
  background: linear-gradient(180deg, #4a90d9 0%, #2a6db5 100%);
  color: #fff;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px 4px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dialog-icon { font-size: 18px; }

.dialog-body {
  padding: 18px 20px 10px;
}

.dialog-footer {
  padding: 10px 20px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-row {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.form-row label {
  width: 110px;
  font-weight: 500;
  flex-shrink: 0;
  text-align: right;
}

.form-row input {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #bbb;
  border-radius: 3px;
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
}

.form-row input:focus { border-color: #4a90d9; box-shadow: 0 0 0 2px rgba(74,144,217,.2); }

.error-msg {
  color: #c0392b;
  font-size: 12px;
  padding: 6px 0 2px;
}

/* ===== Buttons ===== */
.btn {
  padding: 5px 16px;
  border-radius: 3px;
  border: 1px solid #aaa;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
}

.btn-primary {
  background: linear-gradient(180deg, #5fa8e8 0%, #2a6db5 100%);
  color: #fff;
  border-color: #2a6db5;
}

.btn-primary:hover { background: linear-gradient(180deg, #74b8f0 0%, #3a80c8 100%); }

.btn-secondary {
  background: #f5f5f5;
  color: #333;
}

.btn-secondary:hover { background: #e8e8e8; }

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #f8f8f8 0%, #e8e8e8 100%);
  border-bottom: 1px solid #c0c0c0;
  padding: 4px 6px;
  gap: 4px;
  flex-shrink: 0;
}

.toolbar-left { display: flex; gap: 2px; }
.toolbar-right { display: flex; gap: 2px; }

.tool-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 3px 7px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  transition: background .1s, border-color .1s;
  white-space: nowrap;
}

.tool-btn:hover:not(:disabled) { background: #d8e8f8; border-color: #90b8e0; }
.tool-btn:active:not(:disabled) { background: #b8d4f0; }
.tool-btn:disabled { color: #aaa; cursor: default; }

.address-bar-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 3px;
  padding: 0 4px;
  margin: 0 6px;
}

.address-label { color: #666; white-space: nowrap; font-size: 12px; }

.address-bar {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  padding: 3px 2px;
  background: transparent;
}

/* ===== Breadcrumb ===== */
.breadcrumb-bar {
  background: #f5f5f5;
  border-bottom: 1px solid #ddd;
  padding: 3px 10px;
  font-size: 12px;
  color: #555;
  flex-shrink: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
}

.breadcrumb-seg {
  cursor: pointer;
  color: #1a6cb5;
  text-decoration: none;
}

.breadcrumb-seg:hover { text-decoration: underline; }
.breadcrumb-sep { color: #999; margin: 0 2px; }

/* ===== Main pane ===== */
.main-pane {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* ===== Tree panel ===== */
.tree-panel {
  width: 220px;
  min-width: 80px;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  border-right: 1px solid #c8c8c8;
  overflow: hidden;
}

.panel-header {
  background: linear-gradient(180deg, #e8e8e8 0%, #d8d8d8 100%);
  border-bottom: 1px solid #c0c0c0;
  padding: 4px 10px;
  font-weight: 600;
  font-size: 12px;
  color: #444;
  flex-shrink: 0;
}

.tree-content {
  overflow: auto;
  flex: 1;
  padding: 4px 0;
}

.tree-node {
  display: flex;
  align-items: center;
  padding: 2px 4px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.tree-node:hover { background: #daeaf8; }
.tree-node.selected { background: #c5ddf8; }

.tree-toggle {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #666;
  flex-shrink: 0;
}

.tree-icon {
  font-size: 14px;
  margin-right: 4px;
  flex-shrink: 0;
}

.tree-label { overflow: hidden; text-overflow: ellipsis; font-size: 12px; }

.tree-children { display: none; }
.tree-children.open { display: block; }

/* ===== Resizer ===== */
.resizer {
  width: 5px;
  background: #d0d0d0;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background .1s;
}

.resizer:hover, .resizer.dragging { background: #4a90d9; }

/* ===== File panel ===== */
.file-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.file-list-wrap {
  flex: 1;
  overflow: auto;
}

/* ===== File table ===== */
.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.file-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.file-table th {
  background: linear-gradient(180deg, #f0f0f0 0%, #e0e0e0 100%);
  border-right: 1px solid #c8c8c8;
  border-bottom: 2px solid #b0b0b0;
  padding: 5px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

.file-table th:last-child { border-right: none; }

.col-name  { width: 38%; }
.col-size  { width: 12%; }
.col-type  { width: 14%; }
.col-modified { width: 22%; }
.col-perms { width: 14%; }

.sortable { cursor: pointer; }
.sortable:hover { background: linear-gradient(180deg, #d8eaf8 0%, #c8daf0 100%); }

.sort-arrow { font-size: 10px; color: #666; }

.file-table tbody tr {
  cursor: default;
  border-bottom: 1px solid #f0f0f0;
}

.file-table tbody tr:hover { background: #e8f4ff; }
.file-table tbody tr.selected { background: #cce0ff; }
.file-table tbody tr.selected:hover { background: #b8d4ff; }

.file-table td {
  padding: 3px 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-icon { font-size: 14px; margin-right: 5px; }

.file-name-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.file-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr.is-dir .file-name-text { font-weight: 500; color: #1a4e8a; }
tr.is-dir:hover .file-name-text { text-decoration: underline; }

.size-cell { text-align: right; color: #444; }

/* ===== Status bar ===== */
.status-bar {
  background: linear-gradient(180deg, #e8e8e8 0%, #d8d8d8 100%);
  border-top: 1px solid #c0c0c0;
  padding: 3px 10px;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #444;
  flex-shrink: 0;
}

/* ===== Context Menu ===== */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #aaa;
  box-shadow: 3px 4px 12px rgba(0,0,0,.2);
  border-radius: 3px;
  z-index: 2000;
  min-width: 150px;
  padding: 3px 0;
}

.ctx-item {
  padding: 6px 18px;
  cursor: pointer;
  font-size: 13px;
  color: #222;
}

.ctx-item:hover { background: #4a90d9; color: #fff; }

.ctx-divider {
  border-top: 1px solid #ddd;
  margin: 3px 0;
}

/* ===== Download overlay ===== */
.dl-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.dl-box {
  background: #fff;
  border: 1px solid #aaa;
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  padding: 20px 28px;
  min-width: 340px;
  text-align: center;
}

.dl-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.dl-filename { font-size: 12px; color: #555; margin-bottom: 12px; word-break: break-all; }

.dl-progress-wrap {
  background: #e8e8e8;
  border-radius: 10px;
  height: 14px;
  overflow: hidden;
  margin-bottom: 6px;
}

.dl-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4a90d9, #2a6db5);
  border-radius: 10px;
  transition: width .2s;
}

.dl-size { font-size: 12px; color: #666; margin-bottom: 14px; }

/* ===== Loading spinner ===== */
.loading-row td {
  text-align: center;
  padding: 20px;
  color: #888;
  font-style: italic;
}

/* ===== Scrollbars ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ===== Empty state ===== */
.empty-state {
  padding: 30px;
  text-align: center;
  color: #aaa;
  font-size: 14px;
}
