/* ============================================================
   File Explorer · Windows 11 Fluent / Glassmorphism design
   ============================================================ */
:root {
  --bg: #f3f3f3;
  --bg-grad: radial-gradient(at 20% 0%, #d4e4ff 0%, transparent 50%),
             radial-gradient(at 80% 100%, #ffd6f0 0%, transparent 50%),
             linear-gradient(180deg, #f7f9fc 0%, #eef1f6 100%);
  --surface: rgba(255,255,255,0.65);
  --surface-strong: rgba(255,255,255,0.85);
  --border: rgba(0,0,0,0.08);
  --text: #1c1c1e;
  --muted: #6b7280;
  --primary: #0067c0;
  --primary-hover: #0078d4;
  --accent: #8b5cf6;
  --danger: #d13438;
  --success: #107c10;
  --shadow: 0 8px 28px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --hover: rgba(0,0,0,0.04);
  --selected: rgba(0,103,192,0.12);
  --selected-border: rgba(0,103,192,0.45);
}
html[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-grad: radial-gradient(at 20% 0%, #1e3a8a40 0%, transparent 50%),
             radial-gradient(at 80% 100%, #7c3aed40 0%, transparent 50%),
             linear-gradient(180deg, #161618 0%, #0f0f12 100%);
  --surface: rgba(32,32,36,0.72);
  --surface-strong: rgba(40,40,46,0.92);
  --border: rgba(255,255,255,0.08);
  --text: #f5f5f7;
  --muted: #9ca3af;
  --primary: #60cdff;
  --primary-hover: #80d6ff;
  --hover: rgba(255,255,255,0.05);
  --selected: rgba(96,205,255,0.16);
  --selected-border: rgba(96,205,255,0.5);
  --shadow: 0 8px 28px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; }
body {
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  font-size: 14px;
  overflow: hidden;
}

.glass {
  background: var(--surface);
  backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ---------- Login ---------- */
.login-body { display:flex; align-items:center; justify-content:center; height:100vh; overflow:auto; }
.login-card { width: 380px; padding: 32px; border-radius: 16px; text-align:center; }
.login-logo { color: var(--primary); display:flex; justify-content:center; margin-bottom: 8px; }
.login-card h1 { margin: 4px 0; font-weight: 600; font-size: 22px; }
.login-card form { margin-top: 18px; text-align:left; display:flex; flex-direction:column; gap:8px; }
.login-card label { font-size: 12px; color: var(--muted); margin-top: 6px; }
.login-card input { padding:10px 12px; border-radius:8px; border:1px solid var(--border); background: var(--surface-strong); color: var(--text); }
.login-card .btn-primary { margin-top: 16px; }
.pw-wrap { position:relative; display:flex; }
.pw-wrap input { flex:1; padding-right:40px !important; }
.pw-toggle {
  position:absolute; right:4px; top:50%; transform:translateY(-50%);
  background:none; border:none; cursor:pointer; color:var(--muted); padding:6px;
  display:flex; align-items:center;
}
.pw-toggle:hover { color:var(--text); }
.remember-wrap { display:flex; align-items:center; gap:8px; cursor:pointer; font-size:13px; color:var(--text); margin-top:2px; }
.remember-wrap input[type=checkbox] { width:16px; height:16px; margin:0; cursor:pointer; }
.hint { font-size:12px; color: var(--muted); margin-top:14px; }
.alert { background:#fde7e9; color:#a4262c; padding:8px 12px; border-radius:8px; font-size:13px; }

/* ---------- App layout ---------- */
.app { display:flex; flex-direction:column; height:100vh; }

.topbar {
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:8px 12px; margin:8px; border-radius: var(--radius);
}
.topbar-left, .topbar-right { display:flex; align-items:center; gap:6px; }
.topbar-center { flex:1; max-width:560px; }
.icon-btn {
  background: transparent; border: 1px solid transparent;
  width:34px; height:34px; border-radius:8px; cursor:pointer;
  display:inline-flex; align-items:center; justify-content:center;
  color: var(--text); font-size:15px; transition: all .15s ease;
  text-decoration: none;
}
.icon-btn:hover { background: var(--hover); border-color: var(--border); }
.icon-btn.active { background: var(--selected); border-color: var(--selected-border); }
.search-wrap { position:relative; width:100%; }
.search-icon { position:absolute; left:12px; top:50%; transform:translateY(-50%); opacity:.55; }
#search {
  width:100%; padding:9px 14px 9px 36px;
  border-radius: 999px; border:1px solid var(--border);
  background: var(--surface-strong); color: var(--text);
  font-size: 13px; outline: none; transition: all .2s;
}
#search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,103,192,0.15); }
.view-switch { display:flex; gap:2px; padding:2px; border:1px solid var(--border); border-radius:10px; }
.user-chip { display:flex; align-items:center; gap:8px; padding:4px 10px; border-radius:999px; background: var(--surface-strong); font-size: 12px; }

.breadcrumb {
  display:flex; align-items:center; gap:4px; margin-left:6px; flex-wrap:nowrap; overflow:hidden;
}
.breadcrumb .crumb {
  padding:4px 10px; border-radius:6px; cursor:pointer; white-space:nowrap;
  color: var(--text); font-weight:500;
}
.breadcrumb .crumb:hover { background: var(--hover); }
.breadcrumb .sep { color: var(--muted); opacity:.6; }

.layout {
  display:grid; grid-template-columns: 240px 1fr auto;
  gap: 8px; padding: 0 8px 8px; flex:1; min-height:0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-radius: var(--radius); padding:12px 8px;
  overflow-y:auto; display:flex; flex-direction:column;
}
.sb-group { margin-bottom:16px; }
.sb-title { font-size: 11px; text-transform: uppercase; letter-spacing:.05em; color: var(--muted); padding: 6px 10px; }
.sb-item {
  display:flex; align-items:center; gap:10px;
  padding: 8px 10px; border-radius:8px; cursor:pointer;
  color: var(--text); text-decoration:none; font-size:13px;
  transition: background .15s;
}
.sb-item:hover { background: var(--hover); }
.sb-item.active { background: var(--selected); }
.sb-item span:first-child { width:18px; text-align:center; }
.sb-stats { margin-top: auto; padding: 10px; font-size:11px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------- Main ---------- */
.main { display:flex; flex-direction:column; min-width:0; gap:8px; overflow:hidden; }

/* Upload zone */
.upload-zone {
  border-radius: var(--radius);
  padding: 20px; position:relative; overflow:hidden;
  transition: all .25s ease;
  border: 2px dashed transparent;
}
.upload-zone::before {
  content:""; position:absolute; inset:0; z-index:-1;
  background: linear-gradient(135deg, rgba(0,103,192,0.06), rgba(139,92,246,0.06));
  pointer-events:none;
}
.upload-zone.dragover {
  border-color: var(--primary);
  transform: scale(1.005);
  background: var(--surface-strong);
}
.upload-inner { display:flex; flex-direction:column; align-items:center; text-align:center; gap:8px; }
.upload-icon { color: var(--primary); animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.upload-zone h2 { margin: 4px 0; font-size: 18px; font-weight:600; }
.upload-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:center; margin-top:10px; }
.btn-primary, .btn-secondary {
  padding: 10px 18px; border-radius:8px; border:1px solid var(--border);
  cursor:pointer; font-size:13px; font-weight:500; transition: all .15s;
  display:inline-flex; align-items:center; gap:6px;
}
.btn-primary { background: var(--primary); color: white; border-color: transparent; }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--surface-strong); color: var(--text); }
.btn-secondary:hover { background: var(--hover); }
.progress-wrap { width: 100%; max-width: 420px; margin-top: 12px; }
.progress { height: 6px; border-radius: 999px; background: var(--hover); overflow:hidden; }
.progress-bar { height:100%; width:0%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .2s; }
.progress-label { font-size: 12px; color: var(--muted); margin-top:6px; }

.content-toolbar { display:flex; justify-content:space-between; align-items:center; padding: 0 6px; }
.ct-right { display:flex; align-items:center; gap:6px; font-size:12px; color: var(--muted); }
#sort-by {
  background: var(--surface-strong); color: var(--text);
  border: 1px solid var(--border); border-radius:6px; padding:4px 8px;
}

/* ---------- Content ---------- */
.content {
  flex:1; overflow:auto; padding: 6px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  backdrop-filter: blur(40px) saturate(180%);
}
.content.grid {
  display:grid; gap:8px; align-items:start;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.content.list, .content.details { display:flex; flex-direction:column; }

.card {
  position:relative; padding: 14px 10px; border-radius: 10px;
  cursor:pointer; transition: all .15s ease;
  display:flex; flex-direction:column; align-items:center; gap:6px;
  text-align:center; border: 1.5px solid transparent;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity:0; transform: translateY(4px);} to { opacity:1; transform:none; } }
.card:hover { background: var(--hover); }
.card.selected { background: var(--selected); border-color: var(--selected-border); }
.card .ico { font-size: 36px; line-height:1; }
.card .thumb { width: 100%; height: 120px; object-fit: cover; border-radius: 6px; display:block; }
.card .thumb.audio-thumb { height: auto; object-fit: contain; margin: 10px 0; }
.folder-card .ico { font-size: 64px; }
.card .name { font-size: 12.5px; word-break: break-word; max-width: 100%; }
.card .meta { font-size: 11px; color: var(--muted); }
.card .tag-label {
  margin-top:2px; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight:600;
  background: var(--primary); color: #fff;
  max-width: 100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}

/* List/details */
.content.list .card, .content.details .card {
  flex-direction:row; gap:14px; padding: 8px 12px; text-align:left;
  border-radius: 6px; border-bottom: 1px solid var(--border);
}
.content.list .card .ico, .content.details .card .ico { font-size: 22px; width: 32px; }
.content.list .card .name { flex:1; font-size: 13px; }
.content.details .card { display:grid; grid-template-columns: 32px 2fr 1fr 1fr 1fr; align-items:center; }

.empty {
  padding: 60px 20px; text-align:center; color: var(--muted);
}

/* ---------- Chat ---------- */
#chat-btn { position:relative; }
.unread-badge {
  position:absolute; top:-4px; right:-4px;
  background: var(--danger); color: #fff;
  font-size: 10px; min-width: 16px; height: 16px; line-height:16px;
  border-radius: 8px; text-align:center; padding: 0 4px; font-weight:700;
}
.chat-panel {
  width: 340px; border-radius: var(--radius);
  display:flex; flex-direction:column;
  animation: slideIn .25s ease;
  overflow:hidden;
}
.chat-head {
  display:flex; justify-content:space-between; align-items:center;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight:600;
}
.chat-head-actions { display:flex; gap:4px; }
.chat-users-list {
  padding: 8px 14px; border-bottom: 1px solid var(--border);
  display:flex; flex-wrap:wrap; gap:6px;
}
.chat-users-list .chat-user-tag {
  padding: 3px 10px; border-radius: 12px; font-size: 12px;
  background: var(--hover); border: 1px solid var(--border);
}
.chat-users-list .chat-user-tag.admin { border-color: var(--primary); color: var(--primary); }
.chat-messages {
  flex:1; overflow-y:auto; padding: 12px 14px;
  display:flex; flex-direction:column; gap:8px;
}
.chat-msg { display:flex; flex-direction:column; max-width: 85%; }
.chat-msg.mine { align-self:flex-end; }
.chat-msg .msg-user { font-size: 11px; color: var(--primary); font-weight:600; margin-bottom:1px; }
.chat-msg .msg-text { 
  padding: 8px 12px; border-radius: 12px; font-size: 13px; word-break:break-word;
  background: var(--hover);
}
.chat-msg.mine .msg-text { background: var(--selected); }
.chat-msg .msg-time { font-size: 10px; color: var(--muted); margin-top:2px; }
.chat-input-wrap {
  display:flex; gap:8px; padding: 10px 14px; border-top: 1px solid var(--border);
}
.chat-input-wrap input {
  flex:1; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-strong); color: var(--text);
}
.chat-input-wrap .btn-primary { padding: 6px 14px; font-size:13px; }

/* ---------- Preview ---------- */
.preview {
  width: 320px; border-radius: var(--radius);
  display:flex; flex-direction:column;
  animation: slideIn .25s ease;
  overflow:hidden;
}
@keyframes slideIn { from { opacity:0; transform: translateX(20px);} to { opacity:1; transform:none; } }
.preview-head {
  display:flex; justify-content:space-between; align-items:center;
  padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight:600;
}
.preview-body { padding: 14px; overflow:auto; flex:1; font-size: 13px; }
.preview-body img, .preview-body video { max-width: 100%; border-radius: 8px; }
.preview-body audio { width: 100%; }
.preview-body iframe, .preview-body pre { width: 100%; height: 360px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-strong); }
.preview-body pre { overflow:auto; padding: 10px; white-space: pre-wrap; }
.prop-row { display:flex; justify-content:space-between; padding: 4px 0; border-bottom: 1px dashed var(--border); font-size: 12px; }
.prop-row span:first-child { color: var(--muted); }

/* ---------- Context menu ---------- */
.context-menu {
  position: fixed; min-width: 200px; padding: 6px; border-radius: 10px;
  background: var(--surface-strong); border: 1px solid var(--border);
  box-shadow: var(--shadow); backdrop-filter: blur(40px) saturate(180%);
  z-index: 9999; animation: ctxIn .12s ease;
}
@keyframes ctxIn { from { opacity:0; transform: scale(.97);} to { opacity:1; transform:none; } }
.ctx-item {
  padding: 8px 12px; border-radius: 6px; cursor:pointer;
  display:flex; align-items:center; gap:10px; font-size:13px;
}
.ctx-item:hover { background: var(--selected); }
.ctx-sep { height:1px; background: var(--border); margin: 4px 2px; }
.ctx-item.danger { color: var(--danger); }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display:flex; flex-direction:column; gap:8px; z-index: 99999; }
.toast {
  padding: 12px 16px; border-radius: 10px; min-width: 220px;
  background: var(--surface-strong); border: 1px solid var(--border);
  box-shadow: var(--shadow); backdrop-filter: blur(40px) saturate(180%);
  animation: toastIn .25s ease;
  font-size: 13px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes toastIn { from { opacity:0; transform: translateX(20px);} to { opacity:1; transform:none; } }

[hidden] { display: none !important; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display:flex; align-items:center; justify-content:center; z-index: 9000;
  animation: fadeIn .15s ease;
}
.modal { width: 90%; max-width: 480px; border-radius: 12px; padding: 0; overflow:hidden; }
.modal-head { display:flex; justify-content:space-between; align-items:center; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight:600; }
.modal-body { padding: 16px; }
.modal-body input, .modal-body select {
  width:100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-strong); color: var(--text);
  margin-bottom: 12px;
}
.modal-actions { display:flex; justify-content:flex-end; gap:8px; }
.tree-pick { max-height: 260px; overflow:auto; border:1px solid var(--border); border-radius:8px; padding:6px; margin-bottom:12px; }
.tree-pick .t-item { padding:6px 10px; border-radius:6px; cursor:pointer; display:flex; align-items:center; gap:8px; font-size:13px; }
.tree-pick .t-item:hover { background: var(--hover); }
.tree-pick .t-item.selected { background: var(--selected); }

.muted { color: var(--muted); }
code { background: var(--hover); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display:none; }
  .preview { position: fixed; right: 8px; top: 70px; bottom: 8px; width: 90%; max-width: 360px; z-index: 50; }
  .topbar { flex-wrap: wrap; }
  .topbar-center { order: 3; width: 100%; max-width: 100%; }
}
