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

:root {
  --bg: #f0f0f0;
  --surface: #ffffff;
  --border: #d0d0d0;
  --border-light: #e8e8e8;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #999;
  --accent: #0067c0;
  --accent-light: #e5f0fb;
  --sel-bg: #cce8ff;
  --sel-border: #99d1ff;
  --hover-bg: #f5f5f5;
  --danger: #c42b1c;
  --danger-bg: #fde7e6;
  --font: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Noto Sans SC', sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
  --transition: 120ms ease;
}

html, body { height: 100%; font-family: var(--font); font-size: 13px; color: var(--text); background: var(--bg); }

/* ── Login ── */
#login-screen { display: flex; align-items: center; justify-content: center; height: 100%; }
#login-form { background: var(--surface); padding: 36px 32px; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 340px; display: flex; flex-direction: column; gap: 12px; }
#login-form h1 { font-size: 18px; font-weight: 600; text-align: center; margin-bottom: 4px; }
#login-form input { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: var(--font); outline: none; }
#login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
#login-form button { padding: 8px; background: var(--accent); color: #fff; border: 1px solid #005299; border-radius: var(--radius); font-size: 13px; cursor: pointer; }
#login-form button:hover { background: #005299; }
#login-error { color: var(--danger); font-size: 12px; display: none; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; height: 100%; }

/* ── Toolbar ── */
#toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#toolbar-left, #toolbar-center, #toolbar-right { display: flex; align-items: center; gap: 2px; }
#toolbar-center { flex: 1; justify-content: center; }
#toolbar button {
  width: 30px; height: 26px; border: 1px solid transparent; border-radius: var(--radius);
  background: none; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); transition: all var(--transition);
}
#toolbar button:hover { background: #e8e8e8; border-color: var(--border); }
#toolbar button:active { background: #d0d0d0; }
#toolbar button:disabled { opacity: 0.35; pointer-events: none; }
#toolbar button.view-active { background: #e0e0e0; border-color: var(--border); color: var(--text); }
.tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
#toolbar #btn-old-ui { width: auto; min-width: auto; padding: 0 10px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ── Address Bar ── */
#address-bar {
  display: flex; align-items: center; gap: 6px; padding: 4px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border-light); flex-shrink: 0;
}
#addr-label { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
#addr-input {
  flex: 1; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: var(--font-mono); font-size: 13px; outline: none; background: #fafafa;
}
#addr-input:focus { border-color: var(--accent); background: #fff; }
#addr-copy {
  width: 26px; height: 26px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-size: 13px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
#addr-copy:hover { background: #e8e8e8; }

/* ── Main Area ── */
#main-area { display: flex; flex: 1; min-height: 0; }

/* ── Sidebar ── */
#sidebar {
  width: 200px; min-width: 160px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto;
}
#sidebar-title { padding: 10px 14px 4px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
#sidebar-list { flex: 1; }
.sidebar-item {
  padding: 5px 14px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 6px;
  transition: background var(--transition); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-item:hover { background: var(--hover-bg); }
.sidebar-item.active { background: var(--sel-bg); color: var(--text); }
.sidebar-item .fav-icon { flex-shrink: 0; font-size: 14px; }
.sidebar-item .fav-name { overflow: hidden; text-overflow: ellipsis; }
.sidebar-item .fav-del { display: none; margin-left: auto; flex-shrink: 0; font-size: 11px; color: var(--text-muted); cursor: pointer; padding: 2px 4px; border-radius: 2px; }
.sidebar-item:hover .fav-del { display: block; }
.sidebar-item .fav-del:hover { background: var(--danger-bg); color: var(--danger); }
#sidebar-add { padding: 6px 14px; font-size: 12px; color: var(--accent); cursor: pointer; border-top: 1px solid var(--border-light); }
#sidebar-add:hover { background: var(--hover-bg); }
#sidebar-disk { padding: 8px 14px; font-size: 11px; color: var(--text-muted); border-top: 1px solid var(--border); line-height: 1.5; }

/* ── File Area ── */
#file-area { flex: 1; overflow: auto; position: relative; background: var(--surface); }

/* ── List View ── */
#list-view { height: 100%; }
#file-table { width: 100%; border-collapse: collapse; }
#file-table thead { position: sticky; top: 0; z-index: 2; background: #f5f5f5; }
#file-table th {
  padding: 6px 12px; text-align: left; font-weight: 500; font-size: 12px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border); user-select: none; white-space: nowrap;
}
#file-table th.sortable { cursor: pointer; }
#file-table th.sortable:hover { color: var(--text); background: #e8e8e8; }
.sort-arrow { font-size: 10px; }
#file-table td { padding: 5px 12px; border-bottom: 1px solid var(--border-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#file-table tbody tr { cursor: default; }
#file-table tbody tr:hover { background: var(--hover-bg); }
#file-table tbody tr.selected { background: var(--sel-bg); }
#file-table tbody tr.cut { opacity: 0.4; }
.col-select { width: 32px; text-align: center; }
.col-select input { cursor: pointer; vertical-align: middle; }
.col-size { width: 90px; }
.col-type { width: 80px; }
.col-date { width: 150px; }
.file-name { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.file-name:hover { text-decoration: underline; color: var(--accent); }
.file-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 16px; }
.file-size, .file-type, .file-date { color: var(--text-secondary); font-size: 13px; }
#empty-dir, #empty-dir-icons { display: none; text-align: center; padding: 60px 20px; color: var(--text-muted); font-size: 13px; }

