/* ═══════════════════════════════════════════════════════════════════════
   NAS Casero — hoja de estilos
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --bg: #0e1116;
  --bg-soft: #131822;
  --panel: #161c26;
  --panel-2: #1b2230;
  --border: #232c3a;
  --border-soft: #1d2532;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.12);
  --ok: #3fb950;
  --warn: #d29922;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --topbar-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
code {
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.86em;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* ───────────────────────────── botones ───────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
  white-space: nowrap;
}
.btn:hover { background: #232c3c; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #3f7cf0; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn.danger:hover { background: #e03c34; }
.btn.block { width: 100%; padding: 11px 16px; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex: none;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.small { width: 28px; height: 28px; font-size: 20px; line-height: 1; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ───────────────────────────── vistas ───────────────────────────── */

.view { height: 100%; }
.view.auth {
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(79, 140, 255, 0.13), transparent 70%),
    var(--bg);
}

.card {
  width: 100%;
  max-width: 470px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 30px 28px;
  box-shadow: var(--shadow);
}
.card h1 { font-size: 23px; margin: 14px 0 4px; letter-spacing: -0.02em; }
.card > .muted { margin: 0 0 22px; font-size: 14px; }
.logo {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(79, 140, 255, 0.28);
}

.field { display: block; margin-bottom: 16px; }
.field > span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #c3cedb;
  margin-bottom: 7px;
}
.field > small { display: block; color: var(--muted); font-size: 12px; margin-top: 6px; }

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}
input::placeholder { color: #5d6a7c; }

.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(248, 81, 73, 0.3);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  margin: 14px 0 0;
}
.hint { color: var(--muted); font-size: 12.5px; text-align: center; margin: 16px 0 0; }

/* ─────────────────── asistente: carpetas ─────────────────── */

.roots-editor { display: grid; gap: 8px; margin-bottom: 10px; }
.root-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; }
.root-row input { font-size: 14px; padding: 9px 11px; }
.root-row .icon-btn { color: var(--muted); }
.drive-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: #c3cedb;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
}
.chip:hover { border-color: var(--accent); color: #fff; }

/* ─────────────────────────── topbar ─────────────────────────── */

#view-app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: 14px;
  color: #dbe6f2;
  flex: none;
}
.brand svg { color: var(--accent); }

.volumes {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}
.volumes::-webkit-scrollbar { display: none; }
.volume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.volume:hover { color: var(--text); border-color: #33405a; }
.volume.active {
  background: var(--accent-soft);
  border-color: rgba(79, 140, 255, 0.45);
  color: #cfe0ff;
}

.top-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.disk-info { font-size: 12.5px; color: var(--muted); margin-right: 6px; white-space: nowrap; }

/* ─────────────────────────── toolbar ─────────────────────────── */

.toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  min-height: 58px;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumb {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 5px 7px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.crumb:hover { background: var(--panel-2); color: var(--text); }
.crumb.current { color: var(--text); font-weight: 600; }
.crumb-sep { color: #3d4a5c; user-select: none; }
.tool-actions { display: flex; align-items: center; gap: 6px; flex: none; }

/* ─────────────────────────── lista ─────────────────────────── */

.content {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 90px;
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.list-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 165px 132px;
  gap: 12px;
  padding: 12px 14px 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  position: sticky;
  top: 0;
  background: linear-gradient(var(--bg) 78%, transparent);
  z-index: 5;
}

.file-list { list-style: none; margin: 0; padding: 0 0 20px; }

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 165px 132px;
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: default;
}
.row:hover { background: var(--panel); }
.row-main {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  cursor: pointer;
}
.row-ico { flex: none; width: 30px; display: grid; place-items: center; }
.row-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14.5px;
}
.row.is-dir .row-name { font-weight: 550; }
.row-meta { display: none; font-size: 12px; color: var(--muted); }
.row-size, .row-date { font-size: 13px; color: var(--muted); white-space: nowrap; }
.row-actions { display: flex; justify-content: flex-end; gap: 0; opacity: 0.55; transition: opacity 0.12s; }
.row:hover .row-actions, .row:focus-within .row-actions { opacity: 1; }
.row-actions .icon-btn { width: 30px; height: 30px; }
.row-actions .icon-btn svg { width: 16px; height: 16px; }

.empty {
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 70px 20px;
  color: #54637a;
  text-align: center;
}
.empty p { margin: 6px 0 0; color: #93a2b6; font-size: 15px; }
.empty span { font-size: 13px; }

/* ───────────────────────── arrastrar y soltar ───────────────────────── */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 14, 20, 0.82);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  pointer-events: none;
}
.drop-box {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 44px 60px;
  border: 2px dashed var(--accent);
  border-radius: 20px;
  background: rgba(79, 140, 255, 0.07);
  color: #cfe0ff;
}
.drop-box strong { font-size: 18px; }
.drop-box span { font-size: 13px; color: var(--muted); }

