/* Vault — dark, sober, product-grade. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../assets/fonts/inter-var-latin.woff2") format("woff2");
}

:root {
  --bg: #0d1017;
  --bg-raised: #12161f;
  --bg-elevated: #171c27;
  --bg-hover: #1c2230;

  --border: #232a38;
  --border-strong: #2e3747;

  --text: #e8edf4;
  --text-2: #9aa5b5;
  --text-3: #6b7688;

  --accent: #2e90fa;
  --accent-hover: #57a7ff;
  --accent-press: #1f7ce0;
  --accent-tint: rgba(46, 144, 250, 0.12);

  --ok: #32c48d;
  --danger: #f0596c;
  --warn: #e8a33d;

  --hair: rgba(151, 170, 200, 0.14);
  --hair-soft: rgba(151, 170, 200, 0.07);

  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 14px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow-panel: 0 12px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);

  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Texture di fondo stile "wallpaper chat": doodle a tema file/cloud,
   quasi impercettibile, sopra il colore base. */
body {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cg fill='none' stroke='%231a2130' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg transform='translate(18,26) rotate(-8)'%3E%3Cpath d='M0 3a2 2 0 0 1 2-2h5l2.2 2.6H20a2 2 0 0 1 2 2V14a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2z'/%3E%3C/g%3E%3Cg transform='translate(150,18) rotate(10)'%3E%3Crect x='0' y='7' width='15' height='11' rx='2'/%3E%3Cpath d='M3 7V5a4.5 4.5 0 0 1 9 0v2'/%3E%3C/g%3E%3Cg transform='translate(58,95) rotate(-6)'%3E%3Cpath d='M17.5 14A4.5 4.5 0 0 0 16 5.3 6.5 6.5 0 0 0 3.4 7.4 4 4 0 0 0 4 15'/%3E%3Cpath d='M10 16v-6m0 0-2.8 2.8M10 10l2.8 2.8'/%3E%3C/g%3E%3Cg transform='translate(160,120) rotate(7)'%3E%3Cpath d='M2 0h8l6 6v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2z'/%3E%3Cpath d='M10 0v6h6'/%3E%3C/g%3E%3Cg transform='translate(30,165) rotate(14)'%3E%3Ccircle cx='5' cy='5' r='4'/%3E%3Cpath d='M8 8l9 9m-3-1 2-2'/%3E%3C/g%3E%3Cg transform='translate(113,58)'%3E%3Cpath d='M4 0v8M0 4h8'/%3E%3C/g%3E%3Cg transform='translate(196,192)'%3E%3Cpath d='M3 0v6M0 3h6'/%3E%3C/g%3E%3Cg transform='translate(95,196) rotate(-10)'%3E%3Crect x='0' y='4' width='16' height='10' rx='2'/%3E%3Cpath d='M2 4V2.5A2.5 2.5 0 0 1 4.5 0h7A2.5 2.5 0 0 1 14 2.5V4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  background-size: 220px 220px;
}

.hidden { display: none !important; }

button { font-family: inherit; }

::selection { background: rgba(46, 144, 250, 0.35); }

/* ---------------------------------- */
/* Buttons                             */
/* ---------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-s);
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, transform 60ms ease;
  user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  transition: background-color 160ms var(--ease), transform 180ms var(--ease), box-shadow 200ms var(--ease);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -8px rgba(46, 144, 250, 0.55);
}
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled {
  background: var(--border-strong);
  color: var(--text-3);
  cursor: default;
  transform: none;
}

.btn-block { width: 100%; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-s);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all 120ms ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
  border-color: var(--border);
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent-hover); text-decoration: underline; }

/* ---------------------------------- */
/* Login                               */
/* ---------------------------------- */

.login-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}

.login-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 320px at 50% -80px, rgba(46, 144, 250, 0.14), transparent 70%),
    radial-gradient(800px 500px at 85% 110%, rgba(46, 144, 250, 0.05), transparent 60%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: min(400px, 100%);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  padding: 40px 36px 28px;
  box-shadow: var(--shadow-panel);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(160deg, #2e90fa, #1a6ad1);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46, 144, 250, 0.35);
}
.brand-mark svg { width: 18px; height: 18px; }

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.login-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.login-subtitle {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--text-2);
}

