/* VFm - stile */
:root {
  --bg: #f1f3f5;
  --card: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --muted: #6c757d;
  --primary: #1a73e8;
  --primary-dark: #1558b0;
  --danger: #d93025;
  --danger-bg: #fce8e6;
  --ok: #188038;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

/* L'attributo hidden deve SEMPRE nascondere: le regole display dei componenti
   (es. .modal-backdrop) lo sovrascriverebbero altrimenti. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #202124;
  color: #fff;
  padding: 0 24px;
  height: 56px;
}
.topbar .brand { display: flex; align-items: baseline; gap: 10px; }
.topbar .logo { font-weight: 700; font-size: 20px; letter-spacing: .5px; }
.topbar .tagline { color: #9aa0a6; font-size: 13px; }
.topbar .nav { display: flex; align-items: center; gap: 16px; flex: 1; }
.topbar .nav a { color: #dadce0; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.topbar .nav a:hover { background: rgba(255,255,255,.08); }
.topbar .nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .who { color: #e8eaed; font-size: 14px; }
.topbar .who em { color: #9aa0a6; font-style: normal; font-size: 12px; }

/* ---------- layout ---------- */
.main { max-width: 1080px; margin: 24px auto; padding: 0 16px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 0 40px; }

/* ---------- card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f8f9fa; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.primary:disabled { background: #a8c7f2; border-color: #a8c7f2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: #f1f3f4; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------- form ---------- */
label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }

/* ---------- barra di avanzamento upload ---------- */
.upload-progress { display: flex; align-items: center; gap: 8px; }
.upload-progress-track {
  width: 180px;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.upload-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width .15s ease;
}
.upload-progress.done .upload-progress-bar { background: var(--ok); }
.upload-progress-text { color: var(--muted); font-size: 12px; white-space: nowrap; }
#upload-cancel { padding: 2px 8px; line-height: 1.2; color: var(--danger); }
#upload-cancel:hover { background: var(--danger-bg); }
.login-card .version { text-align: center; margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.upload-progress.finalizing .upload-progress-bar {
  background: repeating-linear-gradient(45deg, var(--primary) 0 12px, #5b9bf0 12px 24px);
  background-size: 34px 100%;
  animation: vfm-stripes 1s linear infinite;
}
@keyframes vfm-stripes {
  from { background-position: 0 0; }
  to { background-position: 34px 0; }
}
.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #f5c6c3;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 12px 0;
  font-size: 14px;
}

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-card { width: 380px; max-width: 100%; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.captcha-row { margin-top: 18px; }
.captcha-row > div { min-height: 65px; }

/* ---------- toolbar ---------- */
.fm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.toolbar-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.toolbar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }

/* ---------- breadcrumb ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 14px;
  margin-bottom: 14px;
  font-size: 14px;
}
.breadcrumb a { color: var(--primary); text-decoration: none; padding: 4px 6px; border-radius: 4px; }
.breadcrumb a:hover { background: #e8f0fe; }
.breadcrumb .sep { color: var(--muted); }

/* ---------- tabella ---------- */
.table-card { overflow-x: auto; }
.ftable { width: 100%; border-collapse: collapse; }

/* tabella file: layout fisso, nomi in ellissi e azioni sempre visibili */
.ftable.files { table-layout: fixed; }
.ftable.files .col-check { width: 44px; }
.ftable.files .col-size { width: 110px; text-align: right; }
.ftable.files .col-date { width: 150px; }
.ftable.files .col-actions { width: 420px; text-align: right; white-space: nowrap; }
.ftable th {
  text-align: left;
  padding: 10px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
}
.ftable td { padding: 10px 12px; border-bottom: 1px solid #f0f1f3; }
.ftable tbody tr:hover { background: #f8f9fa; }
.ftable tr:last-child td { border-bottom: none; }
.ftable .empty { text-align: center; color: var(--muted); padding: 32px; }
.col-check { width: 34px; }
.col-size { width: 110px; text-align: right; }
.col-date { width: 150px; }
.col-actions { width: 210px; text-align: right; white-space: nowrap; }

.fname { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.fname .icon { width: 20px; flex: none; text-align: center; font-size: 17px; }
.fname .icon.dir { color: #f9ab00; }
.fname .icon.file { color: #80868b; }
.entry-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dir-link { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--primary); font-weight: 500; }
.dir-link:hover { text-decoration: underline; }
.size { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.date { color: var(--muted); font-variant-numeric: tabular-nums; }
.row-actions { display: inline-flex; gap: 4px; justify-content: flex-end; }
.row-actions .btn { padding: 3px 8px; font-size: 12px; }
.row-actions .act-icon { font-size: 13px; line-height: 1; }
.disabled-cell { color: #ced4da; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal { width: 460px; max-width: 94vw; max-height: 88vh; overflow: auto; padding: 22px; }
.modal.wide { width: 640px; }
.modal h3 { margin: 0 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- permessi (pannello utenti) ---------- */
.perm-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.perm-row input[type=text] { flex: 1; }
.perm-row .perm-tick { display: flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.perm-row input[type=checkbox] { width: auto; }
.perm-add { margin-top: 10px; }

/* ---------- badge ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.badge.admin { background: #e8f0fe; color: var(--primary-dark); }
.badge.user { background: #f1f3f4; color: var(--muted); }
.badge.on { background: #e6f4ea; color: var(--ok); }
.badge.off { background: var(--danger-bg); color: var(--danger); }

@media (max-width: 720px) {
  .ftable.files .col-date, .ftable.files .col-size,
  .ftable.files .date, .ftable.files .size { display: none; }
  .ftable.files .col-actions { width: 168px; }

  /* azioni riga compatte: solo icone */
  .row-actions .act-lbl { display: none; }
  .row-actions .btn { padding: 4px 7px; font-size: 13px; }

  /* topbar su più righe */
  .topbar { height: auto; min-height: 52px; padding: 8px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar .tagline { display: none; }
  .topbar .nav { flex: 1 1 100%; flex-wrap: wrap; gap: 6px; }
  .topbar .spacer { display: none; }
  .topbar .who { font-size: 12px; }
  .topbar .nav a { padding: 4px 8px; font-size: 13px; }

  .main { margin: 12px auto; padding: 0 10px; }
  .fm-toolbar { padding: 8px 10px; }
  .toolbar-right { gap: 8px; }
  .upload-progress-track { width: 120px; }
  .ftable th, .ftable td { padding: 8px 6px; }
  .perm-row { flex-wrap: wrap; }
  .btn { padding: 7px 10px; font-size: 13px; }
}
