/* ── Profilo utente ───────────────────────────────────────────────────────── */
.profile-wrap {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 2rem 4rem;
}
.profile-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}
.profile-section-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}
.stat-card {
  background: var(--bg-elevated);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}
.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: var(--accent);
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ── Form generico ────────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-group { margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}
.form-input, .form-select {
  width: 100%;
  padding: 0.7rem 1rem;
  font-family: inherit;
  font-size: 0.9rem;
  background: var(--search-bg);
  border: 1.5px solid var(--search-border);
  border-radius: 8px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.form-input:focus, .form-select:focus { border-color: var(--search-focus); }
.form-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Bottoni ──────────────────────────────────────────────────────────────── */
.btn-save {
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 1rem;
}

.btn-save#confirm-ok{
  margin-top: 0;
}


.btn-save:hover { background: var(--accent-hover); }
.btn-secondary {
  padding: 0.7rem 1.5rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); }
.btn-secondary[hidden] { display: none; }
.btn-danger {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #c0392b;
  border: 1px solid #c0392b;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-danger:hover { background: rgba(192,57,43,0.1); }

/* ── Sessioni ─────────────────────────────────────────────────────────────── */
.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.session-item:last-child { border-bottom: none; }
.session-info { font-size: 0.82rem; color: var(--text-secondary); }
.session-info strong { color: var(--text-primary); display: block; margin-bottom: 0.2rem; }
.session-current {
  font-size: 0.72rem;
  background: rgba(45,111,168,0.15);
  color: var(--accent);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* ── Cronologia ───────────────────────────────────────────────────────────── */
.history-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
a.history-link { display: block; text-decoration: none; color: inherit; transition: background 0.12s ease; padding: 0.75rem; margin: 0 -0.75rem; border-radius: 8px; border-bottom: 1px solid var(--border); }
a.history-link:hover { background: rgba(var(--accent-rgb, 59,130,246), 0.06); }
a.history-link:last-child { border-bottom: none; }
.history-answer-preview { font-size: 0.78rem; color: var(--text-muted); margin: 0.25rem 0; line-height: 1.4; font-style: italic; }

.cronologia-switch { display: inline-flex; gap: 4px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 3px; }
.cron-tab { background: transparent; border: none; padding: 5px 12px; border-radius: 6px; font-size: 0.78rem; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s ease; font-family: inherit; }
.cron-tab:hover { color: var(--text-primary); }
.cron-tab.active { background: var(--accent); color: white; }
.history-query {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.history-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.history-expanded {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  font-style: italic;
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #2d8a5a; color: #fff; }
.toast.error { background: #c0392b; color: #fff; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg);
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px var(--shadow);
}
.login-logo {
  display: block;
  height: 150px;
  margin: 0 auto 1.5rem;
}
.login-title {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}
.login-subtitle {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form-remember {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 1.5rem 0;
  cursor: pointer;
}
.form-remember input { accent-color: var(--accent); cursor: pointer; }
.btn-login {
  width: 100%;
  padding: 0.875rem;
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-login:hover { background: var(--accent-hover); }
.login-error {
  background: rgba(192, 57, 43, 0.1);
  border: 1px solid rgba(192, 57, 43, 0.3);
  color: #c0392b;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
[data-theme="dark"] .login-error {
  background: rgba(192, 57, 43, 0.15);
  color: #e74c3c;
}