.login-error {
  min-height: 20px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--danger);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-2);
}

.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  color: var(--text);
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

#login-submit { margin-top: 6px; }

#login-submit.loading .btn-label {
  display: inline-block;
  animation: fade-pulse 1.2s ease-in-out infinite;
}

@keyframes fade-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.login-foot {
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* ---------------------------------- */
/* Topbar                              */
/* ---------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 16, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.brand .brand-mark svg { width: 16px; height: 16px; }
.brand .brand-name { font-size: 15.5px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
  flex: none;
}

.user-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

/* ---------------------------------- */
/* Online widget (HUD)                 */
/* ---------------------------------- */

.online-widget { position: relative; }

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 12px 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.online-pill:hover { border-color: var(--border-strong); background: var(--bg-hover); }

.pill-muted { color: var(--text-2); font-weight: 500; }

.pill-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-3);
  transition: transform 200ms var(--ease);
}
.online-widget:has(.online-panel.open) .pill-chevron { transform: rotate(180deg); }

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(50, 196, 141, 0.55);
  animation: pulse 2.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  flex: none;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(50, 196, 141, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(50, 196, 141, 0); }
  100% { box-shadow: 0 0 0 0 rgba(50, 196, 141, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot, #login-submit.loading .btn-label { animation: none; }
}

.online-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 352px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top right;
  pointer-events: none;
  transition: opacity 180ms var(--ease), transform 220ms var(--ease);
  z-index: 60;
}

.online-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.online-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--hair);
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ok);
  background: rgba(50, 196, 141, 0.09);
  border: 1px solid rgba(50, 196, 141, 0.22);
  border-radius: 999px;
  padding: 3px 9px;
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ok);
  animation: fade-pulse 1.8s ease-in-out infinite;
}

.online-list {
  max-height: 340px;
  overflow-y: auto;
}

.online-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  transition: background 120ms var(--ease);
}
.online-item + .online-item { border-top: 1px solid var(--hair-soft); }
.online-item:hover { background: var(--bg-hover); }
.online-item.self {
  background: var(--accent-tint);
  box-shadow: inset 2px 0 0 var(--accent);
}

.avatar-wrap {
  position: relative;
  flex: none;
  margin-top: 1px;
}

.avatar-wrap .avatar { width: 30px; height: 30px; font-size: 11.5px; }

.status-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  border: 2px solid var(--bg-elevated);
}

.online-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.online-top {
  display: flex;
  align-items: center;
  gap: 7px;
}

.online-name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.you-tag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid rgba(46, 144, 250, 0.25);
  border-radius: 4px;
  padding: 1px 5px;
}

.device-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-2);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 2.5px 9px;
  white-space: nowrap;
}
.device-chip svg { width: 12px; height: 12px; color: var(--text-3); }

.online-loc {
  font-size: 12.5px;
  color: var(--text-2);
}

.online-net {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.online-net .k {
  font-family: var(--font-ui);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}
.online-net .v { margin-right: 6px; }

.online-panel-foot {
  padding: 9px 16px;
  border-top: 1px solid var(--hair);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  color: var(--text-3);
}

.online-empty {
  padding: 22px 16px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

/* ---------------------------------- */
/* Main layout                         */
/* ---------------------------------- */

.main {
  max-width: 960px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-meta {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
}

/* ---------------------------------- */
/* Dropzone                            */
/* ---------------------------------- */

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-raised);
  padding: 34px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease;
  margin-bottom: 32px;
}

.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.dropzone-icon {
  display: inline-flex;
  color: var(--text-3);
  margin-bottom: 10px;
}
.dropzone-icon svg { width: 34px; height: 34px; }
.dropzone.dragover .dropzone-icon { color: var(--accent); }

.dropzone-text {
  font-size: 14.5px;
  color: var(--text-2);
}
.dropzone-text strong { color: var(--text); font-weight: 600; }

.dropzone-hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}