/* ── Icon View ── */
#icon-view { height: 100%; overflow: auto; padding: 12px; }
#icon-grid { display: flex; flex-wrap: wrap; gap: 4px; }
.icon-item {
  width: 100px; padding: 8px 4px; cursor: default; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  border: 1px solid transparent; transition: all var(--transition);
}
.icon-item:hover { background: var(--hover-bg); border-color: var(--border-light); }
.icon-item.selected { background: var(--sel-bg); border-color: var(--sel-border); }
.icon-item.cut { opacity: 0.4; }
.icon-item .icon-big { font-size: 36px; line-height: 1; }
.icon-item .icon-name {
  font-size: 11px; text-align: center; word-break: break-all; line-height: 1.3;
  max-width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}

/* ── Status Bar ── */
#status-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 3px 12px; background: var(--surface); border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary); flex-shrink: 0;
}
#status-selected { color: var(--accent); }

/* ── Context Menu ── */
#context-menu {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 180px; z-index: 1000; padding: 2px 0;
}
.ctx-item {
  padding: 5px 24px 5px 24px; cursor: pointer; font-size: 13px; transition: background var(--transition);
  position: relative;
}
.ctx-item:hover { background: var(--accent-light); }
.ctx-item.disabled { color: var(--text-muted); pointer-events: none; }
.ctx-item .ctx-shortcut { position: absolute; right: 12px; color: var(--text-muted); font-size: 11px; }
.ctx-sep { height: 1px; background: var(--border-light); margin: 3px 0; }

/* ── Preview Modal ── */
#preview-modal {
  position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center;
}
#preview-modal.show { display: flex; }
#preview-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
#preview-box {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); max-width: 85vw; max-height: 85vh; width: 800px;
  display: flex; flex-direction: column; overflow: hidden;
}
#preview-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 500; }
#preview-header div { display: flex; align-items: center; gap: 10px; }
#preview-download { font-size: 12px; color: var(--accent); text-decoration: none; }
#preview-download:hover { text-decoration: underline; }
#preview-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary); padding: 0; line-height: 1; }
#preview-close:hover { color: var(--text); }
#preview-content { flex: 1; overflow: auto; padding: 16px; }
#preview-content img { max-width: 100%; height: auto; }
#preview-content pre { background: #1e1e1e; color: #d4d4d4; padding: 14px; border-radius: var(--radius); overflow: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.5; max-height: 60vh; }
.preview-info { color: var(--text-secondary); font-size: 13px; line-height: 1.8; }

/* ── Properties Modal ── */
#props-modal {
  position: fixed; inset: 0; z-index: 2000; display: none; align-items: center; justify-content: center;
}
#props-modal.show { display: flex; }
#props-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.35); }
#props-box {
  position: relative; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 420px; overflow: hidden;
}
#props-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 500; }
#props-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-secondary); padding: 0; line-height: 1; }
#props-close:hover { color: var(--text); }
#props-content { padding: 16px; }
.props-table { width: 100%; border-collapse: collapse; }
.props-table td { padding: 8px 0; font-size: 13px; vertical-align: top; }
.props-label { color: var(--text-muted); width: 80px; white-space: nowrap; }
.props-value { color: var(--text); word-break: break-all; }

/* ── Upload Toast ── */
#upload-toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 10px 16px; font-size: 12px; z-index: 3000; min-width: 240px;
}
.upload-progress-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.upload-progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ── Drop Overlay ── */
#drop-overlay {
  display: none; position: absolute; inset: 0; background: rgba(0,103,192,0.06);
  border: 2px dashed var(--accent); z-index: 10; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 500; color: var(--accent); pointer-events: none;
}
#drop-overlay.active { display: flex; }