/* ─────────────────────────── subidas ─────────────────────────── */

.transfers {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 370px;
  max-width: calc(100vw - 24px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 70;
  overflow: hidden;
}
.transfers-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13.5px;
  font-weight: 600;
}
.transfer-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.transfer {
  padding: 7px 9px;
  border-radius: 9px;
}
.transfer:hover { background: var(--panel-2); }
.transfer-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.8px;
  margin-bottom: 5px;
}
.transfer-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transfer-state { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.transfer-state.error { color: var(--danger); }
.transfer-state.done { color: var(--ok); }
.bar {
  height: 4px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s linear;
}
.transfer.error .bar > i { background: var(--danger); }
.transfer.done .bar > i { background: var(--ok); }

/* ─────────────────────────── toasts ─────────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 200;
  display: grid;
  gap: 8px;
  width: min(460px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 14px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  animation: toastIn 0.18s ease-out;
}
.toast.error { border-color: rgba(248, 81, 73, 0.45); color: #ffb4ae; }
.toast.ok { border-color: rgba(63, 185, 80, 0.4); }
.toast button {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ─────────────────────────── modales ─────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 13, 0.72);
  backdrop-filter: blur(2px);
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade 0.12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.modal.wide { max-width: 980px; }
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-head h2 { font-size: 15.5px; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg-soft);
}

.preview-wrap {
  display: grid;
  place-items: center;
  min-height: 200px;
  background: #080b10;
  border-radius: 10px;
  overflow: hidden;
}
.preview-wrap img, .preview-wrap video {
  max-width: 100%;
  max-height: 74vh;
  display: block;
}
.preview-wrap audio { width: 100%; padding: 20px; }
.preview-wrap iframe { width: 100%; height: 74vh; border: 0; background: #fff; }
.preview-wrap pre {
  margin: 0;
  padding: 16px;
  width: 100%;
  max-height: 74vh;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color: #c8d4e3;
  background: #0b0f15;
}
.modal-foot .spacer { margin-right: auto; }

.share-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.link-row { display: flex; gap: 8px; margin-top: 14px; }
.link-row input {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px;
  background: #0b0f15;
}
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.share-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
}
.share-item .si-main { min-width: 0; flex: 1; }
.share-item .si-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-item .si-meta { font-size: 11.5px; color: var(--muted); }

/* ─────────────────────────── móvil ─────────────────────────── */

@media (max-width: 720px) {
  .toolbar { flex-wrap: wrap; min-height: 0; padding: 8px 10px; gap: 6px; }
  .crumbs { order: 2; width: 100%; flex-basis: 100%; }
  .tool-actions { margin-left: auto; }
  .list-head { display: none; }
  .content { padding: 0 4px 100px; }
  .row {
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 10px;
    gap: 6px;
    border-bottom: 1px solid var(--border-soft);
    border-radius: 0;
  }
  .row:hover { background: transparent; }
  .row-size, .row-date { display: none; }
  .row-meta { display: block; }
  .row-actions { opacity: 1; gap: 0; }
  .row-actions .icon-btn { width: 28px; height: 28px; }
  .disk-info { display: none; }
  .transfers { right: 8px; left: 8px; bottom: 8px; width: auto; }
  .card { padding: 24px 18px; border-radius: 14px; }
  .root-row { grid-template-columns: 1fr auto; }
  .root-row input:nth-child(2) { grid-column: 1 / -1; }
}

@media (max-width: 420px) {
  .brand span { display: none; }
  .row-name { font-size: 14px; }
}
