/* PORTALI — sistema grafico condiviso (Titillium Web + Tabler Icons) */
@import url("/vendor/font/300.css");
@import url("/vendor/font/400.css");
@import url("/vendor/font/600.css");
@import url("/vendor/font/700.css");
@import url("/vendor/icons/tabler-icons.min.css");

:root {
  --ink: #1a1f26;
  --ink-2: #262d37;
  --ink-3: #39424f;
  --paper: #f3f4f1;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --line: #d8dbd5;
  --line-2: #e7e9e4;
  --text: #1a1f26;
  --muted: #687280;
  --faint: #9aa1ab;
  --accent: #e2531d;
  --accent-ink: #b83f10;
  --accent-soft: #fdeee7;
  --blue: #1f5fae;
  --blue-soft: #e8f0fa;
  --ok: #2b8a57;
  --ok-soft: #e6f4ec;
  --danger: #c22d2d;
  --danger-soft: #fbeaea;
  --radius: 6px;
  --shadow-1: 0 1px 2px rgba(20, 25, 32, .06), 0 1px 1px rgba(20, 25, 32, .04);
  --shadow-2: 0 10px 30px rgba(20, 25, 32, .14), 0 2px 6px rgba(20, 25, 32, .08);
  --font: "Titillium Web", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.ti { font-size: 1.2em; line-height: 1; vertical-align: -0.15em; }
[hidden] { display: none !important; }

/* Carta millimetrata tecnica */
.grid-paper {
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(26, 31, 38, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 31, 38, .045) 1px, transparent 1px),
    linear-gradient(rgba(26, 31, 38, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 31, 38, .025) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
}

/* Etichette "da cartiglio" */
.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Bottoni */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; letter-spacing: .01em;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, .input:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-3); border-color: var(--ink-3); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(26, 31, 38, .06); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 15px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: inherit; cursor: pointer;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: rgba(26, 31, 38, .07); }
.icon-btn.active { background: var(--ink); color: #fff; }
.icon-btn .ti { font-size: 19px; }

/* Input */
.input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--ink-3); outline: none; box-shadow: 0 0 0 3px rgba(31, 95, 174, .12); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field small { color: var(--muted); font-size: 13px; }

.search {
  position: relative; display: flex; align-items: center;
}
.search .ti { position: absolute; left: 11px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 36px; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 7px; border-radius: 3px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: var(--line-2); color: var(--ink-3);
}
.badge.fmt { background: var(--ink); color: #fff; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* Breadcrumb */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; font-size: 17px; font-weight: 600; min-width: 0; }
.crumbs button {
  border: 0; background: none; padding: 4px 8px; border-radius: var(--radius);
  cursor: pointer; color: var(--muted); font-weight: 600;
}
.crumbs button:hover { background: rgba(26, 31, 38, .06); color: var(--text); }
.crumbs button.current { color: var(--text); }
.crumbs button.drop-target { background: var(--accent-soft); color: var(--accent-ink); }
.crumbs .sep { color: var(--faint); }

/* Griglia elementi */
.items-section + .items-section { margin-top: 26px; }
.items-section > .label { display: block; margin: 0 0 10px; }
.grid-items {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.folder-card {
  display: flex; align-items: center; gap: 10px;
  height: 52px; padding: 0 8px 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; user-select: none; position: relative;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.folder-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow-1); }
.folder-card .ti-folder, .folder-card .ti-folder { color: var(--ink-3); font-size: 22px; }
.folder-card .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.file-card {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; user-select: none; overflow: hidden; position: relative;
  transition: border-color .12s, box-shadow .12s, transform .12s;
}
.file-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow-2); }
.file-card .thumb {
  position: relative; aspect-ratio: 4 / 3;
  background: var(--surface-2);
  background-image:
    linear-gradient(rgba(26, 31, 38, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 31, 38, .05) 1px, transparent 1px);
  background-size: 12px 12px;
  border-bottom: 1px solid var(--line-2);
  display: grid; place-items: center; overflow: hidden;
}
.file-card .thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.15)); }
.file-card .thumb .ph { font-size: 46px; color: var(--faint); }
.file-card .thumb .corner { position: absolute; left: 8px; top: 8px; display: flex; gap: 4px; }
.file-card .meta { padding: 10px 12px 11px; display: grid; gap: 3px; }
.file-card .name { font-weight: 600; font-size: 14px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .sub { display: flex; gap: 8px; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; }
.file-card .sub span + span::before { content: "·"; margin-right: 8px; color: var(--faint); }

.sel-check {
  position: absolute; right: 8px; top: 8px; z-index: 2;
  width: 24px; height: 24px; border-radius: 4px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.95); border: 1px solid var(--line);
  opacity: 0; transition: opacity .12s; cursor: pointer;
}
.folder-card .sel-check { position: static; opacity: 0; }
.file-card:hover .sel-check, .folder-card:hover .sel-check, .selected .sel-check, .has-selection .sel-check { opacity: 1; }
.selected .sel-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.sel-check .ti { font-size: 16px; }
.file-card.selected, .folder-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset, 0 0 0 1px var(--accent); }
.folder-card.selected { background: var(--accent-soft); }
.folder-card.drop-target { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent); }

