:root {
  --bg-page: #F0F2F5;
  --bg-card: #FFFFFF;
  --text-primary: #252B3F;
  --text-secondary: #5A5F7D;
  --accent: #4F46E5;
  --accent-hover: #4338CA;
  --border-radius: 16px;
  --spacing: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg-page);
  font-family: 'Inter', sans-serif;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: var(--spacing);
  color: var(--text-primary);
}

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 700px;
  padding: calc(var(--spacing) * 1.2);
  display: flex;
  flex-direction: column;
  gap: var(--spacing);
}

/* top controls */
.top-controls {
  display:flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.left-controls { display:flex; gap: 10px; align-items:center; }
.right-controls { display:flex; gap: 10px; align-items:center; }

.small-btn {
  padding: 8px 10px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  background: #F3F4F6;
  color: var(--text-primary);
}
.small-btn:hover { background: #E8EAEE; }

.primary-ghost {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}
.primary-ghost:hover { background: rgba(79,70,229,0.06); }

.download-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.download-btn[disabled] { opacity: 0.6; cursor: not-allowed; }

.last-exec {
  background:#FBFCFF;
  border:1px solid #E6ECFF;
  padding:10px;
  border-radius:10px;
  display:flex;
  align-items:center;
  gap:12px;
  font-size:0.92rem;
  color:var(--text-secondary);
}
.last-exec strong { color: var(--text-primary); display:block; font-size:0.95rem; }

.tabs { display: flex; border-bottom: 2px solid #E0E4E8; }
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.tab.active { border-bottom: 3px solid var(--accent); color: var(--accent); }

.disclaimer-banner {
  background: linear-gradient(135deg, #F0F9FF 0%, #F3F4F6 100%);
  border: 1px solid #BFDBFE;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 12px 0;
}

.disclaimer-icon {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 2px;
}

.disclaimer-text {
  font-size: 0.85rem;
  line-height: 1.4;
  color: #1E40AF;
  margin: 0;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  display: block;
}

input[type="text"], input[type="file"], input[type="email"], select, textarea {
  width: 100%;
  font-size: 1rem;
  padding: 8px;
  background: transparent;
  border: 2px solid #E0E4E8;
  border-radius: 6px;
  transition: border-color 0.2s ease;
  color: var(--text-primary);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

input:focus, input[type="email"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 5px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 12px 0;
  font-size: 1rem;
  font-weight: 600;
  color: #FFFFFF;
  background: var(--accent);
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.2);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  text-align: center;
  margin-top: 10px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
  transform: translateY(-2px);
}

#loading, #loadingFile, #loading1, #loading2 {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  display: none;
}

#result, #resultFile, #result1, #result2 {
  margin-top: 0;
  padding: 12px;
  background: #F8FAFC;
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  font-size: 0.9rem;
  border-radius: 4px;
  white-space: pre-wrap;
  display: none;
}

a.file-link {
  display: inline-block;
  margin-top: 10px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}
a.file-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* --- logo styles --- */
.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
}

.nexi-logo {
  height: 44px;
  object-fit: contain;
  opacity: 0.95;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.nexi-logo:hover {
  opacity: 1;
  transform: translateY(-2px);
}

/* --- X button for clearing files --- */
.clear-files {
  color: var(--accent);
  font-weight: bold;
  cursor: pointer;
  border: none;
  background: transparent;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
}
.clear-files:hover {
  background: rgba(79,70,229,0.06);
}

.file-list-container {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: #5A5F7D;
  margin-top: 6px;
  gap: 8px;
}

.file-names {
  flex: 1 1 auto;
  min-width: 0;          /* ← QUESTA È LA CHIAVE */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* responsive small */
@media (max-width: 600px) {
  .top-controls { flex-direction: column; align-items: stretch; gap:8px; }
  .left-controls, .right-controls { justify-content:space-between; }
  .card { padding: 18px; }
}


.small-card {
  max-width: 480px;
  margin: 40px auto;
}

.response-box {
  display: none;
  background: #F8FAFC;
  border-left: 4px solid var(--accent);
  margin-top: 15px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.error-msg {
  display: none;               /* inizialmente nascosto, lo mostriamo via JS */
  background: #fdecea;         /* leggero rosato chiaro per indicare errore */
  border-left: 4px solid #c62828; /* bordo rosso */
  margin-top: 15px;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #c62828;              /* testo rosso */
  white-space: pre-wrap;       /* mantiene gli a capo come nella response normale */
}

/* TREE DROPDOWN */
.tree-dropdown-container {
  margin: 15px 0;
}

.tree-dropdown {
  border: 1px solid #ccc;
  border-radius: 6px;
  background: white;
  width: 100%;
  position: relative;
}

.tree-dropdown-header {
  padding: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tree-dropdown-menu {
  display: none;
  border-top: 1px solid #ccc;
  max-height: 250px;
  overflow-y: auto;
  padding: 10px;
}

.tree-item {
  margin-left: 20px;
  padding: 4px 0;
}

.tree-folder {
  font-weight: 600;
  cursor: pointer;
}

.checkbox {
  margin-right: 8px;
}

.arrow {
  font-size: 12px;
  opacity: 0.6;
}

.tree-expand {
  cursor: pointer;
  margin-right: 6px;
  user-select: none;
}

.project-load-btn {
  height: 38px;                     /* stessa altezza dell'input */
  font-size: 0.95rem;
  font-weight: 600;
  background: #4f46e5;        /* blu coerente col front-end */
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(79,70,229,0.15);
  transition: background 0.15s ease, transform 0.12s ease;
}
.project-load-btn:hover { 
  background: var(--accent-hover); 
  transform: translateY(-1px); 
}
.project-selector input:focus { 
  border-color: #4f46e5; 
  outline: none; 
}

/* Messaggio "Processing..." */
#projectLoadLoading {
  font-size: 0.9rem;
  color: var(--text-secondary);
  animation: pulseLoading 1.2s ease-in-out infinite;
}

@keyframes pulseLoading {
  0%   { opacity: 0.5; }
  50%  { opacity: 1; }
  100% { opacity: 0.5; }
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    text-align: center;
}

.login-container .logo img {
    max-width: 150px;
    margin-bottom: 30px;
}

.file-link {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--link-color, blue);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}

.file-link{
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  vertical-align: middle;
}

#fileSingleName,
#fileListDoc,
#fileListStory {
  width: 100%;
}

#lastExec {
  display: flex;
  align-items: center;
  width: 100%;       /* occupa tutta la card */
  gap: 12px;
}

.last-exec-text {
  display: flex;
  flex-direction: column;

  /* larghezza massima fissa */
  max-width: 300px;    

  /* larghezza minima dinamica in base al contenuto */
  width: fit-content;  

  overflow: hidden;   /* impedisce scroll orizzontale */
}

#lastExecMeta .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;   /* fallback CSS */
  display: block;
  width: 100%;               /* prende tutto lo spazio del parent max 300px */
}

.last-exec-btn {
  flex: 0 0 auto;             /* pulsante fisso */
}
