/* CSS customizzato per Simple Spreadsheet Tables - Soluzione definitiva */

/* Creiamo una classe specifica per il nostro plugin che non entrerà in conflitto */
.sst-table-container {
  margin: 2rem 0;
  max-width: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Container principale con sfondo bianco e ombra */
.sst-wrapper {
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  padding: 0;
}

/* Rimuove tutti gli stili DataTables problematici */
.sst-wrapper table.dataTable {
  width: 100% !important;
  margin: 0 !important;
  border-collapse: separate !important;
  border-spacing: 0 !important;
  clear: both;
  border: none !important;
}

/* Stile dell'intestazione della tabella */
.sst-wrapper table.dataTable thead th {
  background-color: #f8f9fa;
  color: #333;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 16px;
  text-align: left;
  border-bottom: 1px solid #eaeaea;
  border-top: none;
  border-left: none;
  border-right: none;
}

/* Stile delle celle del corpo della tabella */
.sst-wrapper table.dataTable tbody td {
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid #f2f2f2;
  font-size: 0.875rem;
  color: #444;
  vertical-align: middle;
}

/* Righe alternate */
.sst-wrapper table.dataTable tbody tr:nth-child(even) {
  background-color: #fbfbfb;
}

/* Hover sulle righe */
.sst-wrapper table.dataTable tbody tr:hover {
  background-color: #f5f7ff;
}

/* Rimuove la bordatura inferiore dall'ultima riga */
.sst-wrapper table.dataTable tbody tr:last-child td {
  border-bottom: none;
}

/* Contenitore controlli superiori (ricerca e selezione righe) */
.sst-controls-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #eaeaea;
}

/* Contenitore controlli inferiori (paginazione e info) */
.sst-controls-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-top: 1px solid #eaeaea;
}

/* Tutte le label */
.sst-wrapper label {
  font-size: 0.875rem;
  color: #666;
  display: flex;
  align-items: center;
  margin: 0;
}

/* Selettore righe per pagina */
.sst-length {
  margin-right: 16px;
}

.sst-length select {
  margin: 0 8px;
  padding: 8px 32px 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='6' viewBox='0 0 12 6'%3E%3Cpath fill='%23888' d='M12 0H0l6 6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  color: #444;
  font-size: 0.875rem;
  min-width: 80px;
  cursor: pointer;
  transition: all 0.2s;
}

.sst-length select:focus {
  outline: none;
  border-color: #4d90fe;
  box-shadow: 0 0 0 2px rgba(77, 144, 254, 0.2);
}

/* Ricerca */
.sst-filter {
  position: relative;
}

.sst-filter input {
  padding: 10px 16px 10px 40px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 0.875rem;
  color: #444;
  width: 240px;
  background-color: #fff;
  transition: all 0.2s;
}

.sst-filter input:focus {
  outline: none;
  border-color: #4d90fe;
  box-shadow: 0 0 0 2px rgba(77, 144, 254, 0.2);
}

/* Icona di ricerca */
.sst-filter:before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  pointer-events: none;
}

/* Info paginazione */
.sst-info {
  font-size: 0.875rem;
  color: #666;
}

/* Paginazione */
.sst-pagination {
  display: flex;
  align-items: center;
}

.sst-pagination .paginate_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  margin: 0 2px;
  padding: 0 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background-color: #fff;
  color: #444;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.sst-pagination .paginate_button:hover {
  background-color: #f5f5f5;
  color: #333;
}

.sst-pagination .paginate_button.current {
  background-color: #4d90fe;
  border-color: #4d90fe;
  color: white;
  font-weight: 500;
}

.sst-pagination .paginate_button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Nasconde i pulsanti precedente/successivo quando inattivi */
.sst-pagination .paginate_button.disabled {
  visibility: hidden;
}

/* Modifica i pulsanti specifici di DataTable per evitare conflitti di stile */
.sst-wrapper table.dataTable thead th.sorting,
.sst-wrapper table.dataTable thead th.sorting_asc,
.sst-wrapper table.dataTable thead th.sorting_desc {
  position: relative;
  padding-right: 25px;
  cursor: pointer;
}

.sst-wrapper table.dataTable thead th.sorting:after,
.sst-wrapper table.dataTable thead th.sorting_asc:after,
.sst-wrapper table.dataTable thead th.sorting_desc:after {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75em;
  opacity: 0.5;
}

.sst-wrapper table.dataTable thead th.sorting:after {
  content: "↕";
}

.sst-wrapper table.dataTable thead th.sorting_asc:after {
  content: "↑";
  opacity: 1;
}

.sst-wrapper table.dataTable thead th.sorting_desc:after {
  content: "↓";
  opacity: 1;
}

/* Indicatore di caricamento */
.sst-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-size: 0.9rem;
    color: #666;
    background-color: rgba(255, 255, 255, 0.9);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
}

.sst-loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 2px solid #ddd;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 767px) {
  .sst-controls-top, 
  .sst-controls-bottom {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .sst-length,
  .sst-filter,
  .sst-info,
  .sst-pagination {
    margin: 8px 0;
    width: 100%;
  }
  
  .sst-filter input {
    width: 100%;
  }
  
  .sst-pagination {
    justify-content: center;
  }
  
  /* Tabella responsive */
  .sst-wrapper table.dataTable {
    display: block;
    width: 100%;
  }
  
  .sst-wrapper table.dataTable thead {
    display: none;
  }
  
  .sst-wrapper table.dataTable tbody {
    display: block;
    width: 100%;
  }
  
  .sst-wrapper table.dataTable tbody tr {
    display: block;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eaeaea;
  }
  
  .sst-wrapper table.dataTable tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    padding: 8px 16px;
    border-bottom: 1px solid #f2f2f2;
  }
  
  .sst-wrapper table.dataTable tbody td:before {
    content: attr(data-title);
    font-weight: 600;
    color: #666;
    text-align: left;
    padding-right: 16px;
  }
  
  .sst-wrapper table.dataTable tbody tr:last-child {
    margin-bottom: 0;
    border-bottom: none;
  }
}

/* Overlay di caricamento */
.sst-wrapper .dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  padding: 10px 20px;
  font-size: 0.875rem;
  color: #444;
  z-index: 1;
}

/* Messaggio di errore */
.sst-table-error {
  padding: 16px;
  margin: 16px 0;
  background-color: #fff3f3;
  border-left: 4px solid #ff5252;
  border-radius: 4px;
  color: #d32f2f;
  font-size: 0.875rem;
}