/* Vista elenco */
.list-items { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-row {
  display: grid; align-items: center; gap: 12px;
  grid-template-columns: 34px minmax(0, 1fr) 110px 120px 90px 130px 44px;
  min-height: 48px; padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line-2); cursor: pointer; user-select: none;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-row.head { min-height: 36px; cursor: default; background: var(--surface-2); }
.list-row.head:hover { background: var(--surface-2); }
.list-row.selected { background: var(--accent-soft); }
.list-row.drop-target { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.list-row .nm { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 600; }
.list-row .nm span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .c { color: var(--muted); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .ic { font-size: 22px; color: var(--ink-3); }
.list-row .ic.pdf { color: var(--accent); }
.list-row .sel-check { position: static; opacity: 1; width: 20px; height: 20px; }

/* Stato vuoto */
.empty {
  display: grid; place-items: center; text-align: center; gap: 10px;
  padding: 70px 20px; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: 10px; background: rgba(255,255,255,.5);
}
.empty .ti { font-size: 52px; color: var(--faint); }
.empty h3 { margin: 0; color: var(--text); font-size: 18px; }
.empty p { margin: 0; max-width: 420px; }

/* Menu contestuale */
.menu {
  position: fixed; z-index: 1000; min-width: 230px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-2);
}
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: 5px;
  text-align: left; cursor: pointer; font-size: 14px;
}
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu button.danger:hover { background: var(--danger-soft); }
.menu hr { border: 0; border-top: 1px solid var(--line-2); margin: 5px 2px; }
.menu .ti { color: var(--muted); font-size: 18px; }
.menu .danger .ti { color: var(--danger); }

/* Modali */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(20, 25, 32, .45); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .12s ease-out;
}
.modal {
  width: min(460px, 100%); max-height: calc(100vh - 40px); overflow: auto;
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-2);
  border-top: 4px solid var(--accent);
  animation: pop .14s ease-out;
}
.modal header { display: flex; align-items: center; gap: 10px; padding: 18px 20px 4px; }
.modal header h2 { margin: 0; font-size: 19px; font-weight: 700; flex: 1; }
.modal .body { padding: 12px 20px 6px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal p { margin: 0 0 12px; color: var(--muted); }
@keyframes fade { from { opacity: 0 } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98) } }

.move-tree { border: 1px solid var(--line); border-radius: var(--radius); max-height: 320px; overflow: auto; padding: 4px; }
.move-tree button {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 7px 8px; border-radius: 4px; cursor: pointer; text-align: left;
}
.move-tree button:hover { background: var(--surface-2); }
.move-tree button.active { background: var(--ink); color: #fff; }
.move-tree button:disabled { opacity: .4; cursor: not-allowed; }

/* Toast */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 1100; display: grid; gap: 8px; justify-items: center; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 6px;
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-2); animation: pop .15s ease-out;
}
.toast.err { background: var(--danger); }
.toast .ti { font-size: 18px; }

/* Marchio */
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none; border-radius: 6px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
}
.brand-mark .ti { font-size: 21px; }
.brand-text { min-width: 0; line-height: 1.1; }
.brand-text strong { display: block; font-size: 16px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { display: block; font-size: 11px; letter-spacing: .14em; text-transform: uppercase; opacity: .7; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-2);
  overflow: hidden;
}
.login-card .head { background: var(--ink); color: #fff; padding: 22px 24px; }
.login-card .body { padding: 22px 24px 8px; }
.login-card .foot {
  display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line);
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600;
}
.login-card .foot div { padding: 9px 14px; }
.login-card .foot div + div { border-left: 1px solid var(--line); }
.form-error { color: var(--danger); font-weight: 600; font-size: 14px; min-height: 20px; margin: -4px 0 10px; }

.spin { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg) } }

.skeleton { background: linear-gradient(90deg, var(--line-2), #f3f4f1, var(--line-2)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0 } }

@media (max-width: 720px) {
  .grid-items { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .list-row { grid-template-columns: 30px minmax(0, 1fr) 80px 40px; }
  .list-row .c.hide-sm { display: none; }
}
