
    body {
      font-family: Arial, sans-serif;
      background-color: #f4f4f4;
      margin: 0;
      padding: 0;
    }

   #editor-container {
  width: 210mm;
  height: 297mm; /* fissa l’altezza a 297mm */
  margin: 20px auto;
  background-color: white;
  padding: 0;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  overflow: hidden; /* nasconde contenuto fuori area */
}

#editor {
  width: 210mm;
  height: 297mm; /* fissa altezza a 297mm */
  padding: 25mm 15mm 20mm 15mm;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
  overflow: hidden; /* elimina scroll */
  box-sizing: border-box;
   position: relative; /* aggiungi questa riga */
}

    #toolbar {
      display: flex;
      justify-content: flex-start;
      padding: 10px;
      border-bottom: 1px solid #ccc;
    }

    #toolbar button, #toolbar select {
      padding: 10px;
      background-color: #ff0000;
      color: white;
      border: none;
      cursor: pointer;
      margin-right: 5px;
    }

    #toolbar button:hover {
      background-color: #fc6d6d;
    }

  
 /* #editor {
      position: relative;
      padding: 25mm 20mm 20mm 25mm;
      font-size: 14px;
      line-height: 1.6;
      text-align: left;
      min-height: 1000px;
    }*/


    #editor img {
  position: absolute;
  cursor: move;
  z-index: 10;
}
/*.letterhead { old one without the line head[]
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}*/
   .editor-relative-container {
  position: relative;
}

.draggable {
  position: absolute;
  cursor: move;
}
.editable-area {
  width: 100%;
  min-height: 50px;
  font-size: 14px;
  border: none;
  border-bottom: 1px solid #444; /* come sopra */
  background: transparent;
  padding: 5px 0;
  box-sizing: border-box;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
}
/*.letterhead {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  margin-bottom: 20px;
  border: 1px dashed #999;
  padding: 10px;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
}*/
/*
.letterhead::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 70%;
  width: 1px;
  background: #999;
  border-left: 1px dashed #999;
}*/

    .letterhead .sender {
      max-width: 70%;
    }

 .letterhead .logo {
  max-width: 30%;
  /* text-align: right;  <-- toglilo */
}
.signature {
  text-align: center; /* opzionale, puoi tenerlo se vuoi */
}

    .letterhead .logo img {
      max-width: 120px;
      height: auto;
    }

    .letter-section {
      margin-bottom: 20px;
    }


.letter-section.subject {
  margin-top: 8mm; 
  
  /* 100mm totale - 50mm del destinatario */
}

 /*   .letterhead {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  margin-bottom: 20px;
  padding: 10px;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  margin-top: 50mm; 
}*/
.letter-section:last-of-type input.editable-field {
  margin-top: 40px;
}
.toast-message {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #ff4d4d;
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  opacity: 0;
  animation: fadeInOut 3.5s ease-in-out forwards;
}

@keyframes fadeInOut {
  0%   { opacity: 0; transform: translate(-50%, -40%); }
  10%  { opacity: 1; transform: translate(-50%, -50%); }
  90%  { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -60%); }
}
@media print {
  #editor input,
  #editor .editable-field,
  #editor .spaced-input {
    display: none !important;
  }

  #editor .editable-area[contenteditable="true"]::before {
    content: none !important;
  }
}
.letterhead {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  margin-bottom: 20px;
  padding: 10px;
  min-height: 120px;
  width: 100%;
  box-sizing: border-box;
  position: relative;
  margin-top: 0mm; /* <-- modificato da 50mm a 20mm */
}
.editable-field {
  width: 100%;
  height: 28px;
  font-size: 14px;
  border: none;
  border-bottom: 1px solid #444; /* colore più scuro */
  background: transparent;
  outline: none;
  margin-bottom: 6px; /* spazio tra le righe */
}
.spaced-input {
  margin-top: 0mm; /* 2cm di spazio sopra */
  display: block; /* per assicurare che margin-top funzioni correttamente */
}
#editor2 {
  width: 210mm;
  height: 297mm;
  padding: 25mm 15mm 20mm 15mm;
  font-size: 14px;
  line-height: 1.6;
  text-align: left;
  overflow: hidden;
  box-sizing: border-box;
  position: relative;
}
.resizable-handle {
  width: 10px;
  height: 10px;
  background: #007bff;
  position: absolute;
  z-index: 20;
}
.resizable-handle.nw { cursor: nwse-resize; }
.resizable-handle.ne { cursor: nesw-resize; }
.resizable-handle.sw { cursor: nesw-resize; }
.resizable-handle.se { cursor: nwse-resize; }
.delete-icon {
  width: 16px;
  height: 16px;
  background: red;
  color: white;
  font-weight: bold;
  text-align: center;
  line-height: 16px;
  border-radius: 50%;
  position: absolute;
  cursor: pointer;
  z-index: 30;
  font-size: 12px;
}

.logo, .signature {
  position: relative;
}
.delete-icon {
  top: 0;
  right: 0;
}
#toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}

#toolbar button {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
}

#toolbar button:hover {
  background: #f5f5f5;
}

#toolbar button:active {
  background: #eaeaea;
}

#toolbar button:last-of-type {
  background: #c62828; /* rosso */
  color: #fff;
  border: none;
  font-weight: 600;
}

#toolbar button:last-of-type:hover {
  background: #a81f1f;
}

#toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid #ccc;
}

#toolbar button {
  background: #ffffff;
  border: 1px solid #d1d1d1;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: normal;
  color: #000;
  cursor: pointer;
  line-height: 1.4;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#toolbar button:hover {
  background: #f7f7f7;
  border-color: #bcbcbc;
}

#toolbar button:active {
  background: #eeeeee;
}

#toolbar button:last-of-type {
  background: #b91c1c; /* rosso come nello screenshot */
  color: #fff;
  border: 1px solid #b91c1c;
  font-weight: normal;
}

#toolbar button:last-of-type:hover {
  background: #991b1b;
  border-color: #991b1b;
}



#toolbar {
  display: flex;
  justify-content: flex-start;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #dcdcdc;
  background: #f9f9f9;
}

#toolbar button {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  padding: 5px 12px;           /* padding più compatto */
  font-size: 13px;             /* font più piccolo */
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
  line-height: 1;              /* altezza compatta */
  white-space: nowrap;         /* evita il testo su due righe */
  height: 32px;                /* altezza fissa */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#toolbar button:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

#toolbar button:active {
  background: #e5e7eb;
}

#toolbar button:last-of-type {
  background: #dc2626;
  color: #ffffff;
  border: 1px solid #dc2626;
  font-weight: 600;
}

#toolbar button:last-of-type:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

#toolbar button:last-of-type:active {
  background: #991b1b;
}

.sender input.editable-field {
  width: 158%;          /* tutti dentro .sender saranno uguali */
}
.editable-area[contenteditable="true"]:empty:before {
  content: attr(placeholder);
  color: #999;
  pointer-events: none;
  display: block;
}
