/* =====================================================================
   Econarya – Archivos · estilo de gestor de escritorio clásico
   ===================================================================== */
:root {
  --font: "Segoe UI", "DejaVu Sans", "Noto Sans", Ubuntu, Cantarell, Arial, sans-serif;
  --win-bg: #e6e6e6;
  --panel-bg: #ededed;
  --content-bg: #f9f9f9;
  --border: #b4b4b4;
  --border-light: #d2d2d2;
  --text: #222;
  --text-2: #666;
  --text-3: #8a8a8a;
  --sel: #c7dff5;
  --sel-border: #86b6e4;
  --hover: #e4eff9;
  --hover-border: #b9d3ee;
  --menu-hl: #3d8fd8;
  --icon: 64px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 13px; color: var(--text);
  background: #c9ccd1 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4'%3E%3Crect width='4' height='4' fill='%23cfd2d7'/%3E%3Crect width='1' height='1' fill='%23c5c8cd'/%3E%3C/svg%3E");
  overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: default; }
a { color: inherit; text-decoration: none; }
hr { border: 0; border-top: 1px solid var(--border-light); margin: 3px 1px; }
.hidden, [hidden] { display: none !important; }
input, textarea { user-select: text; -webkit-user-select: text; }
svg.ic { width: 16px; height: 16px; flex: none; display: inline-block; vertical-align: middle; }