/* ---------------------------------- */
/* File list                           */
/* ---------------------------------- */

.files-section {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.files-head {
  display: grid;
  grid-template-columns: 1fr 110px 96px;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--hair);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.files-section.empty .files-head { display: none; }

.col-size { text-align: right; }

.file-list { display: flex; flex-direction: column; }

.file-row {
  display: grid;
  grid-template-columns: 1fr 110px 96px;
  gap: 12px;
  align-items: center;
  padding: 11px 18px;
  transition: background 100ms ease;
}

.file-row + .file-row { border-top: 1px solid var(--hair-soft); }
.file-row:hover { background: var(--bg-hover); }

.file-main {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.file-chip {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  flex: none;
}

.chip-red    { background: rgba(240, 89, 108, 0.14); color: #ff8b99; }
.chip-green  { background: rgba(50, 196, 141, 0.13); color: #56dcaa; }
.chip-amber  { background: rgba(232, 163, 61, 0.14); color: #f2bc6b; }
.chip-blue   { background: rgba(46, 144, 250, 0.14); color: #6fb4ff; }
.chip-purple { background: rgba(167, 116, 245, 0.15); color: #c3a0f8; }
.chip-gray   { background: rgba(154, 165, 181, 0.12); color: #a8b2c1; }

.file-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.file-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-date {
  font-size: 12px;
  color: var(--text-3);
}

.file-size-inline { display: none; }

.file-size {
  font-size: 13px;
  color: var(--text-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
  opacity: 0;
  transition: opacity 100ms ease;
}

.file-row:hover .file-actions,
.file-row:focus-within .file-actions { opacity: 1; }

.file-actions .icon-btn { width: 32px; height: 32px; }
.file-actions .icon-btn svg { width: 16px; height: 16px; }
.icon-btn.danger:hover { color: var(--danger); border-color: rgba(240, 89, 108, 0.4); }

/* uploading row */

.file-row.uploading { opacity: 0.9; }

.progress-track {
  margin-top: 6px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: var(--accent);
  transition: width 180ms ease;
}

.file-progress-label {
  font-size: 12.5px;
  color: var(--accent);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* empty state */

.files-empty {
  padding: 56px 24px;
  text-align: center;
}

.files-empty-icon {
  display: inline-flex;
  color: var(--text-3);
  margin-bottom: 14px;
}
.files-empty-icon svg { width: 40px; height: 40px; }

.files-empty-title {
  margin: 0 0 4px;
  font-size: 15.5px;
  font-weight: 600;
}

.files-empty-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-3);
}

.files-loading {
  padding: 32px;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-3);
}

.files-error {
  padding: 24px;
  text-align: center;
  font-size: 13.5px;
  color: var(--danger);
}

/* ---------------------------------- */
/* Toast                               */
/* ---------------------------------- */

.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-panel);
  padding: 12px 16px;
  font-size: 13.5px;
  animation: toast-in 180ms ease;
}

.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }

.toast.leaving { opacity: 0; transition: opacity 240ms ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------- */
/* Mobile                              */
/* ---------------------------------- */

@media (max-width: 640px) {
  .topbar-inner { padding: 0 14px; height: 56px; }
  .brand .brand-name { display: none; }
  .user-chip .user-name { display: none; }
  .user-chip { padding: 4px; border-radius: 50%; }
  .online-pill { padding: 0 11px; height: 34px; font-size: 12.5px; }

  .online-panel {
    position: fixed;
    top: 64px;
    left: 14px;
    right: 14px;
    width: auto;
  }

  .main { padding: 22px 14px 60px; }
  .page-title { font-size: 22px; }
  .dropzone { padding: 26px 16px; margin-bottom: 22px; }

  .files-head { display: none; }

  .file-row {
    grid-template-columns: 1fr auto;
    padding: 11px 13px;
  }

  .file-size { display: none; }
  .file-size-inline { display: inline; }

  .file-actions { opacity: 1; }
}
