/* styles.css — visor RAR para Drive.
   Dirección: herramienta utilitaria que debe sentirse INSTANTÁNEA y de
   confianza (el pitch es "tu archivo nunca sale de tu navegador").
   - Fuentes del sistema: cero latencia de webfonts en una app que se abre
     desde un menú contextual.
   - Firma visual: las barras de tamaño relativo integradas en el árbol
     (se ve de un vistazo qué pesa dentro del archivo) en verde azulado.
   - Todo lo demás, quieto y disciplinado. */

:root {
  --paper: #f7f7f4;
  --ink: #22262d;
  --ink-soft: #6a7180;
  --line: #e2e2dc;
  --accent: #0f766e;        /* verde azulado: acción y barras */
  --accent-soft: #0f766e22;
  --warn: #b45309;
  --err: #b91c1c;
  --ok: #15803d;
  --card: #ffffff;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16181d; --ink: #e8e8e3; --ink-soft: #9aa1ad;
    --line: #2b2f37; --card: #1e2128; --accent: #2dd4bf;
    --accent-soft: #2dd4bf1f;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--paper); color: var(--ink);
  display: flex; flex-direction: column;
}

header {
  display: flex; align-items: baseline; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
header h1 { font-size: 16px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
header .privacy {
  font-size: 12.5px; color: var(--ink-soft);
}
header .privacy::before {
  content: "●"; color: var(--accent); margin-right: 5px; font-size: 9px;
  vertical-align: 1px;
}

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
[hidden] { display: none !important; }

/* ---------- drop zone ---------- */
#view-drop {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 14px; margin: 24px;
  border: 1.5px dashed var(--line); border-radius: 10px;
  transition: border-color .15s, background .15s;
}
#view-drop.hover { border-color: var(--accent); background: var(--accent-soft); }
#view-drop .big { font-size: 17px; font-weight: 600; }
#view-drop .sub { color: var(--ink-soft); font-size: 13.5px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
  padding: 9px 18px; border-radius: 7px;
}
.btn.ghost { background: transparent; color: var(--accent);
  border: 1px solid var(--accent); }
.btn:hover { filter: brightness(1.08); }

/* ---------- loading ---------- */
#view-loading {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px;
}
#loading-msg { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.progress { width: min(420px, 80%); height: 5px; background: var(--line);
  border-radius: 3px; overflow: hidden; }
#loading-bar { height: 100%; background: var(--accent); width: 0;
  transition: width .2s; border-radius: 3px; }
#loading-bar.indet { width: 40% !important;
  animation: slide 1.1s ease-in-out infinite alternate; }
@keyframes slide { from { margin-left: 0 } to { margin-left: 60% } }
@media (prefers-reduced-motion: reduce) {
  #loading-bar.indet { animation: none; width: 100% !important; opacity: .5; }
}

/* ---------- arbol ---------- */
#view-tree { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tree-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 14px 20px 10px;
}
#archive-name { font-weight: 650; font-size: 15.5px; overflow-wrap: anywhere; }
#archive-meta { color: var(--ink-soft); font-size: 13px; font-family: var(--mono); }
.tree-head .spacer { flex: 1; }

#tree {
  flex: 1; overflow: auto; margin: 0 20px 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 6px;
}
.node .children { margin-left: 20px; display: none; }
.node.open > .children, .node.root > .children { display: block; }
.row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 8px; border-radius: 6px; min-height: 30px;
}
.row:hover { background: var(--accent-soft); }
.row.dir { cursor: pointer; font-weight: 600; }
.node.open > .row .chev { transform: rotate(90deg); }
.chev { width: 14px; color: var(--ink-soft); transition: transform .12s;
  flex: none; font-size: 11px; }
.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sizebar {
  flex: 1; height: 4px; border-radius: 2px; margin: 0 6px;
  background:
    linear-gradient(to right, var(--accent) var(--w), transparent var(--w));
  opacity: .55; min-width: 40px;
}
.size { font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  flex: none; min-width: 64px; text-align: right; }
.act {
  font: inherit; background: none; border: 0; cursor: pointer;
  border-radius: 5px; padding: 2px 6px; opacity: .45; flex: none;
}
.row:hover .act { opacity: 1; }
.act:hover { background: var(--line); opacity: 1; }
.act:focus-visible { opacity: 1; }

/* ---------- error ---------- */
#view-error {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px; text-align: center; padding: 24px;
}
#error-msg { font-size: 16px; max-width: 46ch; }
#error-extra { color: var(--ok); font-weight: 600; }
#pw-form { display: flex; gap: 8px; }
input[type=password], input[type=text] {
  font: inherit; padding: 8px 12px; border: 1px solid var(--line);
  border-radius: 7px; background: var(--card); color: var(--ink);
  min-width: 220px;
}
input:focus-visible, .btn:focus-visible, .act:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- modales ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 12px; padding: 22px;
  background: var(--card); color: var(--ink);
  max-width: min(680px, 92vw);
}
dialog::backdrop { background: #0007; }
#preview-body { max-height: 70vh; overflow: auto; margin-top: 10px; }
#preview-body img { max-width: 100%; border-radius: 6px; }
#preview-body iframe { width: 80vw; max-width: 640px; height: 65vh; border: 0; }
#preview-body pre { font-family: var(--mono); font-size: 12.5px;
  white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.dlg-head { display: flex; align-items: center; gap: 10px; }
.dlg-head h2 { font-size: 15px; margin: 0; flex: 1; overflow-wrap: anywhere; }
.badge {
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  background: var(--accent); color: #fff; border-radius: 4px; padding: 2px 6px;
}
#paywall-reason { color: var(--ink-soft); }
#license-form { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex;
  flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  background: var(--ink); color: var(--paper); padding: 10px 15px;
  border-radius: 8px; font-size: 13.5px; max-width: 340px;
  box-shadow: 0 4px 14px #0004; transition: opacity .35s, transform .35s;
}
.toast-ok { background: var(--ok); color: #fff; }
.toast-err { background: var(--err); color: #fff; }
.toast-warn { background: var(--warn); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }

@media (max-width: 560px) {
  .sizebar { display: none; }
  .act { opacity: .7; }
  header { flex-direction: column; gap: 2px; }
}
