/* ============================================
   PeritoMap — Stili Documenti allegati
   ============================================ */

.documenti-sezione {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.documenti-sezione-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.documenti-sezione-titolo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--colore-testo, #202124);
}

.documenti-sezione-titolo svg { flex-shrink: 0; }

.documenti-sezione-contatore {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 8px;
  background: #1a73e8;
  color: #fff;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
}

.documenti-filtro {
  padding: 6px 10px;
  border: 1px solid var(--colore-bordo, #dadce0);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: var(--colore-testo, #202124);
  min-width: 160px;
}

/* ---- Zona upload ---- */

.documenti-upload-zona {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 16px;
  border: 2px dashed #bdc1c6;
  border-radius: 10px;
  background: #f8f9fa;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  text-align: center;
}

.documenti-upload-zona:hover,
.documenti-upload-zona.dragover {
  border-color: #1a73e8;
  background: #e8f0fe;
}

.documenti-upload-zona svg { color: #5f6368; }

.documenti-upload-testo {
  margin: 4px 0 0;
  font-size: 14px;
  color: #202124;
}

.documenti-upload-testo strong { color: #1a73e8; }

.documenti-upload-sub {
  margin: 0;
  font-size: 12px;
  color: #5f6368;
}

.btn-link {
  background: none;
  border: none;
  color: #1a73e8;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: underline;
}

/* ---- Barra progresso upload ---- */

.documenti-upload-progresso {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #e8f0fe;
  border-left: 3px solid #1a73e8;
  border-radius: 6px;
  font-size: 13px;
  color: #1967d2;
}

.documenti-upload-progresso svg {
  animation: spin-doc 1s linear infinite;
  flex-shrink: 0;
}

@keyframes spin-doc {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- Lista documenti ---- */

.documenti-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.documento-riga {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--colore-bordo, #dadce0);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.documento-riga:hover {
  border-color: #1a73e8;
  box-shadow: 0 1px 4px rgba(26, 115, 232, 0.1);
}

.documento-icona {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.documento-icona-badge {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.documento-info {
  flex: 1;
  min-width: 0;
}

.documento-nome {
  font-size: 14px;
  font-weight: 500;
  color: #202124;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.documento-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  font-size: 12px;
  color: #5f6368;
}

.documento-categoria {
  display: inline-block;
  padding: 2px 8px;
  background: #e8f0fe;
  color: #1967d2;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.documento-sep { color: #bdc1c6; }

.documento-autore {
  margin-top: 2px;
  font-size: 11px;
  color: #80868b;
}

.documento-azioni {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-icona-doc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #5f6368;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-icona-doc:hover {
  background: #f1f3f4;
  color: #1a73e8;
  border-color: #dadce0;
}

.btn-icona-doc.pericolo:hover {
  background: #fce8e6;
  color: #d93025;
  border-color: #f4c7c3;
}

/* ---- Vuoto ---- */

.documenti-vuoto {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 16px;
  color: #9aa0a6;
  text-align: center;
}

.documenti-vuoto svg { opacity: 0.6; }
.documenti-vuoto p { margin: 0; font-size: 14px; }

/* ---- Anteprima full-screen ---- */

.documento-anteprima {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  flex-direction: column;
}

.documento-anteprima-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  flex-shrink: 0;
}

.documento-anteprima-titolo {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.documento-anteprima-azioni {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-chiudi-anteprima {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
}

.btn-chiudi-anteprima:hover { background: rgba(255, 255, 255, 0.15); }

.documento-anteprima-corpo {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.documento-anteprima-corpo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.documento-anteprima-iframe {
  width: 100%;
  height: 100%;
  min-height: 75vh;
  border: none;
  background: #fff;
  border-radius: 4px;
}

/* Anteprima PDF via PDF.js (canvas impilati, scorrevoli) */
.documento-pdf-pagine {
  width: 100%;
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #525659;
}

.documento-pdf-canvas {
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}

.documento-pdf-msg {
  color: #fff;
  text-align: center;
  padding: 20px;
}

.documento-pdf-msg a { color: #fff; text-decoration: underline; }

/* ---- Responsive ---- */

@media (max-width: 600px) {
  .documenti-sezione-header {
    align-items: flex-start;
  }
  .documenti-filtro {
    width: 100%;
    min-width: 0;
  }
  .documento-riga {
    flex-wrap: wrap;
    gap: 8px;
  }
  .documento-azioni {
    width: 100%;
    justify-content: flex-end;
    padding-top: 4px;
    border-top: 1px dashed #e8eaed;
  }
  .documenti-upload-zona {
    padding: 18px 12px;
  }
}