/* ---------- ventana ---------- */
.win { background: var(--win-bg); border: 1px solid #8f8f8f; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.35) inset; overflow: hidden; display: flex; flex-direction: column; }
.titlebar {
  height: 24px; display: flex; align-items: center; position: relative; flex: none;
  background: linear-gradient(#f4f4f4, #dcdcdc); border-bottom: 1px solid #b9b9b9;
}
.titlebar.small { height: 20px; }
.wbtns { display: flex; gap: 6px; padding-left: 8px; position: absolute; left: 0; top: 0; bottom: 0; align-items: center; }
.wbtns i { width: 11px; height: 11px; border-radius: 50%; border: 1px solid #8e8e8e; background: linear-gradient(#fdfdfd, #c4c4c4); box-shadow: 0 1px 0 rgba(255,255,255,.7); }
.wbtns i:first-child { cursor: pointer; }
.wbtns i:first-child:hover { background: linear-gradient(#ff9a92, #e3433a); border-color: #b03229; }
.wtitle { flex: 1; text-align: center; font-weight: 600; font-size: 13px; color: #333; text-shadow: 0 1px 0 #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 70px; }

/* ---------- barra de herramientas ---------- */
.toolbar { display: flex; align-items: center; gap: 6px; padding: 5px 8px; background: linear-gradient(#ebebeb, #e1e1e1); border-bottom: 1px solid #bcbcbc; flex: none; }
.tgroup { display: inline-flex; border: 1px solid #a9a9a9; border-radius: 4px; background: linear-gradient(#fdfdfd, #e3e3e3); box-shadow: 0 1px 0 rgba(255,255,255,.8), 0 1px 1px rgba(0,0,0,.08); overflow: hidden; }
.tbtn { width: 30px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-right: 1px solid #c4c4c4; background: none; color: #444; padding: 0; }
.tbtn:last-child { border-right: 0; }
.tbtn svg { width: 16px; height: 16px; }
.tbtn:hover { background: linear-gradient(#fff, #eaeaea); color: #111; }
.tbtn:active, .tbtn.active { background: linear-gradient(#cfcfcf, #dadada); box-shadow: inset 0 1px 3px rgba(0,0,0,.25); color: #111; }
.tbtn[disabled] { color: #b0b0b0; pointer-events: none; }
.tspacer { flex: 1; }
.searchbar { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: #f3f3f3; border-bottom: 1px solid #c8c8c8; }
.searchbar input { flex: 1; max-width: 420px; }

/* ---------- controles ---------- */
.btn { height: 24px; padding: 0 12px; border: 1px solid #9a9a9a; border-radius: 3px; background: linear-gradient(#fdfdfd, #e2e2e2); box-shadow: 0 1px 0 rgba(255,255,255,.8); color: #222; }
.btn:hover { background: linear-gradient(#fff, #ececec); }
.btn:active { background: linear-gradient(#d4d4d4, #e2e2e2); box-shadow: inset 0 1px 2px rgba(0,0,0,.2); }
.btn.sm { height: 22px; padding: 0 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
input[type="text"], input[type="password"], input[type="search"], textarea {
  height: 24px; padding: 0 6px; border: 1px solid #9a9a9a; border-radius: 3px; background: #fff; outline: none; box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
input:focus, textarea:focus { border-color: #5a9bdc; box-shadow: 0 0 0 2px rgba(90,155,220,.3); }
textarea { height: auto; padding: 6px; resize: none; font-family: "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace; font-size: 12.5px; line-height: 1.45; }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; }
.login-win { width: 400px; }
.login-body { display: flex; flex-direction: column; align-items: center; padding: 26px 32px 18px; background: linear-gradient(#f7f7f7, #ededed); }
.login-ico svg { width: 72px; height: 72px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.18)); }
.login-title { margin: 12px 0 2px; font-size: 22px; font-weight: 400; letter-spacing: .5px; color: #333; text-shadow: 0 1px 0 #fff; }
.login-title span { font-weight: 700; color: #2b6cb0; }
.login-sub { margin: 0 0 20px; font-size: 12px; color: #8c8c8c; }
.login-body input { width: 100%; height: 30px; font-size: 14px; text-align: center; }
.login-body .btn { margin-top: 12px; min-width: 110px; height: 28px; }
.login-error { color: #c0392b; margin: 8px 0 0; font-size: 12px; }
.login-foot { padding: 8px 12px; font-size: 11px; color: #8c8c8c; text-align: center; border-top: 1px solid #c8c8c8; background: linear-gradient(#e6e6e6, #dcdcdc); }

/* ---------- aplicación ---------- */
.app { position: fixed; inset: 0; border-radius: 0; border: 0; box-shadow: none; }
.body { flex: 1; display: flex; min-height: 0; }

/* lugares */
.places { width: 150px; flex: none; background: var(--panel-bg); border-right: 1px solid #c3c3c3; padding: 6px 4px; overflow: auto; display: flex; flex-direction: column; }
.ptitle { color: #8c8c8c; font-size: 12px; padding: 4px 8px 2px; }
.plist { display: flex; flex-direction: column; }
.place { display: flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 3px; border: 1px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 21px; }
.place:hover { background: #e2e2e2; }
.place.active { background: #d7d7d7; border-color: #c4c4c4; }
.place.drop-target { background: var(--sel); border-color: var(--sel-border); }
.pico { width: 16px; height: 16px; display: inline-flex; flex: none; }
.pico svg { width: 16px; height: 16px; }
.pspace { flex: 1; }
.pstorage { color: #8c8c8c; font-size: 11px; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* principal */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--content-bg); }
.crumbbar { height: 24px; display: flex; align-items: center; gap: 2px; padding: 0 8px; background: linear-gradient(#f4f4f4, #ececec); border-bottom: 1px solid #d6d6d6; overflow: hidden; white-space: nowrap; }
.crumb { display: inline-flex; align-items: center; gap: 4px; padding: 1px 5px; border-radius: 3px; color: #333; font-weight: 600; }
.crumb:hover { background: #dedede; }
.crumb.drop-target { background: var(--sel); outline: 1px solid var(--sel-border); }
.crumb-sep { color: #555; font-size: 10px; padding: 0 1px; }
.crumb .pico { width: 16px; height: 16px; }

.selbar { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #eef5fc; border-bottom: 1px solid #c3d7ec; flex-wrap: wrap; }
.selbar-actions { display: inline-flex; gap: 4px; }
.selbar .trash-only { display: none; }
.selbar.trash .trash-only { display: inline-flex; }
.selbar.trash .selbar-actions:not(.trash-only) { display: none; }
.selbar #sel-clear { margin-left: auto; }

.content { flex: 1; overflow: auto; padding: 16px 18px; position: relative; }
.files:focus { outline: none; }

/* --- vista de iconos --- */
.files.grid { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 14px 10px; }
.grid .item { width: calc(var(--icon) + 52px); min-width: 100px; padding: 10px 4px 8px; border: 1px solid transparent; border-radius: 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.grid .thumb { width: var(--icon); height: var(--icon); display: grid; place-items: center; position: relative; }
.grid .thumb svg { width: 100%; height: 100%; }
.grid .thumb img { max-width: 100%; max-height: 100%; border: 1px solid #fff; box-shadow: 0 0 0 1px #bbb, 0 1px 3px rgba(0,0,0,.3); background: #fff; }
.grid .item-name { font-size: 12px; line-height: 1.25; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; width: 100%; }
.grid .item-meta, .grid .check { display: none; }
.item:hover { background: var(--hover); border-color: var(--hover-border); }
.item.selected { background: var(--sel); border-color: var(--sel-border); }
.item.drop-target { background: var(--sel); border-color: var(--sel-border); border-style: dashed; }
.item.dragging { opacity: .45; }
.item .fav-mark { position: absolute; left: -4px; top: -4px; width: 14px; height: 14px; display: none; }
.item.fav .fav-mark { display: block; }
.item .fav-mark svg { width: 14px; height: 14px; }

/* --- vista compacta --- */
.files.compact { display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; max-height: 100%; gap: 1px 10px; }
.compact .item { display: flex; align-items: center; gap: 6px; padding: 2px 6px; border: 1px solid transparent; border-radius: 3px; width: 190px; }
.compact .thumb { width: 22px; height: 22px; display: grid; place-items: center; position: relative; flex: none; }
.compact .thumb svg { width: 22px; height: 22px; }
.compact .thumb img { max-width: 22px; max-height: 22px; }
.compact .item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.compact .item-meta, .compact .check { display: none; }

/* --- vista de detalles --- */
.files.list { display: flex; flex-direction: column; }
.list .list-head { display: grid; grid-template-columns: 1fr 90px 150px 110px; gap: 8px; padding: 2px 8px; font-size: 12px; color: #555; background: linear-gradient(#f6f6f6, #e9e9e9); border: 1px solid #d0d0d0; border-radius: 3px 3px 0 0; }
.list .list-head span { border-right: 1px solid #d0d0d0; }
.list .list-head span:last-child { border: 0; }
.list .item { display: grid; grid-template-columns: 1fr 90px 150px 110px; gap: 8px; align-items: center; padding: 2px 8px; border: 1px solid transparent; font-size: 12px; }
.list .item:nth-child(odd) { background: #f1f3f6; }
.list .item:hover { background: var(--hover); }
.list .item.selected { background: var(--sel); border-color: var(--sel-border); }
.list .thumb { width: 18px; height: 18px; display: inline-grid; place-items: center; position: relative; vertical-align: middle; margin-right: 6px; }
.list .thumb svg { width: 18px; height: 18px; }
.list .thumb img { max-width: 18px; max-height: 18px; }
.list .item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; }
.list .item-name .origin { color: var(--text-3); margin-left: 8px; font-size: 11px; }
.list .item-meta { display: contents; }
.list .item-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #444; }
.list .check { display: none; }

.origin { color: var(--text-3); font-size: 11px; display: block; }
.grid .origin, .compact .origin { display: none; }

/* vacío */
.empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #777; gap: 4px; pointer-events: none; }
.empty strong { color: #444; font-weight: 600; }

/* barra de estado */
.statusbar { height: 24px; display: flex; align-items: center; gap: 10px; padding: 0 8px; background: linear-gradient(#f0f0f0, #e3e3e3); border-top: 1px solid #c6c6c6; font-size: 12px; color: #333; flex: none; }
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-text a { color: #1d63b0; text-decoration: underline; cursor: pointer; margin-left: 8px; }
.status-spacer { flex: 1; }
.zoom { display: inline-flex; align-items: center; gap: 4px; }
.zoom-ico { color: #777; font-size: 11px; }
input[type="range"] { -webkit-appearance: none; width: 110px; height: 14px; background: none; margin: 0; }
input[type="range"]::-webkit-slider-runnable-track { height: 5px; background: linear-gradient(#cfcfcf, #e8e8e8); border: 1px solid #a7a7a7; border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 15px; margin-top: -6px; border: 1px solid #8a8a8a; border-radius: 3px; background: linear-gradient(#fdfdfd, #d4d4d4); }

/* arrastre externo */
.drop-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(255,255,255,.7); opacity: 0; pointer-events: none; transition: opacity .1s; }
.main.dragover .drop-overlay { opacity: 1; }
.drop-box { border: 2px dashed #6fa6dc; border-radius: 6px; padding: 30px 50px; display: grid; justify-items: center; gap: 4px; color: #2b6cb0; background: #fff; }

/* ---------- menús ---------- */
.menu { position: fixed; z-index: 100; min-width: 190px; padding: 3px; background: #fbfbfb; border: 1px solid #9a9a9a; border-radius: 3px; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
.menu button { display: block; width: 100%; text-align: left; padding: 4px 22px; border: 0; background: none; border-radius: 2px; }
.menu button:hover { background: var(--menu-hl); color: #fff; }

/* ---------- ventanas emergentes ---------- */
.overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(0,0,0,.3); }
.dialog-win { width: 440px; }
.dialog-body { display: flex; gap: 14px; padding: 16px 16px 4px; }
.dialog-ico svg { width: 48px; height: 48px; }
.dialog-ico:empty { display: none; }
.dialog-main { flex: 1; min-width: 0; }
.dialog-main p { margin: 0 0 10px; line-height: 1.45; }
.dialog-main p:empty { display: none; }
.dialog-main input[type="text"] { width: 100%; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 6px; padding: 10px 16px 14px; }
.dialog-foot .btn { min-width: 84px; }

.details { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12.5px; }
.details dt { color: #666; text-align: right; }
.details dd { margin: 0; word-break: break-all; user-select: text; }

.folder-picker { border: 1px solid #a3a3a3; background: #fff; max-height: 260px; overflow: auto; padding: 2px; }
.fp-row { display: flex; align-items: center; gap: 4px; padding: 2px 4px; border-radius: 2px; white-space: nowrap; }
.fp-row:hover { background: var(--hover); }
.fp-row.selected { background: var(--sel); }
.fp-row .pico { width: 16px; height: 16px; }
.fp-toggle { width: 14px; height: 14px; display: inline-grid; place-items: center; color: #666; font-size: 9px; }
.fp-row.open .fp-toggle { transform: rotate(90deg); }
.fp-children { padding-left: 18px; display: none; }
.fp-row.open + .fp-children { display: block; }
.fp-dest { margin-top: 8px; color: #555; font-size: 12px; }

/* vista previa */
.preview-win { width: min(92vw, 1100px); height: min(90vh, 800px); }
.preview-meta { color: #555; font-size: 12px; padding: 0 6px; }
.preview-body { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #f3f3f3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='8' height='8' fill='%23ebebeb'/%3E%3Crect x='8' y='8' width='8' height='8' fill='%23ebebeb'/%3E%3C/svg%3E"); overflow: auto; padding: 10px; }
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 0 0 1px #bbb, 0 2px 8px rgba(0,0,0,.3); background: #fff; }
.preview-body video, .preview-body audio { max-width: 100%; max-height: 100%; }
.preview-body iframe { flex: 1; width: 100%; height: 100%; border: 1px solid #bbb; background: #fff; }
.preview-body textarea { flex: 1; width: 100%; height: 100%; }
.nopreview { text-align: center; color: #555; display: grid; justify-items: center; gap: 8px; }
.nopreview svg { width: 64px; height: 64px; }

/* transferencias */
.uploads { position: fixed; right: 16px; bottom: 36px; width: 340px; z-index: 80; }
.uploads-list { max-height: 220px; overflow: auto; padding: 6px; background: #fff; }
.uploads-foot { display: flex; justify-content: flex-end; padding: 5px 8px; border-top: 1px solid #c8c8c8; }
.uploads-foot { gap: 6px; }
.uploads-foot:not(:has(button:not([hidden]))) { display: none; }
.up-row { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; padding: 3px 4px; font-size: 12px; }
.up-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-pct { color: #666; }
.up-bar { grid-column: 1 / -1; height: 9px; border: 1px solid #9a9a9a; border-radius: 2px; background: #f4f4f4; overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: linear-gradient(#8ec6f5, #3f8bd6); transition: width .2s; }
.up-row.done .up-pct { color: #2e7d32; }
.up-row.error .up-pct { color: #c0392b; }
.up-row.error .up-bar i { background: #e57373; }

/* responsive */
@media (max-width: 700px) {
  .places { width: 120px; }
  .list .list-head, .list .item { grid-template-columns: 1fr 80px; }
  .list .item-meta span:nth-child(2), .list .item-meta span:nth-child(3), .list-head span:nth-child(3), .list-head span:nth-child(4) { display: none; }
  .dialog-win, .login-win { width: 94vw; }
}
